public String[] getInitParam() {
String[] params = {"evapRate", "diffusionConstant", "maxIdealTemp",
"minIdealTemp", "maxOutputHeat", "minOutputHeat", "worldXSize",
"worldYSize", "numBugs"};
return params;
}
These ("evapRate", etc.) are the parameters for this model.
public void setEvapRate(double rate) {
eRate = rate;
}
public double getEvapRate() {
return eRate;
}
and so on for the rest of the parameters. All access to the parameters
is through these methods and any actual variables that represent the
parameters (such as eRate in the above example) remain hidden. Many of the Repast data collection mechanisms rely on these parameters remaining constant throughout the life time of a run once the model begins to run. This does not preclude in any way changing the parameters via the user interface or parameter files, but only that these parameters are not expected to change once the model is actually running. Once the parameters are defined in this way, they can be changed through the user interface or through parameter files.
Parameter Files
The multi-keyword value definitions:
Single keyword value_definitions:
Some examples,
More than one parameter can be specified, so for example,
Parameters can also be nested. For example,
Setting constants:
List parameters:
The boolean and string keywords work in an identical manner, but set boolean
and string values instead of numeric ones.
Parameter files can contain comments delimited by the standard c/c++/java
comment markers: '//', '/*...*/'
For more information on loading a parameter file into your model, see
How Run a Simulation,
The Main Method, and How To Use Multi-Run.
Parameter files can be used with both gui and batch models. For
gui models, the parameter file sets some or all initial parameter values,
as if the user had entered those values by hand.
For a batch model, a parameter file defines a parameter space and
describes how the model should explore that space.
A parameter file has the following format:
where x is some number and Parameter is the name of some model parameter
accessible through get and set methods. Runs specifies the number of runs
to execute for the current parameter value. "runs:" is ignored for
non-batch models. The value_definition is composed
of one or more keywords and corresponding values.
runs: x
Parameter {
value_definition
}
The start, end, and incr keywords together provide a value defintion and
must always occur together. For a batch simulation they define
a parameter space which will be automatically iterated through. start:
defines the initial parameter. end: the parameter up to and including
ending parameter, and incr: the amount to increment the start: value and
any succeeding values to reach the end: parameters. For a gui simulation
the start: value is taken as the default parameter and the remaining
keywords are ignored.
For non-batch models the list keywords are equivalent to the "set:"
keywords where the value is the first member of the list.
This means start with a food parameter with a value of 10 and
run the simulation 10 times
using this value. Increment the food value by 10 and run the simulation 10
times with a food value of 20 (start 10 + incr 10). Increment the food value
by another 10, and run another 10 times with the food value of 30 (start 10 +
incr 10 + incr 10). Incrementing the current value at this point
would result in a value greater than the ending value and so the
simulation ends.
runs: 10
Food {
start: 10
end: 30
incr: 10
}
Where both food and max age are incremented as described above. If using more
than one parameter it is important to synchronize them, as whenever any
parameter's current value is greater than its end value, the simulation will
exit.
runs: 10
Food {
start: 10
end: 30
incr: 10
}
MaxAge {
start: 10
end: 30
incr: 10
}
This example means starting with a food value of 10 run the simulation 10
times with a MaxAge of 0. Increment MaxAge by 1 and run the simulation 10
times, continue until the value of MaxAge is greater than 40. At this point,
increment Food by 10 and run the simulation 10 times with a MaxAge of 0.
Increment MaxAge by 1 and run the simulation 10 times. This continues until
the value of Food is greater than 30. Multiple levels of nesting are possible.
runs: 1
Food {
start: 10
end: 30
incr: 10
{
runs: 10
MaxAge {
start: 0
end: 40
incr: 1
}
}
}
RngSeed is parameter of every model and can be manipulated like any other
parameter. And here it is set to one and this value will remain constant
over all the individual batch runs.
runs: 1
Food {
start: 10
end: 30
incr: 10
{
runs: 10
MaxAge {
start: 0
end: 40
incr: 1
}
}
}
RngSeed {
set: 1
}
This is the same as above except that maxAge will be incremented via the list.
So first run with maxAge as 1.2, do this for 10 runs. Then set maxAge to 3 and
run with this value for 10 times. Continue until the end of the list, then
increment Food and start at the beginning of the MaxAge list, and so on
until the Food parameter is greater than 30.
runs: 1
Food {
start: 10
end: 30
incr: 10
{
runs: 10
MaxAge {
set_list: 1.2 3 10 12 84
}
}
}
RngSeed {
set: 1
}