Skip to content

model.comparisons

The comparisons of the maths of an SBML model, which an engine shifts at their threshold.

The integrators of AMICI (CVODES) and of COPASI (LSODA) find the root of a comparison where its root function changes its sign, and not where it leaves 0: a comparison which is exactly at its threshold when the integrator starts to watch it is not found when it turns later. The models of both engines therefore compile a comparison shifted by a parameter, a > b + shift, which is 0 but at the start of an integration at which the comparison is exactly at its threshold, see shift_comparison.

trigger_comparisons

trigger_comparisons(trigger, kinds=STRICT_COMPARISONS)

Get the comparisons of a trigger of given kinds, through its logical operators.

Parameters:

Name Type Description Default
trigger ASTNode

the math of the trigger.

required
kinds Sequence[int]

the types of the nodes of the comparisons, the strict ones > and < by default (STRICT_COMPARISONS), or every comparison (COMPARISONS).

STRICT_COMPARISONS

Returns:

Type Description
list[_Found]

The comparisons in the order of the math, each with its parent

list[_Found]

(None for the trigger itself) and its position in it.

math_comparisons

math_comparisons(math, kinds)

Get the comparisons of given kinds anywhere in a math, e.g. in the conditions of its piecewises.

Parameters:

Name Type Description Default
math ASTNode

the math.

required
kinds Sequence[int]

the types of the nodes of the comparisons.

required

Returns:

Type Description
list[_Found]

The comparisons in the order of the math, a comparison before the

list[_Found]

ones in its operands, each with its parent (None for the math

list[_Found]

itself) and its position in it.

shift_comparison

shift_comparison(comparison, pid)

Shift a comparison by a parameter so that it keeps its value at its threshold.

a > b becomes a > b + shift, a < b a + shift < b, a >= b a >= b - shift and a <= b a <= b + shift: a positive shift keeps the value of the comparison at its threshold until the operands move by the shift in the direction which changes it, a shift of 0 is the comparison as written.

Parameters:

Name Type Description Default
comparison ASTNode

the node of the comparison, changed in place.

required
pid str

the id of the parameter of the shift.

required