| package org.metaabm.gen.test; |
| |
| /** |
| * Complex Movement Agent Java Implementation. |
| * |
| * Generated by metaabm system: May 13, 2009 11:53:50 AM PDT in project: org.metaabm.gen.repast.test (testing) */ |
| |
| import static org.junit.Assert.*; |
| |
| public class ComplexMovementAgent { |
| |
| /** |
| * |
| */ |
| |
| private boolean someBoolean = false; |
| /** |
| * |
| */ |
| |
| private double[] withinSpace = {1, 1, 3, 3}; |
| /** |
| * |
| */ |
| |
| private int result = 0; |
| /** |
| * |
| */ |
| |
| private SpatialStateEnum spatialState = SpatialStateEnum.option1; |
| /** |
| * |
| */ |
| |
| private int vision = 4; |
| /** |
| * Constructs a new Complex Movement Agent. |
| */ |
| |
| public ComplexMovementAgent() { |
| createUniqueID(); |
| } |
| |
| //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 { |
| ComplexMovementAgent clone = (ComplexMovementAgent) super.clone(); |
| clone.createUniqueID(); |
| return clone; |
| } catch (Exception e) { |
| throw new RuntimeException("Unexpected cloning exception: " + e); |
| } |
| } |
| |
| @org.junit.Test |
| public void dummy() { |
| assertTrue(true); |
| } |
| |
| /** |
| * |
| */ |
| |
| private SpatialModel spatialModelList = null; |
| |
| /** |
| * Gets the Spatial Model property for . |
| * @return |
| */ |
| |
| public SpatialModel getSpatialModel() { |
| return spatialModelList; |
| } |
| |
| /** |
| * Sets the Spatial Model property for . |
| * |
| * @param _spatialModel the new Spatial Model value |
| */ |
| |
| public void setSpatialModel(SpatialModel _spatialModel) { |
| spatialModelList = _spatialModel; |
| } |
| |
| public double randomInRange(double minValue, double maxValue) { |
| return repast.simphony.random.RandomHelper.nextDoubleFromTo(minValue, |
| maxValue); |
| } |
| |
| public double randomToLimit(double maxValue) { |
| return repast.simphony.random.RandomHelper.nextDoubleFromTo(0.0, |
| maxValue); |
| } |
| |
| public int randomToLimit(int maxValue) { |
| return repast.simphony.random.RandomHelper.nextIntFromTo(0, maxValue); |
| } |
| /** |
| * . |
| */ |
| |
| @org.junit.Test |
| @repast.simphony.engine.schedule.ScheduledMethod(start = 1, interval = 1, priority = -0) |
| public void testDieAll() { |
| |
| final repast.simphony.context.Context context = repast.simphony.util.ContextUtils |
| .getContext(this); |
| |
| final repast.simphony.space.grid.Grid grid2D = (repast.simphony.space.grid.Grid) context |
| .getProjection("Grid 2D"); |
| |
| /*PROTECTED REGION ID(ComplexMovementAgent_testDieAll_Pre) ENABLED START*/ |
| //Pre-Conditions Here |
| /*PROTECTED REGION END*/ |
| |
| { |
| |
| repast.simphony.query.Query<Object> dieRandomAgentQuery = null; |
| |
| repast.simphony.query.Query<Object> dieRandomAgentQueryAvailable = new repast.simphony.query.Query<Object>() { |
| public java.lang.Iterable<Object> query() { |
| |
| return new repast.simphony.util.collections.FilteredIterator<Object>( |
| context.iterator(), |
| new org.apache.commons.collections15.Predicate() { |
| public boolean evaluate(Object object) { |
| |
| return object instanceof ComplexMovementAgent; |
| |
| } |
| }); |
| |
| } |
| public java.lang.Iterable<Object> query( |
| java.lang.Iterable<Object> other) { |
| return new repast.simphony.util.collections.FilteredIterator<Object>( |
| query().iterator(), |
| repast.simphony.query.QueryUtils |
| .createContains(other)); |
| } |
| }; |
| |
| dieRandomAgentQuery = dieRandomAgentQueryAvailable; |
| |
| java.util.Iterator dieRandomAgentIter = dieRandomAgentQuery.query() |
| .iterator(); |
| if (dieRandomAgentIter.hasNext()) { |
| java.util.List dieRandomAgentList = org.apache.commons.collections15.IteratorUtils |
| .toList(dieRandomAgentIter); |
| final ComplexMovementAgent dieRandomAgent = (ComplexMovementAgent) dieRandomAgentList |
| .get(repast.simphony.random.RandomHelper.nextIntFromTo( |
| 0, dieRandomAgentList.size() - 1)); |
| |
| context.remove(dieRandomAgent); |
| |
| } |
| } |
| |
| /*PROTECTED REGION ID(ComplexMovementAgent_testDieAll_Post) ENABLED START*/ |
| //Post-Conditions Here |
| /*PROTECTED REGION END*/ |
| |
| } |
| |
| /** |
| * . |
| */ |
| |
| @org.junit.Test |
| @repast.simphony.engine.schedule.ScheduledMethod(start = 1, interval = 1, priority = -3) |
| public void testNegateSpatialThenIdentity() { |
| |
| final repast.simphony.context.Context context = repast.simphony.util.ContextUtils |
| .getContext(this); |
| |
| final repast.simphony.space.grid.Grid grid2D = (repast.simphony.space.grid.Grid) context |
| .getProjection("Grid 2D"); |
| |
| /*PROTECTED REGION ID(ComplexMovementAgent_testNegateSpatialThenIdentity_Pre) ENABLED START*/ |
| //Pre-Conditions Here |
| /*PROTECTED REGION END*/ |
| |
| { |
| |
| repast.simphony.query.Query<Object> neighborBeforeIdentityQuery = null; |
| |
| neighborBeforeIdentityQuery = new repast.simphony.query.space.grid.GridWithin( |
| grid2D, this, 1); |
| |
| repast.simphony.query.Query<Object> neighborBeforeIdentityQueryAgentClass = new repast.simphony.query.Query<Object>() { |
| public java.lang.Iterable<Object> query() { |
| |
| return new repast.simphony.util.collections.FilteredIterator<Object>( |
| context.iterator(), |
| new org.apache.commons.collections15.Predicate() { |
| public boolean evaluate(Object object) { |
| |
| return (object instanceof ComplexLocation); |
| |
| } |
| }); |
| |
| } |
| public java.lang.Iterable<Object> query( |
| java.lang.Iterable<Object> other) { |
| return new repast.simphony.util.collections.FilteredIterator<Object>( |
| query().iterator(), |
| repast.simphony.query.QueryUtils |
| .createContains(other)); |
| } |
| }; |
| |
| neighborBeforeIdentityQuery = new repast.simphony.query.AndQuery<Object>( |
| neighborBeforeIdentityQuery, |
| neighborBeforeIdentityQueryAgentClass); |
| |
| java.util.Iterator neighborBeforeIdentityIter = neighborBeforeIdentityQuery |
| .query().iterator(); |
| if (neighborBeforeIdentityIter.hasNext()) { |
| java.util.List neighborBeforeIdentityList = org.apache.commons.collections15.IteratorUtils |
| .toList(neighborBeforeIdentityIter); |
| final ComplexLocation locationGoodMove = (ComplexLocation) neighborBeforeIdentityList |
| .get(repast.simphony.random.RandomHelper.nextIntFromTo( |
| 0, neighborBeforeIdentityList.size() - 1)); |
| |
| if (locationGoodMove.isLocationGood()) { |
| |
| int[] moveLocationNoNegateLoc = grid2D.getLocation( |
| locationGoodMove).toIntArray(null); |
| grid2D.moveTo(this, moveLocationNoNegateLoc); |
| |
| } |
| |
| if (!(locationGoodMove.isLocationGood())) { |
| setSomeBoolean(true); |
| |
| } |
| |
| } |
| } |
| |
| /*PROTECTED REGION ID(ComplexMovementAgent_testNegateSpatialThenIdentity_Post) ENABLED START*/ |
| //Post-Conditions Here |
| /*PROTECTED REGION END*/ |
| |
| } |
| |
| /** |
| * . |
| */ |
| |
| @org.junit.Test |
| @repast.simphony.engine.schedule.ScheduledMethod(start = 1, interval = 1, priority = -10) |
| public void testNegateSpatialWithIdentity() { |
| |
| final repast.simphony.context.Context context = repast.simphony.util.ContextUtils |
| .getContext(this); |
| |
| final repast.simphony.space.grid.Grid grid2D = (repast.simphony.space.grid.Grid) context |
| .getProjection("Grid 2D"); |
| |
| /*PROTECTED REGION ID(ComplexMovementAgent_testNegateSpatialWithIdentity_Pre) ENABLED START*/ |
| //Pre-Conditions Here |
| /*PROTECTED REGION END*/ |
| |
| { |
| |
| repast.simphony.query.Query<Object> notNeighborQuery = null; |
| |
| notNeighborQuery = new repast.simphony.query.space.grid.GridWithin( |
| grid2D, this, 1); |
| |
| repast.simphony.query.Query<Object> notNeighborQueryAgentClass = new repast.simphony.query.Query<Object>() { |
| public java.lang.Iterable<Object> query() { |
| |
| return new repast.simphony.util.collections.FilteredIterator<Object>( |
| context.iterator(), |
| new org.apache.commons.collections15.Predicate() { |
| public boolean evaluate(Object object) { |
| |
| return (object instanceof ComplexMovementAgent); |
| |
| } |
| }); |
| |
| } |
| public java.lang.Iterable<Object> query( |
| java.lang.Iterable<Object> other) { |
| return new repast.simphony.util.collections.FilteredIterator<Object>( |
| query().iterator(), |
| repast.simphony.query.QueryUtils |
| .createContains(other)); |
| } |
| }; |
| |
| notNeighborQuery = new repast.simphony.query.AndQuery<Object>( |
| notNeighborQuery, notNeighborQueryAgentClass); |
| |
| if (!notNeighborQuery.query().iterator().hasNext()) { |
| |
| setSomeBoolean(true); |
| |
| } |
| } |
| |
| /*PROTECTED REGION ID(ComplexMovementAgent_testNegateSpatialWithIdentity_Post) ENABLED START*/ |
| //Post-Conditions Here |
| /*PROTECTED REGION END*/ |
| |
| } |
| |
| /** |
| * . |
| */ |
| |
| @org.junit.Test |
| @repast.simphony.engine.schedule.ScheduledMethod(start = 1, interval = 1, priority = -15) |
| public void testHostHere() { |
| |
| final repast.simphony.context.Context context = repast.simphony.util.ContextUtils |
| .getContext(this); |
| |
| final repast.simphony.space.grid.Grid grid2D = (repast.simphony.space.grid.Grid) context |
| .getProjection("Grid 2D"); |
| |
| /*PROTECTED REGION ID(ComplexMovementAgent_testHostHere_Pre) ENABLED START*/ |
| //Pre-Conditions Here |
| /*PROTECTED REGION END*/ |
| |
| { |
| |
| repast.simphony.query.Query<Object> locationHereQueryQuery = null; |
| |
| repast.simphony.query.Query<Object> locationHereQueryQueryAgentClass = new repast.simphony.query.Query<Object>() { |
| public java.lang.Iterable<Object> query() { |
| |
| return new repast.simphony.util.collections.FilteredIterator<Object>( |
| context.iterator(), |
| new org.apache.commons.collections15.Predicate() { |
| public boolean evaluate(Object object) { |
| |
| return (object instanceof ComplexLocation); |
| |
| } |
| }); |
| |
| } |
| public java.lang.Iterable<Object> query( |
| java.lang.Iterable<Object> other) { |
| return new repast.simphony.util.collections.FilteredIterator<Object>( |
| query().iterator(), |
| repast.simphony.query.QueryUtils |
| .createContains(other)); |
| } |
| }; |
| |
| locationHereQueryQuery = new repast.simphony.query.AndQuery<Object>( |
| locationHereQueryQuery, locationHereQueryQueryAgentClass); |
| |
| java.util.Iterator locationHereQueryIter = locationHereQueryQuery |
| .query().iterator(); |
| if (locationHereQueryIter.hasNext()) { |
| java.util.List locationHereQueryList = org.apache.commons.collections15.IteratorUtils |
| .toList(locationHereQueryIter); |
| final ComplexLocation location = (ComplexLocation) locationHereQueryList |
| .get(repast.simphony.random.RandomHelper.nextIntFromTo( |
| 0, locationHereQueryList.size() - 1)); |
| |
| location.setLocationGood(true); |
| |
| } |
| } |
| |
| /*PROTECTED REGION ID(ComplexMovementAgent_testHostHere_Post) ENABLED START*/ |
| //Post-Conditions Here |
| /*PROTECTED REGION END*/ |
| |
| } |
| |
| /** |
| * . |
| */ |
| |
| @org.junit.Test |
| @repast.simphony.engine.schedule.ScheduledMethod(start = 1, interval = 1, priority = -19) |
| public void testConnectRandomOther() { |
| |
| final repast.simphony.context.Context context = repast.simphony.util.ContextUtils |
| .getContext(this); |
| |
| final repast.simphony.space.grid.Grid grid2D = (repast.simphony.space.grid.Grid) context |
| .getProjection("Grid 2D"); |
| |
| /*PROTECTED REGION ID(ComplexMovementAgent_testConnectRandomOther_Pre) ENABLED START*/ |
| //Pre-Conditions Here |
| /*PROTECTED REGION END*/ |
| |
| { |
| |
| repast.simphony.query.Query<Object> complexMovementAgentQuery = null; |
| |
| repast.simphony.query.Query<Object> complexMovementAgentQueryAvailable = new repast.simphony.query.Query<Object>() { |
| public java.lang.Iterable<Object> query() { |
| |
| return new repast.simphony.util.collections.FilteredIterator<Object>( |
| context.iterator(), |
| new org.apache.commons.collections15.Predicate() { |
| public boolean evaluate(Object object) { |
| |
| return object instanceof ComplexMovementAgent; |
| |
| } |
| }); |
| |
| } |
| public java.lang.Iterable<Object> query( |
| java.lang.Iterable<Object> other) { |
| return new repast.simphony.util.collections.FilteredIterator<Object>( |
| query().iterator(), |
| repast.simphony.query.QueryUtils |
| .createContains(other)); |
| } |
| }; |
| |
| complexMovementAgentQuery = complexMovementAgentQueryAvailable; |
| |
| java.util.Iterator complexMovementAgentIter = complexMovementAgentQuery |
| .query().iterator(); |
| if (complexMovementAgentIter.hasNext()) { |
| java.util.List complexMovementAgentList = org.apache.commons.collections15.IteratorUtils |
| .toList(complexMovementAgentIter); |
| final ComplexMovementAgent complexMovementAgent = (ComplexMovementAgent) complexMovementAgentList |
| .get(repast.simphony.random.RandomHelper.nextIntFromTo( |
| 0, complexMovementAgentList.size() - 1)); |
| |
| } |
| } |
| |
| /*PROTECTED REGION ID(ComplexMovementAgent_testConnectRandomOther_Post) ENABLED START*/ |
| //Post-Conditions Here |
| /*PROTECTED REGION END*/ |
| |
| } |
| |
| /** |
| * . |
| */ |
| |
| @org.junit.Test |
| @repast.simphony.engine.schedule.ScheduledMethod(start = 1, interval = 1, priority = -22) |
| public void testSetRandomOther() { |
| |
| final repast.simphony.context.Context context = repast.simphony.util.ContextUtils |
| .getContext(this); |
| |
| final repast.simphony.space.grid.Grid grid2D = (repast.simphony.space.grid.Grid) context |
| .getProjection("Grid 2D"); |
| |
| /*PROTECTED REGION ID(ComplexMovementAgent_testSetRandomOther_Pre) ENABLED START*/ |
| //Pre-Conditions Here |
| /*PROTECTED REGION END*/ |
| |
| { |
| |
| repast.simphony.query.Query<Object> complexMovementAgentCopyQuery = null; |
| |
| repast.simphony.query.Query<Object> complexMovementAgentCopyQueryAvailable = new repast.simphony.query.Query<Object>() { |
| public java.lang.Iterable<Object> query() { |
| |
| return new repast.simphony.util.collections.FilteredIterator<Object>( |
| context.iterator(), |
| new org.apache.commons.collections15.Predicate() { |
| public boolean evaluate(Object object) { |
| |
| return object instanceof ComplexMovementAgent; |
| |
| } |
| }); |
| |
| } |
| public java.lang.Iterable<Object> query( |
| java.lang.Iterable<Object> other) { |
| return new repast.simphony.util.collections.FilteredIterator<Object>( |
| query().iterator(), |
| repast.simphony.query.QueryUtils |
| .createContains(other)); |
| } |
| }; |
| |
| complexMovementAgentCopyQuery = complexMovementAgentCopyQueryAvailable; |
| |
| java.util.Iterator complexMovementAgentCopyIter = complexMovementAgentCopyQuery |
| .query().iterator(); |
| if (complexMovementAgentCopyIter.hasNext()) { |
| java.util.List complexMovementAgentCopyList = org.apache.commons.collections15.IteratorUtils |
| .toList(complexMovementAgentCopyIter); |
| final ComplexMovementAgent complexMovementAgentCopy = (ComplexMovementAgent) complexMovementAgentCopyList |
| .get(repast.simphony.random.RandomHelper.nextIntFromTo( |
| 0, complexMovementAgentCopyList.size() - 1)); |
| |
| complexMovementAgentCopy.setSomeBoolean(true); |
| |
| } |
| } |
| |
| /*PROTECTED REGION ID(ComplexMovementAgent_testSetRandomOther_Post) ENABLED START*/ |
| //Post-Conditions Here |
| /*PROTECTED REGION END*/ |
| |
| } |
| |
| /** |
| * . |
| */ |
| |
| @org.junit.Test |
| @repast.simphony.engine.schedule.ScheduledMethod(start = 1, interval = 1, priority = -25) |
| public void testSetRandomOtherIf() { |
| |
| final repast.simphony.context.Context context = repast.simphony.util.ContextUtils |
| .getContext(this); |
| |
| final repast.simphony.space.grid.Grid grid2D = (repast.simphony.space.grid.Grid) context |
| .getProjection("Grid 2D"); |
| |
| /*PROTECTED REGION ID(ComplexMovementAgent_testSetRandomOtherIf_Pre) ENABLED START*/ |
| //Pre-Conditions Here |
| /*PROTECTED REGION END*/ |
| |
| { |
| |
| repast.simphony.query.Query<Object> complexMovementAgentCopyCopyQueryCondition = new repast.simphony.query.Query<Object>() { |
| public java.lang.Iterable<Object> query() { |
| |
| return new repast.simphony.util.collections.FilteredIterator<Object>( |
| context.iterator(), |
| new org.apache.commons.collections15.Predicate() { |
| public boolean evaluate(Object object) { |
| |
| if (object instanceof ComplexMovementAgent) { |
| ComplexMovementAgent complexMovementAgentCopyCopy = (ComplexMovementAgent) object; |
| return (complexMovementAgentCopyCopy |
| .isSomeBoolean()); |
| } else { |
| return false; |
| } |
| |
| } |
| }); |
| |
| } |
| public java.lang.Iterable<Object> query( |
| java.lang.Iterable<Object> other) { |
| return new repast.simphony.util.collections.FilteredIterator<Object>( |
| query().iterator(), |
| repast.simphony.query.QueryUtils |
| .createContains(other)); |
| } |
| }; |
| |
| repast.simphony.query.Query<Object> complexMovementAgentCopyCopyQuery = null; |
| |
| repast.simphony.query.Query<Object> complexMovementAgentCopyCopyQueryAvailable = new repast.simphony.query.Query<Object>() { |
| public java.lang.Iterable<Object> query() { |
| |
| return new repast.simphony.util.collections.FilteredIterator<Object>( |
| context.iterator(), |
| new org.apache.commons.collections15.Predicate() { |
| public boolean evaluate(Object object) { |
| |
| return object instanceof ComplexMovementAgent; |
| |
| } |
| }); |
| |
| } |
| public java.lang.Iterable<Object> query( |
| java.lang.Iterable<Object> other) { |
| return new repast.simphony.util.collections.FilteredIterator<Object>( |
| query().iterator(), |
| repast.simphony.query.QueryUtils |
| .createContains(other)); |
| } |
| }; |
| |
| complexMovementAgentCopyCopyQuery = complexMovementAgentCopyCopyQueryAvailable; |
| |
| java.util.Iterator complexMovementAgentCopyCopyIter = complexMovementAgentCopyCopyQuery |
| .query().iterator(); |
| if (complexMovementAgentCopyCopyIter.hasNext()) { |
| java.util.List complexMovementAgentCopyCopyList = org.apache.commons.collections15.IteratorUtils |
| .toList(complexMovementAgentCopyCopyIter); |
| final ComplexMovementAgent complexMovementAgentCopyCopy = (ComplexMovementAgent) complexMovementAgentCopyCopyList |
| .get(repast.simphony.random.RandomHelper.nextIntFromTo( |
| 0, complexMovementAgentCopyCopyList.size() - 1)); |
| |
| if (complexMovementAgentCopyCopy.isSomeBoolean()) { |
| complexMovementAgentCopyCopy.setSomeBoolean(false); |
| |
| } |
| |
| } |
| } |
| |
| /*PROTECTED REGION ID(ComplexMovementAgent_testSetRandomOtherIf_Post) ENABLED START*/ |
| //Post-Conditions Here |
| /*PROTECTED REGION END*/ |
| |
| } |
| |
| /** |
| * . |
| */ |
| |
| @org.junit.Test |
| @repast.simphony.engine.schedule.ScheduledMethod(start = 1, interval = 1, priority = -29) |
| public void testSetRandomPostQuery() { |
| |
| final repast.simphony.context.Context context = repast.simphony.util.ContextUtils |
| .getContext(this); |
| |
| final repast.simphony.space.grid.Grid grid2D = (repast.simphony.space.grid.Grid) context |
| .getProjection("Grid 2D"); |
| |
| /*PROTECTED REGION ID(ComplexMovementAgent_testSetRandomPostQuery_Pre) ENABLED START*/ |
| //Pre-Conditions Here |
| /*PROTECTED REGION END*/ |
| |
| boolean testSetRandomPostQueryRandomBoolean = repast.simphony.random.RandomHelper |
| .getUniform().nextBoolean(); |
| |
| if (isSomeBoolean()) { |
| { |
| |
| repast.simphony.query.Query<Object> complexMovementAgentCopyCopyCopyQuery = null; |
| |
| repast.simphony.query.Query<Object> complexMovementAgentCopyCopyCopyQueryAvailable = new repast.simphony.query.Query<Object>() { |
| public java.lang.Iterable<Object> query() { |
| |
| return new repast.simphony.util.collections.FilteredIterator<Object>( |
| context.iterator(), |
| new org.apache.commons.collections15.Predicate() { |
| public boolean evaluate(Object object) { |
| |
| return object instanceof ComplexMovementAgent; |
| |
| } |
| }); |
| |
| } |
| public java.lang.Iterable<Object> query( |
| java.lang.Iterable<Object> other) { |
| return new repast.simphony.util.collections.FilteredIterator<Object>( |
| query().iterator(), |
| repast.simphony.query.QueryUtils |
| .createContains(other)); |
| } |
| }; |
| |
| complexMovementAgentCopyCopyCopyQuery = complexMovementAgentCopyCopyCopyQueryAvailable; |
| |
| java.util.Iterator complexMovementAgentCopyCopyCopyIter = complexMovementAgentCopyCopyCopyQuery |
| .query().iterator(); |
| if (complexMovementAgentCopyCopyCopyIter.hasNext()) { |
| java.util.List complexMovementAgentCopyCopyCopyList = org.apache.commons.collections15.IteratorUtils |
| .toList(complexMovementAgentCopyCopyCopyIter); |
| final ComplexMovementAgent complexMovementAgentCopyCopyCopy = (ComplexMovementAgent) complexMovementAgentCopyCopyCopyList |
| .get(repast.simphony.random.RandomHelper |
| .nextIntFromTo(0, |
| complexMovementAgentCopyCopyCopyList |
| .size() - 1)); |
| |
| complexMovementAgentCopyCopyCopy.setSomeBoolean(true); |
| |
| } |
| } |
| } |
| |
| /*PROTECTED REGION ID(ComplexMovementAgent_testSetRandomPostQuery_Post) ENABLED START*/ |
| //Post-Conditions Here |
| /*PROTECTED REGION END*/ |
| |
| } |
| |
| /** |
| * . |
| */ |
| |
| @org.junit.Test |
| @repast.simphony.engine.schedule.ScheduledMethod(start = 1, interval = 1, priority = -34) |
| public void testParallelSpatial() { |
| |
| final repast.simphony.context.Context context = repast.simphony.util.ContextUtils |
| .getContext(this); |
| |
| final repast.simphony.space.grid.Grid grid2D = (repast.simphony.space.grid.Grid) context |
| .getProjection("Grid 2D"); |
| |
| /*PROTECTED REGION ID(ComplexMovementAgent_testParallelSpatial_Pre) ENABLED START*/ |
| //Pre-Conditions Here |
| /*PROTECTED REGION END*/ |
| |
| { |
| |
| repast.simphony.query.Query<Object> parallelSelect2NeighborQueryQuery = null; |
| |
| parallelSelect2NeighborQueryQuery = new repast.simphony.query.space.grid.GridWithin( |
| grid2D, this, 1); |
| |
| repast.simphony.query.Query<Object> parallelSelect2NeighborQueryQueryAgentClass = new repast.simphony.query.Query<Object>() { |
| public java.lang.Iterable<Object> query() { |
| |
| return new repast.simphony.util.collections.FilteredIterator<Object>( |
| context.iterator(), |
| new org.apache.commons.collections15.Predicate() { |
| public boolean evaluate(Object object) { |
| |
| return (object instanceof ComplexLocation); |
| |
| } |
| }); |
| |
| } |
| public java.lang.Iterable<Object> query( |
| java.lang.Iterable<Object> other) { |
| return new repast.simphony.util.collections.FilteredIterator<Object>( |
| query().iterator(), |
| repast.simphony.query.QueryUtils |
| .createContains(other)); |
| } |
| }; |
| |
| parallelSelect2NeighborQueryQuery = new repast.simphony.query.AndQuery<Object>( |
| parallelSelect2NeighborQueryQuery, |
| parallelSelect2NeighborQueryQueryAgentClass); |
| |
| java.util.Iterator parallelSelect2NeighborQueryIter = parallelSelect2NeighborQueryQuery |
| .query().iterator(); |
| if (parallelSelect2NeighborQueryIter.hasNext()) { |
| java.util.List parallelSelect2NeighborQueryList = org.apache.commons.collections15.IteratorUtils |
| .toList(parallelSelect2NeighborQueryIter); |
| final ComplexLocation parallelSelect2 = (ComplexLocation) parallelSelect2NeighborQueryList |
| .get(repast.simphony.random.RandomHelper.nextIntFromTo( |
| 0, parallelSelect2NeighborQueryList.size() - 1)); |
| |
| int[] movetoComplexLocationinGrid2DLoc = grid2D.getLocation( |
| parallelSelect2).toIntArray(null); |
| grid2D.moveTo(this, movetoComplexLocationinGrid2DLoc); |
| |
| } |
| } |
| |
| { |
| |
| repast.simphony.query.Query<Object> parallelSelect1NeighborQueryQuery = null; |
| |
| parallelSelect1NeighborQueryQuery = new repast.simphony.query.space.grid.GridWithin( |
| grid2D, this, 1); |
| |
| repast.simphony.query.Query<Object> parallelSelect1NeighborQueryQueryAgentClass = new repast.simphony.query.Query<Object>() { |
| public java.lang.Iterable<Object> query() { |
| |
| return new repast.simphony.util.collections.FilteredIterator<Object>( |
| context.iterator(), |
| new org.apache.commons.collections15.Predicate() { |
| public boolean evaluate(Object object) { |
| |
| return (object instanceof ComplexLocation); |
| |
| } |
| }); |
| |
| } |
| public java.lang.Iterable<Object> query( |
| java.lang.Iterable<Object> other) { |
| return new repast.simphony.util.collections.FilteredIterator<Object>( |
| query().iterator(), |
| repast.simphony.query.QueryUtils |
| .createContains(other)); |
| } |
| }; |
| |
| parallelSelect1NeighborQueryQuery = new repast.simphony.query.AndQuery<Object>( |
| parallelSelect1NeighborQueryQuery, |
| parallelSelect1NeighborQueryQueryAgentClass); |
| |
| java.util.Iterator parallelSelect1NeighborQueryIter = parallelSelect1NeighborQueryQuery |
| .query().iterator(); |
| if (parallelSelect1NeighborQueryIter.hasNext()) { |
| java.util.List parallelSelect1NeighborQueryList = org.apache.commons.collections15.IteratorUtils |
| .toList(parallelSelect1NeighborQueryIter); |
| final ComplexLocation parallelSelect1 = (ComplexLocation) parallelSelect1NeighborQueryList |
| .get(repast.simphony.random.RandomHelper.nextIntFromTo( |
| 0, parallelSelect1NeighborQueryList.size() - 1)); |
| |
| int[] movetoComplexMovementAgentinGrid2DLoc = grid2D |
| .getLocation(parallelSelect1).toIntArray(null); |
| grid2D.moveTo(this, movetoComplexMovementAgentinGrid2DLoc); |
| |
| } |
| } |
| |
| /*PROTECTED REGION ID(ComplexMovementAgent_testParallelSpatial_Post) ENABLED START*/ |
| //Post-Conditions Here |
| /*PROTECTED REGION END*/ |
| |
| } |
| |
| /** |
| * . |
| */ |
| |
| @org.junit.Test |
| @repast.simphony.engine.schedule.ScheduledMethod(start = 1, interval = 1, priority = -41) |
| public void testParallelRoot() { |
| |
| final repast.simphony.context.Context context = repast.simphony.util.ContextUtils |
| .getContext(this); |
| |
| final repast.simphony.space.grid.Grid grid2D = (repast.simphony.space.grid.Grid) context |
| .getProjection("Grid 2D"); |
| |
| /*PROTECTED REGION ID(ComplexMovementAgent_testParallelRoot_Pre) ENABLED START*/ |
| //Pre-Conditions Here |
| /*PROTECTED REGION END*/ |
| |
| { |
| |
| { |
| |
| { |
| |
| int testParallelRootResultAddUnit = getResult() + 1; |
| |
| setResult(testParallelRootResultAddUnit); |
| |
| int testParallelRootResultAddUnitCopyCopy = getResult() + 1; |
| |
| setResult(getResult() + 1); |
| |
| int testParallelRootResultAddUnitCopy = getResult() + 1; |
| |
| setResult(getResult() + 1); |
| |
| } |
| } |
| } |
| |
| /*PROTECTED REGION ID(ComplexMovementAgent_testParallelRoot_Post) ENABLED START*/ |
| //Post-Conditions Here |
| /*PROTECTED REGION END*/ |
| |
| } |
| |
| /** |
| * . |
| */ |
| |
| @org.junit.Test |
| @repast.simphony.engine.schedule.ScheduledMethod(start = 1, interval = 1, priority = -51) |
| public void testParallelWithNetwork() { |
| |
| final repast.simphony.context.Context context = repast.simphony.util.ContextUtils |
| .getContext(this); |
| |
| final repast.simphony.space.graph.Network complexNet = (repast.simphony.space.graph.Network) context |
| .getProjection("Complex Net"); |
| |
| final repast.simphony.space.grid.Grid grid2D = (repast.simphony.space.grid.Grid) context |
| .getProjection("Grid 2D"); |
| |
| /*PROTECTED REGION ID(ComplexMovementAgent_testParallelWithNetwork_Pre) ENABLED START*/ |
| //Pre-Conditions Here |
| /*PROTECTED REGION END*/ |
| |
| { |
| |
| repast.simphony.query.Query<Object> parallelNetwork1NeighborQueryQuery = null; |
| |
| parallelNetwork1NeighborQueryQuery = new repast.simphony.query.space.graph.NetPathWithin( |
| complexNet, this, 1); |
| |
| repast.simphony.query.Query<Object> parallelNetwork1NeighborQueryQueryAgentClass = new repast.simphony.query.Query<Object>() { |
| public java.lang.Iterable<Object> query() { |
| |
| return new repast.simphony.util.collections.FilteredIterator<Object>( |
| context.iterator(), |
| new org.apache.commons.collections15.Predicate() { |
| public boolean evaluate(Object object) { |
| |
| return (object instanceof ComplexMovementAgent); |
| |
| } |
| }); |
| |
| } |
| public java.lang.Iterable<Object> query( |
| java.lang.Iterable<Object> other) { |
| return new repast.simphony.util.collections.FilteredIterator<Object>( |
| query().iterator(), |
| repast.simphony.query.QueryUtils |
| .createContains(other)); |
| } |
| }; |
| |
| parallelNetwork1NeighborQueryQuery = new repast.simphony.query.AndQuery<Object>( |
| parallelNetwork1NeighborQueryQuery, |
| parallelNetwork1NeighborQueryQueryAgentClass); |
| |
| java.util.Iterator parallelNetwork1NeighborQueryIter = parallelNetwork1NeighborQueryQuery |
| .query().iterator(); |
| if (parallelNetwork1NeighborQueryIter.hasNext()) { |
| java.util.List parallelNetwork1NeighborQueryList = org.apache.commons.collections15.IteratorUtils |
| .toList(parallelNetwork1NeighborQueryIter); |
| final ComplexMovementAgent parallelNetwork1 = (ComplexMovementAgent) parallelNetwork1NeighborQueryList |
| .get(repast.simphony.random.RandomHelper |
| .nextIntFromTo(0, |
| parallelNetwork1NeighborQueryList |
| .size() - 1)); |
| |
| } |
| } |
| |
| { |
| |
| repast.simphony.query.Query<Object> parallelMovementAvailableQueryQuery = null; |
| |
| repast.simphony.query.Query<Object> parallelMovementAvailableQueryQueryAvailable = new repast.simphony.query.Query<Object>() { |
| public java.lang.Iterable<Object> query() { |
| |
| return new repast.simphony.util.collections.FilteredIterator<Object>( |
| context.iterator(), |
| new org.apache.commons.collections15.Predicate() { |
| public boolean evaluate(Object object) { |
| |
| repast.simphony.space.grid.GridPoint location = grid2D |
| .getLocation(object); |
| if (location != null) { |
| java.util.Iterator locIter = grid2D |
| .getObjectsAt( |
| location |
| .toIntArray(null)) |
| .iterator(); |
| if (locIter.hasNext()) { |
| locIter.next(); |
| if (!locIter.hasNext()) { |
| return true; |
| } |
| } |
| } |
| return false; |
| |
| } |
| }); |
| |
| } |
| public java.lang.Iterable<Object> query( |
| java.lang.Iterable<Object> other) { |
| return new repast.simphony.util.collections.FilteredIterator<Object>( |
| query().iterator(), |
| repast.simphony.query.QueryUtils |
| .createContains(other)); |
| } |
| }; |
| |
| parallelMovementAvailableQueryQuery = parallelMovementAvailableQueryQueryAvailable; |
| |
| java.util.Iterator parallelMovementAvailableQueryIter = parallelMovementAvailableQueryQuery |
| .query().iterator(); |
| if (parallelMovementAvailableQueryIter.hasNext()) { |
| java.util.List parallelMovementAvailableQueryList = org.apache.commons.collections15.IteratorUtils |
| .toList(parallelMovementAvailableQueryIter); |
| final ComplexLocation parallelMovement = (ComplexLocation) parallelMovementAvailableQueryList |
| .get(repast.simphony.random.RandomHelper.nextIntFromTo( |
| 0, |
| parallelMovementAvailableQueryList.size() - 1)); |
| |
| int[] movetoComplexMovementAgentLoc = grid2D.getLocation( |
| parallelMovement).toIntArray(null); |
| grid2D.moveTo(this, movetoComplexMovementAgentLoc); |
| |
| } |
| } |
| |
| /*PROTECTED REGION ID(ComplexMovementAgent_testParallelWithNetwork_Post) ENABLED START*/ |
| //Post-Conditions Here |
| /*PROTECTED REGION END*/ |
| |
| } |
| |
| /** |
| * . |
| */ |
| |
| @org.junit.Test |
| @repast.simphony.engine.schedule.ScheduledMethod(start = 1, interval = 1, priority = -58) |
| public void testNestedStatements() { |
| |
| final repast.simphony.context.Context context = repast.simphony.util.ContextUtils |
| .getContext(this); |
| |
| final repast.simphony.space.grid.Grid grid2D = (repast.simphony.space.grid.Grid) context |
| .getProjection("Grid 2D"); |
| |
| /*PROTECTED REGION ID(ComplexMovementAgent_testNestedStatements_Pre) ENABLED START*/ |
| //Pre-Conditions Here |
| /*PROTECTED REGION END*/ |
| |
| { |
| |
| { |
| |
| if (getSpatialState() == SpatialStateEnum.option1 |
| && isSomeBoolean() == false) { |
| { |
| |
| repast.simphony.query.Query<Object> goodWithinVisionQueryCondition = new repast.simphony.query.Query<Object>() { |
| public java.lang.Iterable<Object> query() { |
| |
| return new repast.simphony.util.collections.FilteredIterator<Object>( |
| context.iterator(), |
| new org.apache.commons.collections15.Predicate() { |
| public boolean evaluate( |
| Object object) { |
| |
| if (object instanceof ComplexLocation) { |
| ComplexLocation targetLocation = (ComplexLocation) object; |
| return (targetLocation |
| .isLocationGood()); |
| } else { |
| return false; |
| } |
| |
| } |
| }); |
| |
| } |
| public java.lang.Iterable<Object> query( |
| java.lang.Iterable<Object> other) { |
| return new repast.simphony.util.collections.FilteredIterator<Object>( |
| query().iterator(), |
| repast.simphony.query.QueryUtils |
| .createContains(other)); |
| } |
| }; |
| |
| repast.simphony.query.Query<Object> goodWithinVisionQuery = null; |
| |
| goodWithinVisionQuery = new repast.simphony.query.space.grid.GridWithin( |
| grid2D, this, getVision()); |
| |
| goodWithinVisionQuery = new repast.simphony.query.AndQuery<Object>( |
| goodWithinVisionQuery, |
| goodWithinVisionQueryCondition); |
| |
| java.util.Iterator goodWithinVisionIter = goodWithinVisionQuery |
| .query().iterator(); |
| if (goodWithinVisionIter.hasNext()) { |
| java.util.List goodWithinVisionList = org.apache.commons.collections15.IteratorUtils |
| .toList(goodWithinVisionIter); |
| final ComplexLocation targetLocation = (ComplexLocation) goodWithinVisionList |
| .get(repast.simphony.random.RandomHelper |
| .nextIntFromTo( |
| 0, |
| goodWithinVisionList.size() - 1)); |
| |
| setSomeBoolean(true); |
| |
| } |
| } |
| |
| } |
| |
| } |
| |
| } |
| |
| /*PROTECTED REGION ID(ComplexMovementAgent_testNestedStatements_Post) ENABLED START*/ |
| //Post-Conditions Here |
| /*PROTECTED REGION END*/ |
| |
| } |
| |
| /** |
| * . |
| */ |
| |
| @org.junit.Test |
| @repast.simphony.engine.schedule.ScheduledMethod(start = 1, interval = 1, priority = -66) |
| public void testHostHereCondition() { |
| |
| final repast.simphony.context.Context context = repast.simphony.util.ContextUtils |
| .getContext(this); |
| |
| final repast.simphony.space.grid.Grid grid2D = (repast.simphony.space.grid.Grid) context |
| .getProjection("Grid 2D"); |
| |
| /*PROTECTED REGION ID(ComplexMovementAgent_testHostHereCondition_Pre) ENABLED START*/ |
| //Pre-Conditions Here |
| /*PROTECTED REGION END*/ |
| |
| { |
| |
| repast.simphony.query.Query<Object> complexMovementAgentCopyCopyCopyCopy_HereQueryAnd_Unspecified_QueryCopy_QueryCondition = new repast.simphony.query.Query<Object>() { |
| public java.lang.Iterable<Object> query() { |
| |
| return new repast.simphony.util.collections.FilteredIterator<Object>( |
| context.iterator(), |
| new org.apache.commons.collections15.Predicate() { |
| public boolean evaluate(Object object) { |
| |
| if (object instanceof ComplexLocation) { |
| ComplexLocation complexMovementAgentCopyCopyCopyCopy = (ComplexLocation) object; |
| return (complexMovementAgentCopyCopyCopyCopy |
| .isLocationGood()); |
| } else { |
| return false; |
| } |
| |
| } |
| }); |
| |
| } |
| public java.lang.Iterable<Object> query( |
| java.lang.Iterable<Object> other) { |
| return new repast.simphony.util.collections.FilteredIterator<Object>( |
| query().iterator(), |
| repast.simphony.query.QueryUtils |
| .createContains(other)); |
| } |
| }; |
| |
| repast.simphony.query.Query<Object> complexMovementAgentCopyCopyCopyCopy_HereQueryAnd_Unspecified_QueryCopy_Query = null; |
| |
| complexMovementAgentCopyCopyCopyCopy_HereQueryAnd_Unspecified_QueryCopy_Query = new repast.simphony.query.AndQuery<Object>( |
| complexMovementAgentCopyCopyCopyCopy_HereQueryAnd_Unspecified_QueryCopy_Query, |
| complexMovementAgentCopyCopyCopyCopy_HereQueryAnd_Unspecified_QueryCopy_QueryCondition); |
| |
| java.util.Iterator complexMovementAgentCopyCopyCopyCopy_HereQueryAnd_Unspecified_QueryCopy_Iter = complexMovementAgentCopyCopyCopyCopy_HereQueryAnd_Unspecified_QueryCopy_Query |
| .query().iterator(); |
| if (complexMovementAgentCopyCopyCopyCopy_HereQueryAnd_Unspecified_QueryCopy_Iter |
| .hasNext()) { |
| java.util.List complexMovementAgentCopyCopyCopyCopy_HereQueryAnd_Unspecified_QueryCopy_List = org.apache.commons.collections15.IteratorUtils |
| .toList(complexMovementAgentCopyCopyCopyCopy_HereQueryAnd_Unspecified_QueryCopy_Iter); |
| final ComplexLocation complexMovementAgentCopyCopyCopyCopy = (ComplexLocation) complexMovementAgentCopyCopyCopyCopy_HereQueryAnd_Unspecified_QueryCopy_List |
| .get(repast.simphony.random.RandomHelper.nextIntFromTo( |
| 0, |
| complexMovementAgentCopyCopyCopyCopy_HereQueryAnd_Unspecified_QueryCopy_List |
| .size() - 1)); |
| |
| setSomeBoolean(true); |
| |
| } |
| } |
| |
| /*PROTECTED REGION ID(ComplexMovementAgent_testHostHereCondition_Post) ENABLED START*/ |
| //Post-Conditions Here |
| /*PROTECTED REGION END*/ |
| |
| } |
| |
| /** |
| * Gets the Some Boolean property for Complex Movement Agent. |
| * @return |
| */ |
| |
| @repast.simphony.parameter.Parameter(displayName = "Some Boolean", usageName = "someBoolean", defaultValue = "false") |
| public boolean isSomeBoolean() { |
| return someBoolean; |
| } |
| |
| /** |
| * Sets the Some Boolean property for Complex Movement Agent. |
| * |
| * @param _someBoolean the new Some Boolean value |
| */ |
| |
| public void setSomeBoolean(boolean _someBoolean) { |
| someBoolean = _someBoolean; |
| } |
| |
| /** |
| * Gets the Within Space property for Complex Movement Agent. |
| * @return |
| */ |
| |
| public double[] getWithinSpace() { |
| return withinSpace; |
| } |
| |
| /** |
| * Sets the Within Space property for Complex Movement Agent. |
| * |
| * @param _withinSpace the new Within Space value |
| */ |
| |
| public void setWithinSpace(double[] _withinSpace) { |
| withinSpace = _withinSpace; |
| } |
| |
| /** |
| * Gets the Result property for Complex Movement Agent. |
| * @return |
| */ |
| |
| @repast.simphony.parameter.Parameter(displayName = "Result", usageName = "result", defaultValue = "0") |
| public int getResult() { |
| return result; |
| } |
| |
| /** |
| * Sets the Result property for Complex Movement Agent. |
| * |
| * @param _result the new Result value |
| */ |
| |
| public void setResult(int _result) { |
| result = _result; |
| } |
| |
| /** |
| * Gets the Spatial State property for Complex Movement Agent. |
| * @return |
| */ |
| |
| @repast.simphony.parameter.Parameter(displayName = "Spatial State", usageName = "spatialState", defaultValue = "option1") |
| public SpatialStateEnum getSpatialState() { |
| return spatialState; |
| } |
| |
| /** |
| * Sets the Spatial State property for Complex Movement Agent. |
| * |
| * @param _spatialState the new Spatial State value |
| */ |
| |
| public void setSpatialState(SpatialStateEnum _spatialState) { |
| spatialState = _spatialState; |
| } |
| |
| /** |
| * Gets the Vision property for Complex Movement Agent. |
| * @return |
| */ |
| |
| @repast.simphony.parameter.Parameter(displayName = "Vision", usageName = "vision", defaultValue = "4") |
| public int getVision() { |
| return vision; |
| } |
| |
| /** |
| * Sets the Vision property for Complex Movement Agent. |
| * |
| * @param _vision the new Vision value |
| */ |
| |
| public void setVision(int _vision) { |
| vision = _vision; |
| } |
| |
| } |