Simulation Parameters
The IKR Simulation Library can read simulation parameters from a file, the
so-called parameter file. How to write a parameter file and how to read
parameters inside the simulation program will be explained in the following.
Parameter File Structure
The parameter file will be read on a
per-line basis. Each line must have the following structure:
"key" = "value"
There are two principle for defining keys:
- The key may be any name, which the simulation program can query for.
Organizing the name space must be done by the programmer.
- The key or the first part of the key is the fully qualified name of the
SimNode that shall read the corresponding parameter(s). Names may contain
wildcards to make the key match different queries.
The value will be interpreted as follows:
- Whitespaces will be interpreted as separators of vectors. Scalar values
containing a whitespace character must be put in quotes.
- Vectors must begin with a [ character and end with a ] character. Inside a
vector, the values must be separated with whitespaces.
- A Vector can again contain vectors.
You can use the # character to write comments. All characters of a line
following the # character will be ignored. Empty lines will be ignored.
Example parameter file:
# Calls = 10000
TandemModel.*.NrOrGenerator = 42 # the answer
TandemModel.Node*.Generator = StdGenerator
TandemModel.Node*.Generator*.IATDist = NegExp
TandemModel.Node*.Generator*.IATDist.Mean = 50
Reading Parameter Values
Class Parameters
In every SimLib simulation program, there is one object of class
Parameters
. This object represents the content
of the parameter file. The object provides a set of methods to query the
parameters listed in this file. The methods, that can be used for querying,
are the following ones:
hasParameter()
returns true if the parameter exists.
hasSubTree()
returns true if the subtree exists.
get()
returns the value of the parameter.
getOrUseDefault(, )
returns the value of
the parameter if it is listed in the parameter file. If not, the default
value will be used. Note that the default value will be passed as a string
and will only be parsed if it is needed.
There are different variants for providing the query to the methods listed
above:
- (String name): The name must specify the fully qualified name of the
queried parameter.
- (Prefix prefix, String name): The name will be extended by the prefix.
- (SimNode simNode, String name): The name will be extended by the name of
the simNode.
Class Value
The class
Value
is
the abstract base class of the classes
Scalar
and
Array
. These objects provide methods to
return a parameter value in one of the following forms:
boolean
enum
String
, String[]
, or String[][]
double
, double[]
, or double[][]
int
, int[]
, or int[][]
long
, long[]
, or long[][]
Parser Classes
With the help of the
createInstance()
method it is possible to create objects from classed defined in the parameter
file.