| 查看: 767 | 回复: 1 | ||
water11金虫 (正式写手)
|
[求助]
Java程序没有错误,但不显示结果,求指点。已有1人参与
|
|
java程序运行(环境Eclipse)时没有提示错误, 但是不显示结果,不明所以,请大家帮帮忙,非常感谢。 Person.java代码如下: public class Person { private boolean IsConsuming; private boolean IsConcerned; private int LastTimeChangeConcernedFromConsumingToNonConsuming; private ContinuousSpace <Object> mySpace; // handle for the space public Person(ContinuousSpace <Object> space, boolean consuming, boolean concerned){ IsConsuming=consuming; IsConcerned=concerned; mySpace = space; LastTimeChangeConcernedFromConsumingToNonConsuming = 0; } @ScheduledMethod (start=1, interval=1 ) public void step () { LastTimeChangeConcernedFromConsumingToNonConsuming++; } private void NonConcernedChangeFromConsumingToNonConsuming () { if (IsConcerned == false) { double rnd = RandomHelper.nextDouble(); if (rnd < 0.1) { IsConsuming = !IsConsuming; } } } private void ConsumingChangeFromNonConcernedToConcerned () { if (IsConcerned == false) { Context <Object> context = ContextUtils.getContext(this); Network <Object> net = (Network<Object> context.getProjection ("communication" ;Iterable<Object> neighbours = net.getAdjacent(this); for (Object obj : neighbours) { boolean neighbourConcernStatus = ((Person) obj).GetConcernStatus(); if (neighbourConcernStatus == true) { IsConcerned = true; } } } } private void ConcernedChangeFromConsumingToConsuming () { if ((IsConcerned == true) && (IsConsuming == true)) { Context <Object> context = ContextUtils.getContext(this); Network <Object> net = (Network<Object> context.getProjection ("communication" ;int number_of_neighbours = 0; int number_of_noncons = 0; Iterable<Object> neighbours = net.getAdjacent(this); for (Object obj : neighbours) { number_of_neighbours++; boolean neighbourConsumingStatus = ((Person) obj).GetConsumingStatus(); if (neighbourConsumingStatus == false) { number_of_noncons++; } } if (number_of_noncons == number_of_neighbours) { IsConsuming = false; LastTimeChangeConcernedFromConsumingToNonConsuming = 0; } } } private void NonConsumingChangeFromConcernedToNonConcerned () { if ((IsConcerned == true) && (IsConsuming ==false) && (LastTimeChangeConcernedFromConsumingToNonConsuming > 20)) { IsConcerned = false; } } public boolean GetConcernStatus() { return IsConcerned; } public boolean GetConsumingStatus() { return IsConsuming; } } MyStyle.java代码如下: public class MyStyle extends DefaultStyleOGL2D { @Override public Color getColor(Object obj) { if (obj instanceof Person) { Person agent = (Person) obj; if (agent.GetConsumingStatus() == true) { return Color.BLUE; } else { return Color.RED; } } else { return null; } } @Override public VSpatial getVSpatial(Object obj, VSpatial shape) { if (obj instanceof Person) { Person agent = (Person) obj; if (agent.GetConcernStatus() == true) { // consuming return shapeFactory.createRectangle(10, 10); // cubic } else { return shapeFactory.createCircle(3, 10); } } else { return null; } } } MyContextBuilder.java代码如下: public class MyContextBuilder implements ContextBuilder<Object> { public Context build(Context<Object> context) { ContinuousSpaceFactory spaceFactory = ContinuousSpaceFactoryFinder.createContinuousSpaceFactory(null); ContinuousSpace <Object> space = spaceFactory.createContinuousSpace ("space", context, new SimpleCartesianAdder<Object>(), new repast.simphony.space.continuous.WrapAroundBorders(), new double[]{1, 1}); for (int i=1; i<=3; i++){ Person p = new Person(space, true, true); context.add(p); } for (int i=1; i<=3; i++){ Person p = new Person(space, true, false); context.add(p); } for (int i=1; i<=47; i++){ Person p = new Person(space, true, false); context.add(p); } for (int i=1; i<=47; i++){ Person p = new Person(space, false, false); context.add(p); } // create network projection NetworkBuilder <Object> netBuilder = new NetworkBuilder<Object>("communication", context, false); NetworkGenerator gen; gen = new WattsBetaSmallWorldGenerator(0.25, 8, false); // prob connected, degree, symmetrical = false netBuilder.setGenerator(gen); netBuilder.buildNetwork(); RunEnvironment.getInstance().endAt(1000); return context; } } |
» 猜你喜欢
请问有评职称,把科研教学业绩算分排序的高校吗
已经有4人回复
孩子确诊有中度注意力缺陷
已经有12人回复
2025冷门绝学什么时候出结果
已经有3人回复
天津工业大学郑柳春团队欢迎化学化工、高分子化学或有机合成方向的博士生和硕士生加入
已经有4人回复
康复大学泰山学者周祺惠团队招收博士研究生
已经有6人回复
AI论文写作工具:是科研加速器还是学术作弊器?
已经有3人回复
2026博士申请-功能高分子,水凝胶方向
已经有6人回复
论文投稿,期刊推荐
已经有4人回复
硕士和导师闹得不愉快
已经有13人回复
请问2026国家基金面上项目会启动申2停1吗
已经有5人回复
» 本主题相关价值贴推荐,对您同样有帮助:
菜鸟求助,老师给了一个分子让优化,可总是错误,求大神指点
已经有22人回复
求指点:java web serivce 学习那个工具?
已经有4人回复
matlab程序运行总是出现下面的错误,请各位高手指点一下,谢谢了!急 急急
已经有5人回复
【求助】请高手指点一下vc++的一部分程序,看看哪有错误,急急。。。。。。。。。。
已经有6人回复
erghper
铜虫 (小有名气)
- 应助: 3 (幼儿园)
- 金币: 1419.8
- 红花: 1
- 帖子: 141
- 在线: 44.8小时
- 虫号: 1146544
- 注册: 2010-11-14
- 性别: GG
- 专业: 原子和分子物理
2楼2014-11-18 09:13:48














context.getProjection ("communication"
回复此楼