Skip to content

simulator.segments

The segments of a plan on an engine which continues one integration from another.

The executors of COPASI and of AMICI integrate the segments of a plan between its changes in absolute time, every one from the state the one before it ended in, and share how the segments are cut, which changes and events of the model are applied at their bounds and which rows the output has, see simulate_segments; an engine integrates through its Course. The executor of roadrunner has its own segments, see sbmlsim.simulator.executor.

Course

Bases: Protocol

The integrations of a model of an engine which continue one another.

steps

steps(start, end)

Integrate from start to end with the output of the steps of the integrator.

Returns:

Type Description
ndarray

The values, a row per step, the first at the start and the last

ndarray

at the end, an event of the model as two rows at its time; an

ndarray

event right after the start has its row after the row of the

ndarray

start.

times

times(start, times, end)

Integrate from start with output at times, the last one the stop.

Parameters:

Name Type Description Default
start float

the time of the current state.

required
times ndarray

the output times, sorted, distinct, after the start.

required
end float

the end of the segment, which the integration must not reach if the last time is before it.

required

Returns:

Type Description
ndarray

The values, a row at the start, the state before an event right

ndarray

after it, and a row per time, at the times.

event_at_the_end

event_at_the_end(start, end, tolerance)

Get the state after the events of the model at the end of a simulation.

An event within the resolution of the time after the end is at the end, as a time of a grid sees it, see sbmlsim.result.timecourse.grid_weights.

Parameters:

Name Type Description Default
start float

the start of the integration, just before the end, where the last segment stopped, or the end after a change at the end.

required
end float

the end of the simulation.

required
tolerance float

the resolution of the time.

required

Returns:

Type Description
ndarray | None

The state after the last event within the resolution after the

ndarray | None

end, None without one.

horizon

horizon(start, end)

Integrate from start to end without output, events active.

rates

rates(states)

Get the current rates of change of states, the species in amounts.

steady_state

steady_state(plan, start)

Integrate the model from a time until its rates of change vanish, see steady_state.

Returns:

Type Description
float

The time the steady state was reached at.

simulate_segments

simulate_segments(plan, model, values, columns, course)

Integrate the segments of a plan.

The interval is split at the times of the changes. At the start of a segment the changes of its time are applied, every value evaluated with the state at that time before any target is set, see sbmlsim.simulator.changes.apply_changes; after a change after the start (or at the start after a presimulation) the events whose triggers the change made true fire, which an engine does not see, see sbmlsim.simulator.changes.fire_events. A change at the start without a presimulation fires no event, as in roadrunner, whose triggers are the ones of the initial state. A change after the start, the one at the end included, has two rows at its time, the state before the change, which ends the segment before it, and the state after it, which starts the next one. A segment of a model with events stops just before its end, see sbmlsim.simulator.executor.segment_stop, so an event of the model at the time of a change fires after the change; a segment too short for the integrator is not integrated, its state is the one at its start, see sbmlsim.simulator.executor.integrable. An event of the model within the resolution of the time after the end is at the end, see Course.event_at_the_end: the steps of the integrator have it as two rows, an output time at the end the state after it. The steady state after the end starts after it.

Parameters:

Name Type Description Default
plan Plan

the plan.

required
model SBMLModel

the model, initialized, after the presimulation.

required
values ModelValues

the values of the model.

required
columns list[str]

the selections, the time first.

required
course Course

the integrations of the model.

required

Returns:

Type Description
ndarray

The values, a row per output time and a column per selection, two

ndarray

rows at the time of a change after the start which is an output

ndarray

time.

steady_state

steady_state(model, course, plan, start=0.0)

Integrate a model until its rates of change vanish.

The algorithm and the criterion of sbmlsim.simulator.executor.steady_state: the model is integrated over horizons which grow by a factor of ten, from start, until |dx/dt| <= absolute_tolerance + relative_tolerance * |x| for every state, the species in amounts, events active.

Parameters:

Name Type Description Default
model SBMLModel

the model in the state the integration starts from.

required
course Course

the integrations of the model.

required
plan SteadyStatePlan

the steady state.

required
start float

the time the integration starts at.

0.0

Returns:

Type Description
float

The time the steady state was reached at.

Raises:

Type Description
SteadyStateError

if the steady state is not reached by max_time.

RuntimeError

if the engine fails to integrate, with its message.

held_rows

held_rows(model, columns, times)

Get the rows of a segment which is not integrated, the state at its start.

state_row

state_row(model, columns, time)

Get the current values of the selections, time the given time.