From: Jeremy J. <jer...@gm...> - 2005-11-08 19:17:20
|
1.)Does Repast Py make code on its own to support polygonal neighbors? For example, when writing in Repast J I wrote code such as the following to create an array of neighbors for each agent and display them to the user. Would this all have to be written from scratch in Repast Py, or is it already there for us? neighborhoodFile =3D "C:\\Jeremy\\Raja\\farms4queen.GAL"; // create a list of geoAgents geoAgentList.addAll(gisHandler.createAgents(Areal_Agents.class, datasource)); gisHandler.readNeighborhoodInfo(neighborhoodFile, geoAgentList); for (int i =3D 0; i < geoAgentList.size(); i++){ int [] neighborArray =3D ((Areal_Agents)geoAgentList.get(i)).getNeighbors()= ; System.out.println("Neighbors for Polygon "+ (i) + " are "); for (int j=3D0; j < neighborArray.length; j++){ System.out.println("Polygon # "+ (neighborArray[j])); } } the following function was also necessary: public ArrayList getNeighborAgents(int [] neighbors) { ArrayList neighborAgents =3D new ArrayList(); for (int i =3D 0; i < neighbors.length; i++) { neighborAgents.add((Areal_Agents)geoAgentList.get(neighbors[i])); } return neighborAgents; } 2.) Also, I'm wondering if anyone else has had problems using java.util.ArrayList in Py. I've entered it as a field type, hoping to store integers in the array, but for some reason the " .add()" method is not recognized, even though the NQPy tutorial that comes with it seems to suggest that this should work. -- (514) 807-6350 Home (617) 306-5085 Cell Isaiah55:8-9 for my thoughts are not your thoughts and neither are my ways your ways. As the heavens are higher than the earth, so are my ways higher than your ways and my thoughts higher than your thoughts. |