| package org.metaabm.gen.test; |
| |
| /** |
| * Basic Movement Model Java Implementation. |
| * Most recent version. |
| * Generated by metaabm system: May 13, 2009 11:53:51 AM PDT in project: org.metaabm.gen.repast.test (testing) */ |
| |
| import static org.junit.Assert.*; |
| |
| public class BasicMovementModel extends repast.simphony.context.DefaultContext |
| implements |
| repast.simphony.dataLoader.ContextBuilder, |
| IBasicMovementModel { |
| |
| /** |
| * The number of areas to create. |
| */ |
| |
| private int areaCount = 0; |
| /** |
| * The number of network agents to create. |
| */ |
| |
| private int networkAgentCount = 0; |
| /** |
| * The number of generate act people to create. |
| */ |
| |
| private int basicMovementAgentCount = 0; |
| /** |
| * The number of complex space agents to create. |
| */ |
| |
| private int complexSpaceAgentCount = 0; |
| /** |
| * The number of act non movement persons to create. |
| */ |
| |
| private int actNonMovementPersonCount = 0; |
| /** |
| * The number of basic movement state agents to create. |
| */ |
| |
| private int basicMovementStateAgentCount = 0; |
| /** |
| * The size of each dimension. |
| */ |
| |
| private int[] gridDimensions = new int[2]; |
| /** |
| * |
| */ |
| |
| private repast.simphony.space.grid.Grid grid = null; |
| /** |
| * |
| */ |
| |
| private repast.simphony.space.graph.Network testNetwork = null; |
| /** |
| * Constructs a new Basic Movement Model. |
| */ |
| |
| public BasicMovementModel() { |
| createUniqueID(); |
| setGridWidth(100); |
| setGridHeight(50); |
| } |
| |
| repast.simphony.context.Context buildContext; |
| |
| //todo, make this a useful value for evaluating compatibility of different versions of generated classes |
| private static final long serialVersionUID = 89989998L; |
| |
| private String uniqueID; |
| |
| public String getUID() { |
| return uniqueID; |
| } |
| |
| public void createUniqueID() { |
| uniqueID = org.apache.commons.lang.RandomStringUtils |
| .randomAlphanumeric(5); |
| } |
| |
| /** |
| * Clones the agent, ensuring that a unique id is assigned. |
| */ |
| public Object clone() { |
| try { |
| BasicMovementModel clone = (BasicMovementModel) super.clone(); |
| clone.createUniqueID(); |
| return clone; |
| } catch (Exception e) { |
| throw new RuntimeException("Unexpected cloning exception: " + e); |
| } |
| } |
| |
| @org.junit.Test |
| public void dummy() { |
| assertTrue(true); |
| } |
| |
| public repast.simphony.context.Context getContext() { |
| return buildContext; |
| } |
| |
| /** |
| * Builds and returns a context based on MetaABM generation for repast.simphony. Building a context consists of filling it with |
| * agents, adding projects and so forth. When this is called for the master context |
| * the system will pass in a created context based on information given in the |
| * model.score file. When called for subcontexts, each subcontext that was added |
| * when the master context was built will be passed in. |
| * |
| * @param context |
| * @return the built context. |
| */ |
| public repast.simphony.context.Context build( |
| repast.simphony.context.Context context) { |
| this.buildContext = context; |
| |
| NetworkAgent createNetworkAgents = null; |
| for (int i = 0; i < getNetworkAgentCount(); i++) { |
| createNetworkAgents = new NetworkAgent(); |
| context.add(createNetworkAgents); |
| |
| createNetworkAgents.setBasicMovementModel(this); |
| |
| } |
| |
| BasicMovementAgent createPerson1 = null; |
| for (int i = 0; i < getBasicMovementAgentCount(); i++) { |
| createPerson1 = new BasicMovementAgent(); |
| context.add(createPerson1); |
| |
| createPerson1.setBasicMovementModel(this); |
| |
| } |
| |
| //Agents are never actually added automatically |
| repast.simphony.space.grid.GridAdder buildAgentsAdder = new repast.simphony.space.grid.RandomGridAdder(); |
| repast.simphony.space.grid.GridBuilderParameters params = new repast.simphony.space.grid.GridBuilderParameters( |
| new repast.simphony.space.grid.StrictBorders(), |
| buildAgentsAdder, true, gridDimensions); |
| grid = repast.simphony.context.space.grid.GridFactoryFinder |
| .createGridFactory(null).createGrid("Grid", context, params); |
| |
| repast.simphony.space.grid.GridDimensions dims = grid.getDimensions(); |
| |
| for (int d0 = 0; d0 < dims.getDimension(0); d0++) { |
| |
| for (int d1 = 0; d1 < dims.getDimension(1); d1++) { |
| |
| int[] nextLoc = { |
| |
| d0, d1}; |
| org.metaabm.gen.test.BasicCell basicCell = new org.metaabm.gen.test.BasicCell(); |
| context.add(basicCell); |
| grid.moveTo(basicCell, nextLoc); |
| |
| } |
| } |
| |
| testNetwork = repast.simphony.context.space.graph.NetworkFactoryFinder |
| .createNetworkFactory(null).createNetwork("Test Network", |
| context, false); |
| |
| BasicMovementStateAgent createBasicMovementStateAgents = null; |
| for (int i = 0; i < getBasicMovementStateAgentCount(); i++) { |
| createBasicMovementStateAgents = new BasicMovementStateAgent(); |
| context.add(createBasicMovementStateAgents); |
| |
| createBasicMovementStateAgents.setBasicMovementModel(this); |
| |
| } |
| |
| return context; |
| } |
| /** |
| * . |
| */ |
| |
| @org.junit.Test |
| @repast.simphony.engine.schedule.ScheduledMethod(start = 1, interval = 1, priority = -4) |
| public void testFake() { |
| |
| /*PROTECTED REGION ID(BasicMovementModel_testFake_Pre) ENABLED START*/ |
| //Pre-Conditions Here |
| /*PROTECTED REGION END*/ |
| |
| assertTrue(true); |
| |
| /*PROTECTED REGION ID(BasicMovementModel_testFake_Post) ENABLED START*/ |
| //Post-Conditions Here |
| /*PROTECTED REGION END*/ |
| |
| } |
| |
| /** |
| * Gets the Area Count property for Basic Movement Model. |
| * @return The number of areas to create. |
| */ |
| |
| @repast.simphony.parameter.Parameter(displayName = "Area Count", usageName = "areaCount", defaultValue = "0") |
| public int getAreaCount() { |
| return areaCount; |
| } |
| |
| /** |
| * Sets the Area Count property for Basic Movement Model. |
| * The number of areas to create. |
| * @param _areaCount the new Area Count value |
| */ |
| |
| public void setAreaCount(int _areaCount) { |
| areaCount = _areaCount; |
| } |
| |
| /** |
| * Gets the Network Agent Count property for Basic Movement Model. |
| * @return The number of network agents to create. |
| */ |
| |
| @repast.simphony.parameter.Parameter(displayName = "Network Agent Count", usageName = "networkAgentCount", defaultValue = "0") |
| public int getNetworkAgentCount() { |
| return networkAgentCount; |
| } |
| |
| /** |
| * Sets the Network Agent Count property for Basic Movement Model. |
| * The number of network agents to create. |
| * @param _networkAgentCount the new Network Agent Count value |
| */ |
| |
| public void setNetworkAgentCount(int _networkAgentCount) { |
| networkAgentCount = _networkAgentCount; |
| } |
| |
| /** |
| * Gets the Basic Movement Agent Count property for Basic Movement Model. |
| * @return The number of generate act people to create. |
| */ |
| |
| @repast.simphony.parameter.Parameter(displayName = "Basic Movement Agent Count", usageName = "basicMovementAgentCount", defaultValue = "0") |
| public int getBasicMovementAgentCount() { |
| return basicMovementAgentCount; |
| } |
| |
| /** |
| * Sets the Basic Movement Agent Count property for Basic Movement Model. |
| * The number of generate act people to create. |
| * @param _basicMovementAgentCount the new Basic Movement Agent Count value |
| */ |
| |
| public void setBasicMovementAgentCount(int _basicMovementAgentCount) { |
| basicMovementAgentCount = _basicMovementAgentCount; |
| } |
| |
| /** |
| * Gets the Complex Space Agent Count property for Basic Movement Model. |
| * @return The number of complex space agents to create. |
| */ |
| |
| @repast.simphony.parameter.Parameter(displayName = "Complex Space Agent Count", usageName = "complexSpaceAgentCount", defaultValue = "0") |
| public int getComplexSpaceAgentCount() { |
| return complexSpaceAgentCount; |
| } |
| |
| /** |
| * Sets the Complex Space Agent Count property for Basic Movement Model. |
| * The number of complex space agents to create. |
| * @param _complexSpaceAgentCount the new Complex Space Agent Count value |
| */ |
| |
| public void setComplexSpaceAgentCount(int _complexSpaceAgentCount) { |
| complexSpaceAgentCount = _complexSpaceAgentCount; |
| } |
| |
| /** |
| * Gets the Act Non Movement Person Count property for Basic Movement Model. |
| * @return The number of act non movement persons to create. |
| */ |
| |
| @repast.simphony.parameter.Parameter(displayName = "Act Non Movement Person Count", usageName = "actNonMovementPersonCount", defaultValue = "0") |
| public int getActNonMovementPersonCount() { |
| return actNonMovementPersonCount; |
| } |
| |
| /** |
| * Sets the Act Non Movement Person Count property for Basic Movement Model. |
| * The number of act non movement persons to create. |
| * @param _actNonMovementPersonCount the new Act Non Movement Person Count value |
| */ |
| |
| public void setActNonMovementPersonCount(int _actNonMovementPersonCount) { |
| actNonMovementPersonCount = _actNonMovementPersonCount; |
| } |
| |
| /** |
| * Gets the Basic Movement State Agent Count property for Basic Movement Model. |
| * @return The number of basic movement state agents to create. |
| */ |
| |
| @repast.simphony.parameter.Parameter(displayName = "Basic Movement State Agent Count", usageName = "basicMovementStateAgentCount", defaultValue = "0") |
| public int getBasicMovementStateAgentCount() { |
| return basicMovementStateAgentCount; |
| } |
| |
| /** |
| * Sets the Basic Movement State Agent Count property for Basic Movement Model. |
| * The number of basic movement state agents to create. |
| * @param _basicMovementStateAgentCount the new Basic Movement State Agent Count value |
| */ |
| |
| public void setBasicMovementStateAgentCount( |
| int _basicMovementStateAgentCount) { |
| basicMovementStateAgentCount = _basicMovementStateAgentCount; |
| } |
| |
| /** |
| * Gets the Dimensions property for Grid. |
| * @return The size of each dimension. |
| */ |
| |
| public int[] getGridDimensions() { |
| return gridDimensions; |
| } |
| |
| /** |
| * Sets the Dimensions property for Grid. |
| * The size of each dimension. |
| * @param _gridDimensions the new Dimensions value |
| */ |
| |
| public void setGridDimensions(int[] _gridDimensions) { |
| gridDimensions = _gridDimensions; |
| } |
| |
| /** |
| * Gets the Width property for Grid. |
| * @return The horizontal extent of the space. |
| */ |
| |
| @repast.simphony.parameter.Parameter(displayName = "Grid Width", usageName = "gridWidth", defaultValue = "100") |
| public int getGridWidth() { |
| return gridDimensions[0]; |
| } |
| |
| /** |
| * Sets the Width property for Grid. |
| * The horizontal extent of the space. |
| * @param _gridWidth the new Width value |
| */ |
| |
| public void setGridWidth(int _gridWidth) { |
| gridDimensions[0] = _gridWidth; |
| } |
| |
| /** |
| * Gets the Height property for Grid. |
| * @return The vertical extent of the space. |
| */ |
| |
| @repast.simphony.parameter.Parameter(displayName = "Grid Height", usageName = "gridHeight", defaultValue = "50") |
| public int getGridHeight() { |
| return gridDimensions[1]; |
| } |
| |
| /** |
| * Sets the Height property for Grid. |
| * The vertical extent of the space. |
| * @param _gridHeight the new Height value |
| */ |
| |
| public void setGridHeight(int _gridHeight) { |
| gridDimensions[1] = _gridHeight; |
| } |
| |
| /** |
| * Gets the Grid property for Basic Movement Model. |
| * @return |
| */ |
| |
| public repast.simphony.space.grid.Grid getGrid() { |
| return grid; |
| } |
| |
| /** |
| * Sets the Grid property for Basic Movement Model. |
| * |
| * @param _grid the new Grid value |
| */ |
| |
| public void setGrid(repast.simphony.space.grid.Grid _grid) { |
| grid = _grid; |
| } |
| |
| /** |
| * Gets the Test Network property for Basic Movement Model. |
| * @return |
| */ |
| |
| public repast.simphony.space.graph.Network getTestNetwork() { |
| return testNetwork; |
| } |
| |
| /** |
| * Sets the Test Network property for Basic Movement Model. |
| * |
| * @param _testNetwork the new Test Network value |
| */ |
| |
| public void setTestNetwork(repast.simphony.space.graph.Network _testNetwork) { |
| testNetwork = _testNetwork; |
| } |
| |
| } |