From: Dave Murray-R. <d.m...@ed...> - 2008-12-17 11:26:42
|
After further investigation, if I take a working model, and add a grid to it, without locating any of the agents in the grid, then this error crops up. Once the removal ContextEvent has been fired, it drops down to remove(T) in AbstractGrid, which doesn't check that the agent is part of the projection before trying to remove it: protected void remove(T t) { GridPoint location = agentLocationMap.remove(t).point; if (location != null) { accessor.remove(t, locationStorage, location); } size--; fireProjectionEvent(new ProjectionEvent(this, t, ProjectionEvent.OBJECT_REMOVED)); } In my case, where the agents haven't been added to the projection, I'm assuming that remove(t) will return null, so this won't work? Or is there always a PointHolder for every agent in the projection? (And should I just upgrade to 1.2?) Cheers, dave On 16 Dec 2008, at 17:54, Nick Malleson wrote: > > Here's a forwarded message, looks like someone else has found the same > problem when trying to remove agents from a context (apologies if > this has > been resolved in the new version of repast, I haven't updated yet). > > From: Dave Murray-Rust [mailto:d.m...@ed...] > Sent: 16 December 2008 17:49 > To: Nicolas Malleson > Subject: Re: [Repast-interest] NullPointerException when removing > agent from > a context > > I can confirm a similar error: > > java.lang.NullPointerException > at > repast.simphony.space.grid.AbstractGrid.remove(AbstractGrid.java: 404) > at repast > .simphony > .context.space.grid.ContextGrid.eventOccured(ContextGrid.java: 60) > at repast .simphony > .context.AbstractContext.fireContextEvent(AbstractContext.java:360) > at repast > .simphony > .context.AbstractContext.fireRemoveEvent(AbstractContext.java: 221) > at > repast.simphony.context.AbstractContext.remove(AbstractContext.java: > 193) > at simplegeoinformatics.agent.Agent.die(Agent.java:35) > at simplegeoinformatics.agent.Mature.becomeOld(Mature.java:40) > at simplegeoinformatics.agent.Mature.update(Mature.java:29) > at simplegeoinformatics.agent.Mature$$FastClassByCGLIB$ > $cb292121.invoke(<generated>) > at net.sf.cglib.reflect.FastMethod.invoke(FastMethod.java:53) > at repast > .simphony > .engine.schedule.CallBackAction.execute(CallBackAction.java: 123) > 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:51) > at java.lang.Thread.run(Thread.java:613) > > with context.contains(agent) returning true just before the error. My > agents have not been added to any projection. After the error, the > agent doesn't appear to be in a context, but the scheduler still acts > on it. > > Cheers, > dave > > On 2 Dec 2008, at 09:35, Nick Malleson wrote: > >> >> Hi Nick, >> >> I tried calling getLocation() and it works fine. In summary, just >> before >> trying to remove the agent these commands are OK: >> >> context.contains(agent); // returns true >> projection.getLocation(agent); // returns the agent's location. >> >> But then context.remove(agent) throws the error. >> >> Thanks, >> Nick M >> > > > > -- > View this message in context: http://www.nabble.com/NullPointerException-when-removing-agent-from-a-context-tp20678989p21038228.html > Sent from the repast-interest mailing list archive at Nabble.com. > > > ------------------------------------------------------------------------------ > SF.Net email is Sponsored by MIX09, March 18-20, 2009 in Las Vegas, > Nevada. > The future of the web can't happen without you. Join us at MIX09 to > help > pave the way to the Next Web now. Learn more and register at > http://ad.doubleclick.net/clk;208669438;13503038;i?http://2009.visitmix.com/ > _______________________________________________ > Repast-interest mailing list > Rep...@li... > https://lists.sourceforge.net/lists/listinfo/repast-interest > -- The University of Edinburgh is a charitable body, registered in Scotland, with registration number SC005336. |