From: Jonathan O. <xi...@gm...> - 2011-05-31 15:53:07
|
Hi David, Regarding the error you see in the ReLogo model, there was a bug based on a faulty assumption that's been fixed. It will be part of the next release but let me know if you'd like a workaround in the meantime. Jonathan On May 31, 2011, at 9:56 AM, David Makovoz wrote: > My goal is to run Repast model programmatically. To this end I use a class MPCRunner extends AbstractRunner; > with the following members: > private RunEnvironmentBuilder runEnvironmentBuilder; > protected Controller controller; > private Schedule schedule; > and the following basic functionalities: > public void load(File scenarioDir) { > BatchScenarioLoader loader = new BatchScenarioLoader(scenarioDir); > ControllerRegistry registry = loader.load(runEnvironmentBuilder); > controller.setControllerRegistry(registry); > controller.batchInitialize(); > controller.runParameterSetters(loader.getParameters()); } > public void runInitialize() { > controller.runInitialize(null); > schedule = (Schedule) RunState.getInstance().getScheduleRegistry() > .getModelSchedule();} > public void step() { > schedule.execute();} > > Which are called in that order in the main program: > MPCRunner mpc = new MPCRunner(XmlCheckpoint.class); > mpc.load(file); > mpc.runInitialize(); > mpc.step(); > > I have been working with the sample models that comes with Repast, there are 11 java-based models, 1 groovy-based model and 1 Relogo (which also means groovy) model. > I can successfully execute the above three steps for all the java-based models, but fail for both groovy-based models, FlowZombies and Zombies. > Below I pasted the error stack traces. > There must be something I have to do differently with these models, isn't there? > Thanks > > David > > Here are the error stack traces. Note that both start essentially with MPCRunner.java:101, which is: controller.runInitialize(null); > 1. FlowZombies: > java.lang.NullPointerException > at repast.simphony.engine.controller.WatcherControllerAction.runInitialize(WatcherControllerAction.java:50) > at repast.simphony.engine.controller.DefaultController$2.visit(DefaultController.java:179) > at repast.simphony.engine.controller.DefaultController$2.visit(DefaultController.java:1) > at repast.simphony.util.collections.NaryTree.preOrderTraverals(NaryTree.java:301) > at repast.simphony.util.collections.NaryTree.preOrderTraverals(NaryTree.java:304) > at repast.simphony.util.collections.NaryTree.preOrderTraverals(NaryTree.java:304) > at repast.simphony.util.collections.NaryTree.preOrderTraversal(NaryTree.java:297) > at repast.simphony.engine.controller.DefaultController.runInitialize(DefaultController.java:177) > at repast.simphony.engine.controller.DefaultController.runInitialize(DefaultController.java:335) > at repast.simphony.mpc.MPCRunner.runInitialize(MPCRunner.java:101) > at repast.simphony.mpc.test.MPCTestMain.run(MPCTestMain.java:56) > at repast.simphony.mpc.test.MPCTestMain.main(MPCTestMain.java:43) > > Here is WatcherControllerAction.java:50 for (Object obj : context.getContextListeners()) > I debugged it, context = null; > > 2. Zombies: > java.lang.NullPointerException > at repast.simphony.relogo.factories.LinkFactory.<init>(LinkFactory.java:52) > at repast.simphony.relogo.factories.LinkFactory.<init>(LinkFactory.java:46) > at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) > at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source) > at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source) > at java.lang.reflect.Constructor.newInstance(Unknown Source) > at org.codehaus.groovy.reflection.CachedConstructor.invoke(CachedConstructor.java:77) > at org.codehaus.groovy.runtime.callsite.ConstructorSite$ConstructorSiteNoUnwrapNoCoerce.callConstructor(ConstructorSite.java:102) > at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallConstructor(CallSiteArray.java:52) > at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:190) > at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:198) > at zombies.context.SimBuilder.build(SimBuilder.groovy:32) > at repast.simphony.dataLoader.engine.ClassNameContextBuilder.build(ClassNameContextBuilder.java:41) > at repast.simphony.dataLoader.engine.DataLoaderControllerAction.runInitialize(DataLoaderControllerAction.java:48) > at repast.simphony.engine.controller.DefaultController$2.visit(DefaultController.java:179) > at repast.simphony.engine.controller.DefaultController$2.visit(DefaultController.java:1) > at repast.simphony.util.collections.NaryTree.preOrderTraverals(NaryTree.java:301) > at repast.simphony.util.collections.NaryTree.preOrderTraverals(NaryTree.java:304) > at repast.simphony.util.collections.NaryTree.preOrderTraverals(NaryTree.java:304) > at repast.simphony.util.collections.NaryTree.preOrderTraversal(NaryTree.java:297) > at repast.simphony.engine.controller.DefaultController.runInitialize(DefaultController.java:177) > at repast.simphony.engine.controller.DefaultController.runInitialize(DefaultController.java:335) > at repast.simphony.mpc.MPCRunner.runInitialize(MPCRunner.java:101) > at repast.simphony.mpc.test.MPCTestMain.run(MPCTestMain.java:57) > at repast.simphony.mpc.test.MPCTestMain.main(MPCTestMain.java:44) > > Here is LinkFactory.java:51-52 > this(dirLinkClass, undirLinkClass, > ReLogoImplementingClassesFinder.find(RSApplication.getRSApplicationInstance().getCurrentScenario(),BaseLink.class)); > I debugged it: > RSApplication.getRSApplicationInstance() = null; > ------------------------------------------------------------------------------ > Simplify data backup and recovery for your virtual environment with vRanger. > Installation's a snap, and flexible recovery options mean your data is safe, > secure and there when you need it. Data protection magic? > Nope - It's vRanger. Get your free trial download today. > http://p.sf.net/sfu/quest-sfdev2dev_______________________________________________ > Repast-interest mailing list > Rep...@li... > https://lists.sourceforge.net/lists/listinfo/repast-interest |