Skip to content

simulator.engines

The executor of the engine of a model.

execute_plan runs a plan on a loaded model with the executor of its engine: sbmlsim.simulator.executor for roadrunner, sbmlsim.simulator.executor_copasi for COPASI, sbmlsim.simulator.executor_amici for AMICI and sbmlsim.simulator.executor_core for sbmlsim-core, which are imported when a model of their engine runs, so a run of roadrunner never imports COPASI, AMICI or the bindings of sbmlsim-core. Every simulation of the package outside the executors runs through it: the simulator, the workers of a scan and the evaluation of a fit.

execute_plan

execute_plan(plan, model, selections)

Run a plan on a loaded model with the executor of its engine.

Parameters:

Name Type Description Default
plan Plan

the plan, compiled against the model.

required
model SBMLModel

the loaded model, of roadrunner, COPASI, AMICI or the engine core.

required
selections Sequence[str]

the columns of the output, the time first.

required

Returns:

Type Description
TimecourseResult

The output of the simulation.

Raises:

Type Description
RuntimeError

if the engine fails to integrate.

SteadyStateError

if a presimulation finds no steady state.

NotImplementedError

for a feature the engine does not simulate, the same for every plan of the model, see check_plan.

TypeError

if the model is not a model of its engine.

ValueError

for an engine without an executor.

execute_plans

execute_plans(points, model, threads)

Run the plans of a batch on a loaded model, one batch of sbmlsim-core.

sbmlsim-core simulates a batch of plans on threads of its own, so the points of the batch run at once in this process, see sbmlsim.simulator.executor_core.execute_many. The other engines simulate one plan per call, so the batch is the loop over the plans for them: a caller gains the threads of the batch with sbmlsim-core and the same results with every engine, see sbmlsim.fit.optimization.OptimizationProblem.evaluate_residuals_many.

Parameters:

Name Type Description Default
points Sequence[tuple[Plan, Sequence[str]]]

the plan of every point of the batch and the columns of its output, in their order.

required
model SBMLModel

the loaded model of every point of the batch.

required
threads int

the threads of the engine the batch runs on, which only the sbmlsim-core uses.

required

Returns:

Type Description
list[TimecourseResult | Exception]

The output of every point in the order of the points, the error which

list[TimecourseResult | Exception]

failed it instead: the error of its integration or of its

list[TimecourseResult | Exception]

presimulation.

Raises:

Type Description
NotImplementedError

for a feature the engine does not simulate, the same for every point of the model, see check_plan.

TypeError

if the model is not a model of its engine.

ValueError

for an engine without an executor, or if the engine refuses the batch.

check_plan

check_plan(plan, model)

Check that the engine of a model simulates a plan, before it runs.

A feature the engine does not simulate is the same for every point of a plan, so a run checks it once before it runs a point, serially or in a pool; the executor checks every plan as well. roadrunner simulates every plan, COPASI refuses a change of a conversion factor and a delayed event of the model in a plan which sets values between two runs, see sbmlsim.simulator.executor_copasi.check_supported, and AMICI a change of a compartment it keeps out of its states, see sbmlsim.simulator.executor_amici.check_supported. A scan of sbmlsim-core is checked by its planner, see sbmlsim.simulator.scan_core, and every request of its executor by executor_core.check_supported.

Parameters:

Name Type Description Default
plan Plan

the plan, compiled against the model, with the values of a point.

required
model SBMLModel

the loaded model.

required

Raises:

Type Description
NotImplementedError

for a feature the engine does not simulate.

TypeError

if the model is not a model of its engine.

ValueError

for an engine without an executor.

core_model

core_model(model)

Get a model of sbmlsim-core as its class.

The module of the model does not import the bindings of sbmlsim-core, a model of the engine which is loaded has imported them. It is public, unlike the three others, since a scan of sbmlsim-core narrows its model as well, see sbmlsim.simulator.simulator.Simulator.run.

Parameters:

Name Type Description Default
model SBMLModel

the loaded model.

required

Returns:

Type Description
CoreSBMLModel

The model as a CoreSBMLModel.

Raises:

Type Description
TypeError

if the model is not a model of sbmlsim-core.