simulator.changes¶
The changes of a plan and the events a change fires, independent of the engine.
An executor applies the changes of a plan at their times and fires the events
of the model whose triggers a change made true (PEtab v2, reinitialization),
which an engine does not see, since the values are set between two
integrations. Both read and write the values of the model through
ModelValues, the getValue/setValue of the selections of roadrunner,
which roadrunner.RoadRunner has and an executor of another engine provides,
see sbmlsim.simulator.executor.
ModelValues
¶
Bases: Protocol
The current values of a model in the selections of roadrunner.
A selection is S for the amount of a species, [S] for its
concentration, or the id of a parameter or a compartment.
roadrunner.RoadRunner satisfies the protocol.
SBMLModelLike
¶
Bases: Protocol
The model of the messages of the events.
Attributes:
| Name | Type | Description |
|---|---|---|
sid |
str | None
|
id of the model, |
reported_triggers |
set[str]
|
the events whose trigger was reported as no math the simulator evaluates, so a trigger is reported once. |
apply_changes
¶
Apply the assignments of a change.
Every value is evaluated first, with the state at the time of the change, then every target is set; a compartment keeps the concentration of the concentration species in it (PEtab v2).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
event
|
PlanEvent
|
the assignments at one time. |
required |
values
|
ModelValues
|
the values of the model. |
required |
plan
|
Plan
|
the plan, whose symbols resolve the targets. |
required |
Raises:
| Type | Description |
|---|---|
ValueError
|
if an assignment has neither a value nor a formula. |
triggers
¶
Evaluate the triggers of the events, None for one which is not evaluated.
A trigger which is no math the simulator evaluates, one with rateOf or
delay, see sbmlsim.sbml_math.compile_math, is not evaluated, so a
change does not fire its event; it is reported once per event of a model
instance, so once per worker of a pool, which loads its own instance.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
events
|
Sequence[EventSymbols]
|
the events of the model. |
required |
values
|
ModelValues
|
the values of the model. |
required |
time
|
float
|
the time of the model. |
required |
model
|
SBMLModelLike
|
the model, for the messages. |
required |
Returns:
| Type | Description |
|---|---|
list[bool | None]
|
The value of every trigger. |
fire_start_events
¶
Fire the events whose trigger is false before the time 0 and true at the start.
roadrunner fires them at the start in the initial state, with the events
they trigger in the order of their priorities, before a change at the
start; the executors of COPASI and AMICI fire them with this function,
their engines get the triggers of such events true before the time 0,
see sbmlsim.model.model_copasi and sbmlsim.model.model_amici.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
events
|
Sequence[EventSymbols]
|
the events of the model. |
required |
start
|
Sequence[bool]
|
by the position of an event, whether its trigger is false
before the time 0 ( |
required |
values
|
ModelValues
|
the values of the model, in its initial state. |
required |
time
|
float
|
the time of the start. |
required |
model
|
SBMLModelLike
|
the model, for the messages. |
required |
Returns:
| Type | Description |
|---|---|
list[int]
|
The events which fired, by their positions, see |
fire_events
¶
Fire the events whose triggers a change made true.
An engine does not see a trigger which becomes true by a value which is
set between two integrations, so the executor fires such events (PEtab
v2, reinitialization: the events are applied after the changes): the
events execute one at a time in priority order. Priorities and triggers
are evaluated again after every event, and a nonpersistent pending event
is cancelled if its trigger becomes false. Assignment values are captured
at the trigger or evaluated at execution, as the event specifies. An event
with a delay is reported and not fired, an event whose priority is no
math the simulator evaluates is reported and fires with the priority 0,
the one of an event without a priority, and an event whose trigger or
assignments are no math the simulator evaluates is reported and not
fired, see triggers. One event fires at most MAX_EXECUTIONS_PER_EVENT
times, which stops events which trigger each other in a cycle.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
events
|
Sequence[EventSymbols]
|
the events of the model. |
required |
before
|
list[bool | None]
|
the triggers before the change. |
required |
values
|
ModelValues
|
the values of the model, in the state after the change. |
required |
time
|
float
|
the time of the change. |
required |
model
|
SBMLModelLike
|
the model, for the messages. |
required |
after
|
Sequence[bool | None] | None
|
the triggers after the change, evaluated in the state after
it for |
None
|
Returns:
| Type | Description |
|---|---|
list[int]
|
The events which fired, by their positions, in the order of their |
list[int]
|
executions; an event which fired twice is listed twice. |