From: Richard O. L. <rle...@ai...> - 2012-07-30 10:53:08
|
Hi Yang, Probably the solution is in this line: Caused by: java.lang.NullPointerException at moveagent.People.step(People.java:31) It is hard to tell which is line 31 based on what you attached, but I guess either the projection or the space query results in a /null/. Please double check if they are spelled properly and identical to what you defined. Best, Richard -- Richard O. Legendi Software developer Intelligent Applications and Web Services AITIA International, Inc. http://people.inf.elte.hu/legendi/ On 2012.07.30. 12:41, yang chen wrote: > Hi: > i design a very simple modle.just people as agents walk in the > grid.i can initial my modle successfully,but when i run my > modle,agents cann't move.(Tick can move). i donn't know why.and i have > think for 2 days.so please help me. > error log as follows: > 2012/07/30 11:07:00,116: Tried to call: public void > moveagent.People.step() > java.lang.reflect.InvocationTargetException > at moveagent.People$$FastClassByCGLIB$$418e0c09.invoke(<generated>) > at net.sf.cglib.reflect.FastMethod.invoke(FastMethod.java:53) > at > repast.simphony.engine.schedule.DynamicTargetAction.execute(DynamicTargetAction.java:69) > at > repast.simphony.engine.controller.ScheduledMethodControllerAction$ScheduleMethodAction.execute(ScheduledMethodControllerAction.java:216) > at > repast.simphony.engine.schedule.DefaultAction.execute(DefaultAction.java:38) > at > repast.simphony.engine.schedule.ScheduleGroup.executeList(ScheduleGroup.java:184) > at > repast.simphony.engine.schedule.ScheduleGroup.execute(ScheduleGroup.java:201) > at repast.simphony.engine.schedule.Schedule.execute(Schedule.java:352) > at > repast.simphony.ui.GUIScheduleRunner$ScheduleLoopRunnable.run(GUIScheduleRunner.java:53) > at java.lang.Thread.run(Unknown Source) > Caused by: java.lang.NullPointerException > at moveagent.People.step(People.java:31) > ... 10 more > peoples codes as follows: > public class People { > public double heading; > > public People(double heading) { > this.heading=heading ; > } > @ScheduledMethod(start = 1, interval = 1) > public void step() { > Context cdcontext = ContextUtils.getContext(this); > Grid grid = (Grid) cdcontext.getProjection("Simple Grid"); > ContinuousSpace cdspace = (ContinuousSpace) > cdcontext.getProjection("Continuou Space"); > NdPoint point = cdspace.getLocation(this); > double x = point.getX(); > double y = point.getY(); > if (Math.random() > 0.5) > heading = heading + Math.random() * 50; > else > heading = heading - Math.random() * 50; > > cdspace.moveByVector(this, 1, Math.toRadians(heading), 0,0); > grid.moveTo(this, (int) x, (int)y); > > } > } > > thank you! > > > > ------------------------------------------------------------------------------ > Live Security Virtual Conference > Exclusive live event will cover all the ways today's security and > threat landscape has changed and how IT managers can respond. Discussions > will include endpoint security, mobile security and the latest in malware > threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ > > > _______________________________________________ > Repast-interest mailing list > Rep...@li... > https://lists.sourceforge.net/lists/listinfo/repast-interest |