public class BasicTestsUtils extends Object
ModelData modelData
- RunInfo runInfo
- SimplePotentialAgent forestry
- SimplePotentialAgent farmering
- Set potentialAgents
Models:
- CompetitivenessModel competition
- allocation
- StaticPerCellDemandModel demandR1
- StaticPerCellDemandModel demandR2
2 region with models above, potential agents and 10 cells c per region:
- Region r1
- Region r2
- Set regions
- RegionSet w
2 Agents:
- AbstractAgent a1
- AbstractAgent a2
- ABMPersister persister
- sets for each regions cells rcells
Static members:
- SimpleProductionModel forestryProduction
- SimpleProductionModel farmingProduction
- SimplePotentialAgent forestry
- SimplePotentialAgent farming
- Set potentialAgents
Considered Capitals are:
HUMAN(0), INFRASTRUCTURE(1), ECONOMIC(2), NATURAL_GRASSLAND(3),
NATURAL_FOREST(4), NATURAL_CROPS(5), NATURE_VALUE(6)
Considered Services:
HOUSING(0), TIMBER(1), FOOD(2), RECREATION(3),
Further data as provided (all static):| Modifier and Type | Field and Description |
|---|---|
AbstractAgent |
a1 |
AbstractAgent |
a2 |
AllocationModel |
allocation |
Cell |
c11
A whole bunch of cells to play with
|
Cell |
c12
A whole bunch of cells to play with
|
Cell |
c13
A whole bunch of cells to play with
|
Cell |
c14
A whole bunch of cells to play with
|
Cell |
c15
A whole bunch of cells to play with
|
Cell |
c16
A whole bunch of cells to play with
|
Cell |
c17
A whole bunch of cells to play with
|
Cell |
c18
A whole bunch of cells to play with
|
Cell |
c19
A whole bunch of cells to play with
|
Cell |
c21 |
Cell |
c22 |
Cell |
c23 |
Cell |
c24 |
Cell |
c25 |
Cell |
c26 |
Cell |
c27 |
Cell |
c28 |
Cell |
c29 |
static com.moseph.modelutils.fastdata.DoubleMap<Capital> |
cellCapitalsA
Arbitrary
DoubleMap A of cell capitals |
static com.moseph.modelutils.fastdata.DoubleMap<Capital> |
cellCapitalsB
Arbitrary
DoubleMap B of cell capitals |
CompetitivenessModel |
competition
Default competition and allocation functions
|
StaticPerCellDemandModel |
demandR1 |
StaticPerCellDemandModel |
demandR2 |
static double[][] |
extensiveFarmingCapitalWeights |
static com.moseph.modelutils.fastdata.DoubleMap<Service> |
extensiveFarmingOnCA
Expected service provision from extensive farmers on a cell with cellCapitals A.
|
static com.moseph.modelutils.fastdata.DoubleMap<Service> |
extensiveFarmingOnCB
Expected service provision from extensive farmers on a cell with cellCapitals B.
|
static double[] |
extensiveFarmingProductionWeights |
static SimplePotentialAgent |
farming |
static double |
farmingGivingIn |
static double |
farmingGivingUp |
static SimpleProductionModel |
farmingProduction |
static SimplePotentialAgent |
forestry |
static double[][] |
forestryCapitalWeights |
static double |
forestryGivingIn |
static double |
forestryGivingUp |
static com.moseph.modelutils.fastdata.DoubleMap<Service> |
forestryOnCA
Expected service provision from foresters on a cell with cellCapitals A.
|
static com.moseph.modelutils.fastdata.DoubleMap<Service> |
forestryOnCB
Expected service provision from foresters on a cell with cellCapitals B.
|
static SimpleProductionModel |
forestryProduction |
static double[] |
forestryProductionWeights |
static ModelData |
modelData |
ABMPersister |
persister |
static Set<PotentialAgent> |
potentialAgents |
Region |
r1 |
Set<Cell> |
r1cells |
Region |
r2 |
Set<Cell> |
r2cells |
protected static int |
randomNumberCounter |
Set<Region> |
regions |
static RunInfo |
runInfo |
RegionSet |
w |
| Constructor and Description |
|---|
BasicTestsUtils()
Initialises region set
w |
| Modifier and Type | Method and Description |
|---|---|
static void |
assertAgent(String id,
double competitiveness,
Cell... cells)
Asserts that the given cells are occupied by an agent with the given ID and given
competitiveness.
|
static <T extends com.moseph.modelutils.fastdata.Indexed> |
assertEqualMaps(String msg,
com.moseph.modelutils.fastdata.UnmodifiableNumberMap<T> exp,
com.moseph.modelutils.fastdata.UnmodifiableNumberMap<T> got)
Checks that two NumberMaps are the same
|
static <T extends com.moseph.modelutils.fastdata.Indexed> |
assertEqualMaps(com.moseph.modelutils.fastdata.UnmodifiableNumberMap<T> exp,
com.moseph.modelutils.fastdata.UnmodifiableNumberMap<T> got)
Compare maps of data
|
static void |
assertUnmanaged(Cell... cells)
Checks that the given cells are indeed unmanaged.
|
static com.moseph.modelutils.fastdata.DoubleMap<Capital> |
capitals(double... vals)
Creates a map using the
SimpleCapitals and the given values. |
static <T extends com.moseph.modelutils.fastdata.Named & com.moseph.modelutils.fastdata.Indexed> |
checkDataType(com.moseph.modelutils.fastdata.NamedIndexSet<T> caps,
String name,
int index)
Checks whether the capital with the given name has the given index in the given capitals
named index set.
|
static void |
checkOwnership(Cell[] cells,
PotentialAgent... owners)
Checks whether the
ith cell is occupied by an agent of the ith
potential agent. |
static void |
checkOwnership(Cell[] cells,
String... owners)
Checks whether the
ith cell is occupied by an agent with the ith
ID. |
static <T> void |
checkSet(Collection<T> got,
T... ex)
Checks that an expected set is the same as the actual set Note: arguments are the opposite
way round to normal, to allow user of varargs
|
static <T> void |
checkSet(String msg,
Collection<T> got,
T... ex)
Checks that an expected set is the same as the actual set Note: arguments are the opposite
way round to normal, to allow user of varargs
|
com.google.common.collect.Multiset<PotentialAgent> |
countAgents(Region r)
Returns a Multiset which provides the opportunity to receive counts agents of each
PotentialAgent in the given region. |
static <T extends com.moseph.modelutils.fastdata.Indexed> |
dm(com.moseph.modelutils.fastdata.IndexSet<T> ind,
double... vals)
Creates a new double map with the given index set and values.
|
static PotentialAgent |
getSingleProductionAgent(String id,
double givingUp,
double givingIn,
double amount,
Service service,
Capital... dependencies)
Return a
PotentialAgent with the given ID and given giving in/put thresholds that
produces only the given Service leveraging capitals according to given dependencies. |
void |
initTestEnvironment()
Inits cells, regions, agents, cell sets, regions set, regionset.
|
static void |
print(Object... vals)
Log given objects in a line
|
static com.moseph.modelutils.fastdata.DoubleMap<Service> |
services(double... vals)
Create a map using the
SimpleServices and the given values |
static void |
setCapitals(Cell[] cells,
double[]... capitals)
Set the
ith given capitals for tje ith cell. |
Region |
setupBasicWorld(boolean initialiseRegion,
Cell... cells)
Sets up a very basic world containing one region with the given cells.
|
Region |
setupBasicWorld(Cell... cells)
Set up a basic world with the given cells.
|
void |
setupPersister()
Setup persister by default to look in test-data.
|
protected void |
setupPseudoRandomEngine() |
Region |
setupWorld(AllocationModel allocation,
CompetitivenessModel competition,
DemandModel demand,
Set<PotentialAgent> potentialAgents,
Cell... cells)
Creates a very basic world applying the given models.
|
protected static int randomNumberCounter
public static ModelData modelData
public static RunInfo runInfo
public Cell c11
public Cell c12
public Cell c13
public Cell c14
public Cell c15
public Cell c16
public Cell c17
public Cell c18
public Cell c19
public Cell c21
public Cell c22
public Cell c23
public Cell c24
public Cell c25
public Cell c26
public Cell c27
public Cell c28
public Cell c29
public static double[] extensiveFarmingProductionWeights
public static double[][] extensiveFarmingCapitalWeights
public static double[] forestryProductionWeights
public static double[][] forestryCapitalWeights
public static com.moseph.modelutils.fastdata.DoubleMap<Capital> cellCapitalsA
DoubleMap A of cell capitalspublic static com.moseph.modelutils.fastdata.DoubleMap<Capital> cellCapitalsB
DoubleMap B of cell capitalspublic static com.moseph.modelutils.fastdata.DoubleMap<Service> extensiveFarmingOnCA
SimpleProductionModel).public static com.moseph.modelutils.fastdata.DoubleMap<Service> extensiveFarmingOnCB
SimpleProductionModel).public static com.moseph.modelutils.fastdata.DoubleMap<Service> forestryOnCA
SimpleProductionModel).public static com.moseph.modelutils.fastdata.DoubleMap<Service> forestryOnCB
SimpleProductionModel).public CompetitivenessModel competition
public AllocationModel allocation
public StaticPerCellDemandModel demandR1
public StaticPerCellDemandModel demandR2
public static SimpleProductionModel forestryProduction
public static SimpleProductionModel farmingProduction
public static final double forestryGivingUp
public static final double forestryGivingIn
public static final double farmingGivingUp
public static final double farmingGivingIn
public static SimplePotentialAgent forestry
public static SimplePotentialAgent farming
public static Set<PotentialAgent> potentialAgents
public Region r1
public Region r2
public RegionSet w
public AbstractAgent a1
public AbstractAgent a2
public ABMPersister persister
public void setupPersister()
public void initTestEnvironment()
public static <T> void checkSet(String msg, Collection<T> got, T... ex)
msg - describe the origin and kind of compared datagot - actual data to compareex - expected data to compare withpublic static <T> void checkSet(Collection<T> got, T... ex)
got - actual data to compareex - expected data to compare withpublic static <T extends com.moseph.modelutils.fastdata.Indexed> com.moseph.modelutils.fastdata.DoubleMap<T> dm(com.moseph.modelutils.fastdata.IndexSet<T> ind,
double... vals)
ind - index setvals - valuespublic static com.moseph.modelutils.fastdata.DoubleMap<Service> services(double... vals)
SimpleServices and the given valuesvals - public static com.moseph.modelutils.fastdata.DoubleMap<Capital> capitals(double... vals)
SimpleCapitals and the given values.vals - public static <T extends com.moseph.modelutils.fastdata.Indexed> void assertEqualMaps(com.moseph.modelutils.fastdata.UnmodifiableNumberMap<T> exp,
com.moseph.modelutils.fastdata.UnmodifiableNumberMap<T> got)
exp - expected datagot - acutal datapublic static <T extends com.moseph.modelutils.fastdata.Indexed> void assertEqualMaps(String msg, com.moseph.modelutils.fastdata.UnmodifiableNumberMap<T> exp, com.moseph.modelutils.fastdata.UnmodifiableNumberMap<T> got)
msg - exp - got - public static void assertUnmanaged(Cell... cells)
cells - public static void assertAgent(String id, double competitiveness, Cell... cells)
id - agent ID to checkcompetitiveness - competitiveness to checkcells - cells to checkpublic static <T extends com.moseph.modelutils.fastdata.Named & com.moseph.modelutils.fastdata.Indexed> void checkDataType(com.moseph.modelutils.fastdata.NamedIndexSet<T> caps,
String name,
int index)
caps - name - index - public static void checkOwnership(Cell[] cells, String... owners)
ith cell is occupied by an agent with the ith
ID.cells - owners - public static void checkOwnership(Cell[] cells, PotentialAgent... owners)
ith cell is occupied by an agent of the ith
potential agent.cells - owners - public static void setCapitals(Cell[] cells, double[]... capitals)
ith given capitals for tje ith cell.cells - capitals - public static void print(Object... vals)
vals - public Region setupBasicWorld(Cell... cells) throws Exception
cells - Exceptionpublic static PotentialAgent getSingleProductionAgent(String id, double givingUp, double givingIn, double amount, Service service, Capital... dependencies)
PotentialAgent with the given ID and given giving in/put thresholds that
produces only the given Service leveraging capitals according to given dependencies.id - givingUp - givingIn - amount - service - dependencies - public com.google.common.collect.Multiset<PotentialAgent> countAgents(Region r)
PotentialAgent in the given region.r - public Region setupBasicWorld(boolean initialiseRegion, Cell... cells) throws Exception
SimpleAllocationModel, SimpleCompetitivenessModel, and
RegionalDemandModel are applied. Schedule is initialised.initialiseRegion - cells - Exceptionpublic Region setupWorld(AllocationModel allocation, CompetitivenessModel competition, DemandModel demand, Set<PotentialAgent> potentialAgents, Cell... cells) throws Exception
allocation - competition - demand - potentialAgents - cells - Exceptionprotected void setupPseudoRandomEngine()