From: Van P. <van...@gm...> - 2017-02-01 15:55:35
|
That did it! Thanks, Nick. On 2/1/17 09:13, Nick Collier wrote: > You should be able to set the data loader just on the top context. > That context builder should create the two subcontexts and add the > agents, projections to them. I’m guessing that the double displays is > because the there are two copies of the networks and so they are > displayed twice. Its hard to say for sure though. > > Nick > > >> On Jan 31, 2017, at 11:00 AM, Van Parunak <van...@gm... >> <mailto:van...@gm...>> wrote: >> >> OK, I see that I had defined the displays in the top-level context. >> So I removed them there, defined them in each of the subcontexts, and >> added my context builder to the DataLoader field in each subtree. Now >> I get my displays...but I get two of each! That is, I define one >> display in each of two subcontexts, and none in the top context, but >> I end up with four displays. Thoughts? >> >> By the way, I discovered that I have to define my dataloader in both >> the top-level context and the subcontexts in the scenario tree, >> otherwise it doesn't work. >> >> On 1/31/17 09:14, Nick Collier wrote: >>> The “caused by” section of the stack trace indicates that the display cannot find the “target” projection to display? In the scenario tree, what context do you have the display attached to? >>> >>> Nick >>> >>>> On Jan 30, 2017, at 9:10 PM, Van Parunak<van...@gm...> wrote: >>>> >>>> I'd be grateful if someone can help me figure out what's wrong with an >>>> application of subcontexts. >>>> >>>> I'm manipulating two graphs, and it seems natural to put all the nodes >>>> in each graph in a separate subcontext so that I can easily iterate over >>>> them. My context builder starts out like this: >>>>> public Context<Object> build(Context<Object> context) { >>>>> context.setId("assist"); >>>>> >>>>> Context<Object> patternContext = new DefaultContext(); >>>>> patternContext.setId("patternContext"); >>>>> context.addSubContext(patternContext); >>>>> context.add(patternContext); >>>>> >>>>> Context<Object> targetContext = new DefaultContext(); >>>>> targetContext.setId("targetContext"); >>>>> context.addSubContext(targetContext); >>>>> context.add(targetContext); >>>> Then I invoke the network builder twice, once for each subcontext. >>>> Here's the code for the target graph: >>>>> NetworkBuilder<Object> targetBuilder = new >>>>> NetworkBuilder<Object>("target", targetContext, false); >>>>> NodeCreator tnc = new DefaultNodeCreator(TargetNode.class); >>>>> try { >>>>> targetBuilder.load(targetPath, NetworkFileFormat.EXCEL, tnc); >>>>> } >>>>> catch (IOException e) { >>>>> System.out.println("IOException occurred when trying to >>>>> build network: " + e.getMessage()); >>>>> } >>>>> catch (Exception e) >>>>> { >>>>> System.out.println("Non-IO Exception occurred when trying >>>>> to build network: " + e.getMessage()); >>>>> } >>>>> Network<Object> target = targetBuilder.buildNetwork(); >>>> The code for the pattern graph is analogous. >>>> >>>> I've named both subcontexts in my context.xml file: >>>>> <context id="assist" >>>>> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" >>>>> xsi:noNamespaceSchemaLocation="http://repast.org/scenario/context"> >>>>> <context id = "targetContext"> >>>>> <projection type="network" id="target"></projection> >>>>> </context> >>>>> <context id = "patternContext"> >>>>> <projection type="network" id="pattern"></projection> >>>>> </context> >>>>> </context> >>>> The scenario is configured with two displays, one for each graph in its >>>> own tab. >>>> >>>> When I try to run this, both graphs load OK from their respective input >>>> files (as shown by diagnostic msgs I'm printing from the my >>>> NodeCreators). But then the display creation fails: >>>>> ERROR [AWT-EventQueue-0] 20:48:41,335 >>>>> repast.simphony.visualization.engine.DisplayComponentControllerAction >>>>> - Error while creating displays >>>>> repast.simphony.visualization.engine.DisplayCreationException: Error >>>>> while creating display. >>>>> at >>>>> repast.simphony.visualization.engine.DisplayCreatorOGL2D.createDisplay(DisplayCreatorOGL2D.java:102) >>>>> at >>>>> repast.simphony.visualization.engine.DisplayProducer.createDisplay(DisplayProducer.java:45) >>>>> at >>>>> repast.simphony.visualization.engine.DisplayComponentControllerAction.runInitialize(DisplayComponentControllerAction.java:104) >>>>> ... >>>>> Caused by: java.lang.RuntimeException: Projection 'target' not found. >>>>> at >>>>> repast.simphony.visualization.engine.AbstractCartesianDisplayCreator.createLayout(AbstractCartesianDisplayCreator.java:57) >>>>> at >>>>> repast.simphony.visualization.engine.DisplayCreatorOGL2D.createDisplay(DisplayCreatorOGL2D.java:62) >>>>> ... 49 more >>>> and similarly for the 'pattern' projection. Clearly the display runtime >>>> can't find my projections. >>>> >>>> I have another version of the same builder without subcontexts. The only >>>> differences are that the second argument to NetworkBuilder is simply >>>> context rather than targetContext (respectively, patternContext), and >>>> the context.xml says simply >>>>> <context id="assist" >>>>> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" >>>>> xsi:noNamespaceSchemaLocation="http://repast.org/scenario/context"> >>>>> <projection type="network" id="target"></projection> >>>>> <projection type="network" id="pattern"></projection> >>>>> </context> >>>> This version runs just fine. What am I missing? >>>> >>>> >>>> >>>> ------------------------------------------------------------------------------ >>>> Check out the vibrant tech community on one of the world's most >>>> engaging tech sites,SlashDot.org <http://slashdot.org>!http://sdm.link/slashdot >>>> _______________________________________________ >>>> Repast-interest mailing list >>>> Rep...@li... >>>> https://lists.sourceforge.net/lists/listinfo/repast-interest >> >> -- >> H. Van Dyke Parunak, Ph.D. >> President, ABC Research, LLC >> <LogoColorArtNouveau_Small.png> <http://www.abcresearch.org/> >> Superior solutions through Agent-Based and Complex systems >> 1027 Ferdon Road >> Ann Arbor, MI 48104-3630 >> email: van...@gm... <x-msg://49/van...@gm...> >> cell: 734 395 3253 >> www.ABCResearch.org <http://www.abcresearch.org/> > -- H. Van Dyke Parunak, Ph.D. President, ABC Research, LLC <http://www.abcresearch.org> Superior solutions through Agent-Based and Complex systems 1027 Ferdon Road Ann Arbor, MI 48104-3630 email: van...@gm... cell: 734 395 3253 www.ABCResearch.org <http://www.abcresearch.org> |