variables¶
Syntax¶
variables {
# One or more variable declarations.
<scope> <variable_type> <variable_name>
# One or more optional variable initializations
<variable_name> = <some_value>
}
Parameters¶
<scope>-
The scope of the variable being declared. Valid values for scope are
sharedandagent.Important
For
agent-scoped variables,tableandlist_tablevariable types are currently disabled, as they would be extremely memory-intensive with fairly ordinary numbers of agents.
<variable_type>-
The type of the variable being declared. Valid variable types are:
Important
For
agent-scoped variables,tableandlist_tablevariable types are currently disabled, as they would be extremely memory-intensive with fairly ordinary numbers of agents.
<variable_name>- A name to give the newly declared variable. If multiple are present, they must be separated by a space. Variable names must start with a letter and contain no symbols.
<some_value>- An expression that is equal to a value that has the same type as the variable to which it is being assigned.
Description¶
This block defines the names and initial values of variables.
Programs may contain more than one variables block. They are interpreted as a single block when the model file is processed.
Initialization of Agent Variables¶
When agent-scoped variables are initialized in a variables block, each agent will be evaluated individually. For example, the following initialization will assign each agent a distinct temperature drawn from a normal distribution with a mean of 98.6 and a standard deviation of 1.0.
Examples¶
This example defines a shared variable fever_temperature and an agent
variable my_temperature.
variables {
shared numeric fever_temperature
fever_temperature = 101.5
agent my_temperature
my_temperature = 98.6
}