From: Erica C. <eca...@gm...> - 2012-07-25 15:00:30
|
Hi Nick, Do you mean delete any default displays and then run it? I did that, and no error messages wrre throen, although the programme did go unresponsive at about tick count 674.0. I had to stop the thread from the console as the pause or stop buttons did not work at this point. Kind regards, Erica. On Wed, Jul 25, 2012 at 2:21 PM, Nick Collier <nic...@ve...>wrote: > Can you try running without the display and see if you get a more > informative error? > > thanks, > > Nick > > On Jul 24, 2012, at 3:15 PM, Erica Calogero wrote: > > Hi there Nick, > > That indeed did the trick. Now that I have done that, I get this error: > > Exception in thread "AWT-EventQueue-0" *java.lang.NullPointerException* > > at > repast.simphony.visualizationOGL2D.DisplayOGL2D.getSpatialForObject(* > DisplayOGL2D.java:526*) > > at repast.simphony.visualizationOGL2D.NetworkLayerOGL2D.update(* > NetworkLayerOGL2D.java:103*) > > at repast.simphony.visualizationOGL2D.DisplayOGL2D.update(* > DisplayOGL2D.java:402*) > > at repast.simphony.visualizationOGL2D.DisplayOGL2D.reshape(* > DisplayOGL2D.java:580*) > > at saf.v3d.Canvas2D.reshape(*Canvas2D.java:362*) > > at com.sun.opengl.impl.GLDrawableHelper.reshape(* > GLDrawableHelper.java:85*) > > at javax.media.opengl.GLCanvas$DisplayAction.run(*GLCanvas.java:431 > *) > > at com.sun.opengl.impl.GLDrawableHelper.invokeGL(* > GLDrawableHelper.java:194*) > > at javax.media.opengl.GLCanvas.maybeDoSingleThreadedWorkaround(* > GLCanvas.java:412*) > > at javax.media.opengl.GLCanvas.display(*GLCanvas.java:244*) > > at javax.media.opengl.GLCanvas.paint(*GLCanvas.java:277*) > > at sun.awt.RepaintArea.paintComponent(Unknown Source) > > at sun.awt.RepaintArea.paint(Unknown Source) > > at sun.awt.windows.WComponentPeer.handleEvent(Unknown Source) > > at java.awt.Component.dispatchEventImpl(Unknown Source) > > at java.awt.Component.dispatchEvent(Unknown Source) > > at java.awt.EventQueue.dispatchEventImpl(Unknown Source) > > at java.awt.EventQueue.access$000(Unknown Source) > > at java.awt.EventQueue$1.run(Unknown Source) > > at java.awt.EventQueue$1.run(Unknown Source) > > at java.security.AccessController.doPrivileged(*Native Method*) > > at > java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown Source) > > at > java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown Source) > > at java.awt.EventQueue$2.run(Unknown Source) > > at java.awt.EventQueue$2.run(Unknown Source) > > at java.security.AccessController.doPrivileged(*Native Method*) > > at > java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown Source) > > at java.awt.EventQueue.dispatchEvent(Unknown Source) > > at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown > Source) > > at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source) > > at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown > Source) > > at java.awt.EventDispatchThread.pumpEvents(Unknown Source) > > at java.awt.EventDispatchThread.pumpEvents(Unknown Source) > > at java.awt.EventDispatchThread.run(Unknown Source) > > From the following code (which is based on the JZombies_Demo project, with > a modified builder class that looks like: > > public class JZombiesBuilder implements ContextBuilder<Object> { > > > /* > > * (non-Javadoc) > > * > > * @see > > * > repast.simphony.dataLoader.ContextBuilder#build(repast.simphony.context > > * .Context) > > */ > > @Override > > public Context build(Context<Object> context) { > > context.setId("jzombies"); > > > MyNodeCreator myCreator = new > MyNodeCreator(); > > > NetworkBuilder<Object> builder = new > NetworkBuilder<Object>("spatialNetwork", > > context, > false); > > > try { > > > builder.load("./matrices.xls", > > > NetworkFileFormat.EXCEL, myCreator); > > } catch (IOException e) { > > e.printStackTrace(); > > } > > Network<Object> spatialNetwork = > builder.buildNetwork(); > > > ContinuousSpaceFactory spaceFactory = > ContinuousSpaceFactoryFinder > > > .createContinuousSpaceFactory(null); > > ContinuousSpace<Object> space = > spaceFactory.createContinuousSpace( > > "space", > context, new RandomCartesianAdder<Object>(), > > new > repast.simphony.space.continuous.WrapAroundBorders(), 50, > > 50); > > > GridFactory gridFactory = > GridFactoryFinder.createGridFactory(null); > > Grid<Object> grid = > gridFactory.createGrid("grid", context, > > new > GridBuilderParameters<Object>(new WrapAroundBorders(), > > > new SimpleGridAdder<Object>(), true, 50, 50)); > > > for (Object obj : context) { > > NdPoint pt = > space.getLocation(obj); > > grid.moveTo(obj, (int) > pt.getX(), (int) pt.getY()); > > } > > > return context; > > } > > } > > Could you let me know if you can see what the error might be from this? > > Thank you, > > Kind regards, > > Erica. > > On Wed, Jul 11, 2012 at 2:05 PM, Nick Collier <nic...@ve...>wrote: > >> Eric, >> >> Does "./matrices.xls" work? If you look at the launcher for your model, >> you can see what the working directory is and set the path relative to >> that. Also, you could just give full complete path. >> >> Nick >> >> On Jul 11, 2012, at 5:50 AM, Erica Calogero wrote: >> >> Hi Nick, >> >> Thank you for the help. I am having difficulty getting rid of a file I/O >> error with the code. I have created an excel file called matrices, and >> placed it in the root folder of the project. If that is the case, what text >> would I replace the current filepath with in the following bit of code to >> make it not throw this error? (I know this is really basic, which is why I >> don't want to post to the whole list)... >> >> >> builder.load("repast.simphony.core/test/repast/simphony/graph/matrices.xls", >> >> Thank you for your help, >> >> Kind regards, >> >> Erica. >> >> >> On Thu, Jul 5, 2012 at 2:05 PM, Nick Collier <nic...@ve...>wrote: >> >>> Erica, >>> >>> The NetworkBuilder will create the nodes, add them to the context, as >>> well as create the network projection and add it to the context. Given >>> that, you don't need the code in your example that creates the nodelist, >>> adds agents to it, etc. >>> >>> Nick >>> >>> On Jul 4, 2012, at 11:29 AM, Erica Calogero wrote: >>> >>> Hi there, >>> >>> Just to add that I am trying to follow these instructions to create a >>> Context Builder using a Network projection following these instructions: >>> >>> >>> http://repast.sourceforge.net/docs/reference/SIM/Network%20Projections.html >>> >>> The code I have so far is below: >>> >>> /** >>> >>> * >>> >>> */ >>> >>> package NetworkAgents.NetworkAgents; >>> >>> >>> >>> import java.io.IOException; >>> >>> import java.util.List; >>> >>> import repast.simphony.context.Context; >>> >>> import repast.simphony.context.space.graph.NetworkBuilder; >>> >>> import repast.simphony.context.space.graph.NetworkFileFormat; >>> >>> import repast.simphony.dataLoader.ContextBuilder; >>> >>> import repast.simphony.random.RandomHelper; >>> >>> import repast.simphony.space.graph.Network; >>> >>> >>> >>> /** >>> >>> * @author Erica Calogero July 2012 (c) All rights reserved >>> >>> * >>> >>> */ >>> >>> public class NetAgentsBuilder implements ContextBuilder<Object> { >>> >>> >>> >>> @Override >>> >>> public Context<Object> build(Context<Object> context) { >>> >>> >>> >>> context.setId("NetworkAgents"); >>> >>> >>> >>> MyNodeCreator myCreator = new >>> MyNodeCreator(); >>> >>> >>> >>> NetworkBuilder<Object> builder = new >>> NetworkBuilder<Object>("spatialNetwork", >>> >>> context, >>> false); >>> >>> //builder.setEdgeCreator(new >>> NetworkEdgeCreator<NetSpatialNode>()); >>> >>> try { >>> >>> >>> builder.load("repast.simphony.core/test/repast/simphony/graph/matrices.xls", >>> >>> >>> NetworkFileFormat.EXCEL, myCreator); >>> >>> } catch (IOException e) { >>> >>> e.printStackTrace(); >>> >>> } >>> >>> Network<Object> spatialNetwork = >>> builder.buildNetwork(); >>> >>> >>> >>> //TODO create an importer that can >>> import a list of nodes >>> >>> //that exist in the imported network >>> >>> //right now this is just dummy code >>> >>> List<NetSpatialNode> nodelist = null; >>> >>> for(int i = 0; i < 20; i++){ >>> >>> nodelist.add(new >>> NetSpatialNode()); >>> >>> } >>> >>> //This is where the agents that move get >>> added to the context >>> >>> int agentCount = 10; >>> >>> for(int i = 0; i < agentCount; i++){ >>> >>> NetSpatialNode startnode >>> = nodelist.get(RandomHelper.nextIntFromTo(0, nodelist.size()-1)); >>> >>> context.add(new >>> wayFinder(startnode, nodelist)); >>> >>> } >>> >>> >>> >>> return context; >>> >>> } >>> >>> >>> >>> } >>> >>> On Wed, Jul 4, 2012 at 2:21 PM, Erica Calogero <eca...@gm...>wrote: >>> >>>> Hi Richard, >>>> >>>> Yes, this looks interesting as a way to import the network information >>>> into a file the regular java way. It does not however implement a network >>>> context, which I am interested in doing. I will see what I can do with this >>>> as a starting point. Thank you, the documentation looks extremely clear. >>>> >>>> Kind regards, >>>> >>>> Erica. >>>> >>>> >>>> On Wed, Jul 4, 2012 at 1:30 PM, Richard O. Legendi <rle...@ai...>wrote: >>>> >>>>> Hi Erica, >>>>> >>>>> Here is a small description how to handle an input file from Repast >>>>> Simphony: >>>>> >>>>> http://code.google.com/p/cscs-**repast-demos/wiki/StupidModel#** >>>>> Habitat_Data_from_File_Input<http://code.google.com/p/cscs-repast-demos/wiki/StupidModel#Habitat_Data_from_File_Input> >>>>> >>>>> Here I use it to construct a 2D world, creating an initial network >>>>> from a file should be similar, and it is reading a simple CSV file (you can >>>>> save any Excel sheet as Coma Separated Values). >>>>> >>>>> If you need to use advanced features of Excel through the Repast Java >>>>> API, you'll need something like Apache POI to do the job ( >>>>> http://poi.apache.org/). >>>>> >>>>> Hope that helps a bit. >>>>> >>>>> Best regards, >>>>> Richard >>>>> >>>>> -- >>>>> Richard O. Legendi >>>>> Software developer >>>>> Intelligent Applications and Web Services >>>>> AITIA International, Inc. >>>>> http://people.inf.elte.hu/**legendi/<http://people.inf.elte.hu/legendi/> >>>>> >>>>> >>>>> On 2012.07.04. 14:18, Erica Calogero wrote: >>>>> >>>>>> Hi there, >>>>>> >>>>>> I am a newbie looking for a demo project that uses an imported file >>>>>> from excel. Can anybody tell me if they have one? >>>>>> >>>>>> Thanks, >>>>>> Erica >>>>> >>>>> |