|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectuchicago.src.sim.parameter.ParameterReader
public class ParameterReader
Reads a model's parameters from a parameter file for a batch run. A typical user should have no need to use this class directly.
A parameter file has the following format:
runs: x
Parameter (input|output) {
value_definition
}
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. The value_definition is composed
of one or more keywords and corresponding values. Parameters can be either input or
output. Parameters are input by default and need not be explicitly specified. Output parameters
have to be declared using the keyword output enclosed in parenthesis. For output parameters
value_definition should be omitted.The multi-keyword value definitions:
Single keyword value_definitions:
Some examples,
runs: 10
Food {
start: 10
end: 30
incr: 10
}
This means start with a food 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). This example assumes that the model has getFood()
and setFood() methods.More than one parameter can be specified, so for example,
runs: 10
Food {
start: 10
end: 30
incr: 10
}
MaxAge {
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 a
parameter's current value is greater than its end value, the simulation will
exit.Parameters can also be nested. For example,
runs: 1
Food {
start: 10
end: 30
incr: 10
{
runs: 10
MaxAge {
start: 0
end: 40
incr: 1
}
}
}
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, and so on 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 {
set: 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 {
set_list: 1.2 3 10 12 84
}
}
}
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 and the beginning of the MaxAge list, and so on
until the Food parameter is greater than 30.The boolean and string keywords work in the 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: '//' and so on.
| Field Summary | |
|---|---|
static java.lang.String |
XSLT_TRANSLATION_FILE_NAME
the file used to translate xml parameter files to normal parameter files |
| Constructor Summary | |
|---|---|
ParameterReader()
|
|
ParameterReader(java.lang.String fileName)
Constructs a ParameterReader with specified parameter file. |
|
| Method Summary | |
|---|---|
java.util.Vector |
getParameters()
Gets the parameters read by this Parameter reader |
static void |
main(java.lang.String[] args)
|
java.util.Vector |
read(java.lang.String fileName)
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final java.lang.String XSLT_TRANSLATION_FILE_NAME
| Constructor Detail |
|---|
public ParameterReader()
public ParameterReader(java.lang.String fileName)
throws java.io.IOException
fileName - the name of the parameter file
java.io.IOException| Method Detail |
|---|
public java.util.Vector read(java.lang.String fileName)
throws java.io.IOException
java.io.IOExceptionpublic java.util.Vector getParameters()
public static void main(java.lang.String[] args)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||