SimulationFunction
simulation.SimulationFunction()
A function which runs in the context of a RUME to produce a value (as a numpy array). The value must be independent of the simulation state, and they will often be evaluated before the simulation starts.
SimulationFunction is an abstract class. In typical usage you will not implement a SimulationFunction directly, but rather one of its more-specific child classes.
SimulationFunction is generic in the type of result it produces (ResultT
).
See Also
Notable child classes of SimulationFunction include Initializers
, ADRIOs
, and ParamFunctions
.
Attributes
requirements: Sequence[AttributeDef] | property
-
The attribute definitions describing the data requirements for this function.
For advanced use-cases, you may specify requirements as a property if you need it to be dynamically computed.
randomized: bool
-
Should this function be re-evaluated every time it’s referenced in a RUME? (Mostly useful for randomized results.) If False, even a function that utilizes the context RNG will only be computed once, resulting in a single random value that is shared by all references during evaluation.
class_name: str
-
The class name of the SimulationFunction.
name: AbsoluteName
-
The name under which this attribute is being evaluated.
scope:
GeoScope
-
The simulation GeoScope.
time_frame: TimeFrame
-
The simulation TimeFrame.
ipm: BaseCompartmentModel
-
The simulation IPM.
rng: np.random.Generator
-
The simulation’s random number generator.
dim:
Dimensions
-
The simulation’s dimensional information. This is a re-packaging of information contained in other context elements, like the geo scope.
Methods
Name | Description |
---|---|
validate |
Override this method to validate the function evaluation result. Implementations should raise an appropriate error if results are not valid. |
with_context |
Constructs a clone of this instance which has access to the given context. |
data |
Retrieve the value of a requirement. You must declare the attribute in this function’s requirements list. |
evaluate |
Implement this method to provide logic for the function. Use self methods and properties to access the simulation context or defer processing to another function. |
defer |
Defer processing to another instance of a SimulationFunction, returning the result of evaluation. |