Quartz::State
A base class that wraps the state of a model. Automatically extended by
models through use of the state macro.
See Stateful#state.
Constructors
Instance methods
Macros
The parameter macro defines a state parameter for the State of a model.
It is intended to be used within a block provided with the Stateful#state
macro.
Unlike state variables, parameters are read-only variables that can be set with the initial state of a model. As an example, they can be used to define the constants of an equation.
See also #var to declare state variables.
See also Stateful#state.
Usage
parameter must receive a type declaration which will be used to declare an instance
variable and a getter.
Default values must be declared using the type declaration notation or through a block (lazy initialization) :
state do
parameter c = 0.013
end
The var macro defines a state variable for the State of a model. Its
primary goal is to generate convenient getters and setters for the model
among other purposes.
It is intended to be used within a block provided with the Stateful#state
macro.
Unlike state parameters, state variables are updated during the simulation by its model behaviour.
See also #parameter
See also Stateful#state.
Usage
var must receive a type declaration which will be used to declare an instance
variable, a getter and a setter.
Default values must be declared using the type declaration notation or through a block (lazy initialization) :
state do
var foo : Int32 = 42
var bar : Int32 { (rand * 100 + 1).to_i32 }
var quz : Int32 { foo * 42 }
end
Note from previous example that the initialization block of quz is
allowed to reference the value of another state variable.