Skip to content

scales

The typical magnitudes of the states of a model, which scale their absolute tolerances.

An absolute tolerance relative to the scale of every state (AbsoluteTolerance(relative=..., scales=...), see sbmlsim.model.tolerances) gives a small state the same relative accuracy as a large one (#435). The initial value of a state is its scale when no scale is given, which leaves a state which starts at 0, e.g. a drug before its dose, at the tolerance of its kind. typical_scales gives the largest magnitude of every state in test simulations, e.g. the standard doses of a model, which includes its initial value:

scales = typical_scales(simulator, model, [oral_dose, iv_dose])
tolerance = AbsoluteTolerance(relative=1e-10, scales=scales)

The scales are computed once and stored with the model, e.g. in the settings of the simulator of its project as JSON (AbsoluteTolerance.to_dict), so that the tolerances of a simulation never depend on its own scenario. Fixed scales of a standard dose keep the relative accuracy of the states within about 1e-7 from a hundredth to a hundred times the dose, see #435.

typical_scales

typical_scales(simulator, model, simulations)

Get the largest magnitude of every state of a model in test simulations.

The states are the ones roadrunner integrates, the targets of the rate rules and the independent floating species, whose scale is their amount, as the tolerances of AbsoluteTolerance are amounts. Every simulation, or every point of a scan, is simulated with the simulator in the steps of the integrator, and the scale of a state is the largest absolute value it takes in any of them, the start included.

Parameters:

Name Type Description Default
simulator Simulator

the simulator, of any engine.

required
model ModelLike

the model.

required
simulations Simulation | Scan | Iterable[Simulation | Scan]

the test simulations, a simulation or a scan or several.

required

Returns:

Type Description
dict[str, float]

The scale of every state which is not 0 in all simulations, by id, in

dict[str, float]

the order of the states.

Raises:

Type Description
ValueError

without a simulation.