amici.de_model_components

Objects for AMICI’s internal differential equation model representation

Classes

AlgebraicEquation(symbol, value)

An AlgebraicEquation defines an algebraic equation.

AlgebraicState(symbol, name, init)

An AlgebraicState defines an entity that is algebraically determined

ConservationLaw(symbol, name, value, ...)

A conservation law defines the absolute the total amount of a (weighted) sum of states

Constant(symbol, name, value)

A Constant is a fixed variable in the model with respect to which sensitivities cannot be computed, abbreviated by k.

DifferentialState(symbol, name, init, dt)

A State variable defines an entity that evolves with time according to the provided time derivative, abbreviated by x.

Event(symbol, name, value, ...[, ...])

An Event defines either a SBML event or a root of the argument of a Heaviside function.

EventObservable(symbol, name, value, event)

An Event Observable links model simulations to event related experimental measurements, abbreviated by z.

Expression(symbol, name, value)

An Expression is a recurring elements in symbolic formulas.

LogLikelihood(symbol, name, value)

A LogLikelihood defines the distance between measurements and experiments for a particular observable.

LogLikelihoodRZ(symbol, name, value)

Loglikelihood for event observables regularization

LogLikelihoodY(symbol, name, value)

Loglikelihood for observables

LogLikelihoodZ(symbol, name, value)

Loglikelihood for event observables

ModelQuantity(symbol, name, value)

Base class for model components

NoiseParameter(symbol, name)

A NoiseParameter is an input variable for the computation of sigma that can be specified in a data-point specific manner, abbreviated by np.

Observable(symbol, name, value[, ...])

An Observable links model simulations to experimental measurements, abbreviated by y.

ObservableParameter(symbol, name)

A NoiseParameter is an input variable for the computation of y that can be specified in a data-point specific manner, abbreviated by op.

Parameter(symbol, name, value)

A Parameter is a free variable in the model with respect to which sensitivities may be computed, abbreviated by p.

Sigma(symbol, name, value)

A Standard Deviation Sigma rescales the distance between simulations and measurements when computing residuals or objective functions, abbreviated by sigma{y,z}.

SigmaY(symbol, name, value)

Standard deviation for observables

SigmaZ(symbol, name, value)

Standard deviation for event observables

State(symbol, name, value)

Base class for differential and algebraic model states

class amici.de_model_components.AlgebraicEquation(symbol, value)[source]

An AlgebraicEquation defines an algebraic equation.

__init__(symbol, value)[source]

Create a new AlgebraicEquation instance.

Parameters:

value (sympy.core.expr.Expr) – Formula of the algebraic equation, the solution is given by formula == 0

get_free_symbols()[source]
get_id()

ModelQuantity identifier

Return type:

str

Returns:

identifier of the ModelQuantity

get_name()

ModelQuantity name

Return type:

str

Returns:

name of the ModelQuantity

get_sym()

ModelQuantity symbol

Return type:

sympy.core.symbol.Symbol

Returns:

Symbol of the ModelQuantity

get_val()

ModelQuantity value

Return type:

sympy.core.expr.Expr

Returns:

value of the ModelQuantity

set_val(val)

Set ModelQuantity value

Returns:

value of the ModelQuantity

class amici.de_model_components.AlgebraicState(symbol, name, init)[source]

An AlgebraicState defines an entity that is algebraically determined

__init__(symbol, name, init)[source]

Create a new AlgebraicState instance.

Parameters:
get_dx_rdata_dx_solver(state_id)

Returns the expression that allows computation of dx_rdata_dx_solver for this state, accounting for conservation laws.

Returns:

dx_rdata_dx_solver expression

get_free_symbols()[source]
get_id()

ModelQuantity identifier

Return type:

str

Returns:

identifier of the ModelQuantity

get_name()

ModelQuantity name

Return type:

str

Returns:

name of the ModelQuantity

get_sym()

ModelQuantity symbol

Return type:

sympy.core.symbol.Symbol

Returns:

Symbol of the ModelQuantity

get_val()

ModelQuantity value

Return type:

sympy.core.expr.Expr

Returns:

value of the ModelQuantity

get_x_rdata()[source]

Returns the expression that allows computation of x_rdata for this state, accounting for conservation laws.

Returns:

x_rdata expression

has_conservation_law()[source]

Checks whether this state has a conservation law assigned.

Return type:

bool

Returns:

True if assigned, False otherwise

set_val(val)

Set ModelQuantity value

Returns:

value of the ModelQuantity

class amici.de_model_components.ConservationLaw(symbol, name, value, coefficients, state_id)[source]

A conservation law defines the absolute the total amount of a (weighted) sum of states

__init__(symbol, name, value, coefficients, state_id)[source]

Create a new ConservationLaw instance.

Parameters:
get_id()

ModelQuantity identifier

Return type:

str

Returns:

identifier of the ModelQuantity

get_name()

ModelQuantity name

Return type:

str

Returns:

name of the ModelQuantity

get_ncoeff(state_sym)[source]

Computes the normalized coefficient a_i/a_j where i is the index of the provided state_id and j is the index of the state that is replaced by this conservation law. This can be used to compute both dtotal_cl/dx_rdata (=ncoeff) and dx_rdata/dx_solver (=-ncoeff).

Parameters:

state_sym (sympy.core.symbol.Symbol) – Symbol of the state

Return type:

sympy.core.expr.Expr | int | float

Returns:

normalized coefficient of the state

get_sym()

ModelQuantity symbol

Return type:

sympy.core.symbol.Symbol

Returns:

Symbol of the ModelQuantity

get_val()

ModelQuantity value

Return type:

sympy.core.expr.Expr

Returns:

value of the ModelQuantity

get_x_rdata()[source]

Returns the expression that allows computation of x_rdata for the state that this conservation law replaces.

Returns:

x_rdata expression

set_val(val)

Set ModelQuantity value

Returns:

value of the ModelQuantity

class amici.de_model_components.Constant(symbol, name, value)[source]

A Constant is a fixed variable in the model with respect to which sensitivities cannot be computed, abbreviated by k.

__init__(symbol, name, value)[source]

Create a new Expression instance.

Parameters:
get_id()

ModelQuantity identifier

Return type:

str

Returns:

identifier of the ModelQuantity

get_name()

ModelQuantity name

Return type:

str

Returns:

name of the ModelQuantity

get_sym()

ModelQuantity symbol

Return type:

sympy.core.symbol.Symbol

Returns:

Symbol of the ModelQuantity

get_val()

ModelQuantity value

Return type:

sympy.core.expr.Expr

Returns:

value of the ModelQuantity

set_val(val)

Set ModelQuantity value

Returns:

value of the ModelQuantity

class amici.de_model_components.DifferentialState(symbol, name, init, dt)[source]

A State variable defines an entity that evolves with time according to the provided time derivative, abbreviated by x.

Variables:
  • _conservation_law – algebraic formula that allows computation of this state according to a conservation law

  • _dt – algebraic formula that defines the temporal derivative of this state

__init__(symbol, name, init, dt)[source]

Create a new State instance. Extends ModelQuantity.__init__() by dt

Parameters:
get_dt()[source]

Gets the time derivative

Return type:

sympy.core.expr.Expr

Returns:

time derivative

get_dx_rdata_dx_solver(state_id)

Returns the expression that allows computation of dx_rdata_dx_solver for this state, accounting for conservation laws.

Returns:

dx_rdata_dx_solver expression

get_free_symbols()[source]

Gets the set of free symbols in time derivative and initial conditions

Return type:

set[sympy.core.basic.Basic]

Returns:

free symbols

get_id()

ModelQuantity identifier

Return type:

str

Returns:

identifier of the ModelQuantity

get_name()

ModelQuantity name

Return type:

str

Returns:

name of the ModelQuantity

get_sym()

ModelQuantity symbol

Return type:

sympy.core.symbol.Symbol

Returns:

Symbol of the ModelQuantity

get_val()

ModelQuantity value

Return type:

sympy.core.expr.Expr

Returns:

value of the ModelQuantity

get_x_rdata()

Returns the expression that allows computation of x_rdata for this state, accounting for conservation laws.

Returns:

x_rdata expression

has_conservation_law()[source]

Checks whether this state has a conservation law assigned.

Returns:

True if assigned, False otherwise

set_conservation_law(law)[source]

Sets the conservation law of a state.

If a conservation law is set, the respective state will be replaced by an algebraic formula according to the respective conservation law.

Parameters:

law (amici.de_model_components.ConservationLaw) – linear sum of states that if added to this state remain constant over time

Return type:

None

set_dt(dt)[source]

Sets the time derivative

Parameters:

dt (sympy.core.expr.Expr) – time derivative

Return type:

None

set_val(val)

Set ModelQuantity value

Returns:

value of the ModelQuantity

class amici.de_model_components.Event(symbol, name, value, use_values_from_trigger_time, assignments=None, initial_value=True, priority=None)[source]

An Event defines either a SBML event or a root of the argument of a Heaviside function. The Heaviside functions will be tracked via the vector h during simulation and are needed to inform the solver about a discontinuity in either the right-hand side or the states themselves, causing a reinitialization of the solver.

__init__(symbol, name, value, use_values_from_trigger_time, assignments=None, initial_value=True, priority=None)[source]

Create a new Event instance.

Parameters:
  • symbol (sympy.core.symbol.Symbol) – unique symbol of the Event

  • name (str) – individual name of the Event (does not need to be unique)

  • value (sympy.core.expr.Expr) – formula for the root / trigger function

  • assignments (dict[sympy.core.symbol.Symbol, sympy.core.expr.Expr] | None) – Dictionary of event assignments: state symbol -> new value.

  • initial_value (bool | None) – initial boolean value of the trigger function at t0. If set to False, events may trigger at t==t0, otherwise not.

  • priority (sympy.core.basic.Basic | None) – The priority of the event assignment.

  • use_values_from_trigger_time (bool) – Whether the event assignment is evaluated using the state from the time point at which the event triggered (True), or at the time point at which the event assignment is evaluated (False).

get_id()

ModelQuantity identifier

Return type:

str

Returns:

identifier of the ModelQuantity

get_initial_value()[source]

Return the initial value for the root function.

Return type:

bool

Returns:

initial value formula

get_name()

ModelQuantity name

Return type:

str

Returns:

name of the ModelQuantity

get_priority()[source]

Return the priority of the event assignment.

Return type:

sympy.core.basic.Basic | None

get_state_update(x, x_old)[source]

Get the state update (bolus) expression for the event assignment.

Parameters:
Return type:

sympy.matrices.dense.MutableDenseMatrix | None

Returns:

State-update matrix or None if no state update is defined.

get_sym()

ModelQuantity symbol

Return type:

sympy.core.symbol.Symbol

Returns:

Symbol of the ModelQuantity

get_trigger_time()[source]

Get the time at which the event triggers.

Only for events that trigger at a single fixed time-point.

Return type:

sympy.core.numbers.Float

get_trigger_times()[source]

Get the time points at which the event triggers.

Returns a set of expressions, which may contain multiple time points for events that trigger at multiple time points.

If the return value is empty, the trigger function cannot be solved for t. I.e., the event does not explicitly depend on time, or sympy is unable to solve the trigger function for t.

If the return value is non-empty, it contains expressions for all time points at which the event triggers.

Return type:

set[sympy.core.expr.Expr]

get_val()

ModelQuantity value

Return type:

sympy.core.expr.Expr

Returns:

value of the ModelQuantity

has_explicit_trigger_times(allowed_symbols=None)[source]

Check whether the event has explicit trigger times.

Explicit trigger times do not require root finding to determine the time points at which the event triggers.

Parameters:

allowed_symbols (set[sympy.core.symbol.Symbol] | None) – The set of symbols that are allowed in the trigger time expressions. If None, any symbols are allowed. If empty, only numeric values are allowed.

Return type:

bool

set_val(val)

Set ModelQuantity value

Returns:

value of the ModelQuantity

triggers_at_fixed_timepoint()[source]

Check whether the event triggers at a (single) fixed time-point.

Return type:

bool

property updates_state: bool

Whether the event assignment updates the model state.

property uses_values_from_trigger_time: bool

Whether the event assignment is evaluated using the state from the time point at which the event triggered (True), or at the time point at which the event assignment is evaluated (False).

class amici.de_model_components.EventObservable(symbol, name, value, event, measurement_symbol=None, transformation='lin')[source]

An Event Observable links model simulations to event related experimental measurements, abbreviated by z.

Variables:

_event – symbolic event identifier

__init__(symbol, name, value, event, measurement_symbol=None, transformation='lin')[source]

Create a new EventObservable instance.

Parameters:
get_event()[source]

Get the symbolic identifier of the corresponding event.

Return type:

sympy.core.symbol.Symbol

Returns:

symbolic identifier

get_id()

ModelQuantity identifier

Return type:

str

Returns:

identifier of the ModelQuantity

get_measurement_symbol()
Return type:

sympy.core.symbol.Symbol

get_name()

ModelQuantity name

Return type:

str

Returns:

name of the ModelQuantity

get_regularization_symbol()
Return type:

sympy.core.symbol.Symbol

get_sym()

ModelQuantity symbol

Return type:

sympy.core.symbol.Symbol

Returns:

Symbol of the ModelQuantity

get_val()

ModelQuantity value

Return type:

sympy.core.expr.Expr

Returns:

value of the ModelQuantity

set_val(val)

Set ModelQuantity value

Returns:

value of the ModelQuantity

class amici.de_model_components.Expression(symbol, name, value)[source]

An Expression is a recurring elements in symbolic formulas. Specifying this may yield more compact expression which may lead to substantially shorter model compilation times, but may also reduce model simulation time. Abbreviated by w.

__init__(symbol, name, value)[source]

Create a new Expression instance.

Parameters:
get_id()

ModelQuantity identifier

Return type:

str

Returns:

identifier of the ModelQuantity

get_name()

ModelQuantity name

Return type:

str

Returns:

name of the ModelQuantity

get_sym()

ModelQuantity symbol

Return type:

sympy.core.symbol.Symbol

Returns:

Symbol of the ModelQuantity

get_val()

ModelQuantity value

Return type:

sympy.core.expr.Expr

Returns:

value of the ModelQuantity

set_val(val)

Set ModelQuantity value

Returns:

value of the ModelQuantity

class amici.de_model_components.LogLikelihoodRZ(symbol, name, value)[source]

Loglikelihood for event observables regularization

__init__(symbol, name, value)

Create a new Expression instance.

Parameters:
get_id()

ModelQuantity identifier

Return type:

str

Returns:

identifier of the ModelQuantity

get_name()

ModelQuantity name

Return type:

str

Returns:

name of the ModelQuantity

get_sym()

ModelQuantity symbol

Return type:

sympy.core.symbol.Symbol

Returns:

Symbol of the ModelQuantity

get_val()

ModelQuantity value

Return type:

sympy.core.expr.Expr

Returns:

value of the ModelQuantity

set_val(val)

Set ModelQuantity value

Returns:

value of the ModelQuantity

class amici.de_model_components.LogLikelihoodY(symbol, name, value)[source]

Loglikelihood for observables

__init__(symbol, name, value)

Create a new Expression instance.

Parameters:
get_id()

ModelQuantity identifier

Return type:

str

Returns:

identifier of the ModelQuantity

get_name()

ModelQuantity name

Return type:

str

Returns:

name of the ModelQuantity

get_sym()

ModelQuantity symbol

Return type:

sympy.core.symbol.Symbol

Returns:

Symbol of the ModelQuantity

get_val()

ModelQuantity value

Return type:

sympy.core.expr.Expr

Returns:

value of the ModelQuantity

set_val(val)

Set ModelQuantity value

Returns:

value of the ModelQuantity

class amici.de_model_components.LogLikelihoodZ(symbol, name, value)[source]

Loglikelihood for event observables

__init__(symbol, name, value)

Create a new Expression instance.

Parameters:
get_id()

ModelQuantity identifier

Return type:

str

Returns:

identifier of the ModelQuantity

get_name()

ModelQuantity name

Return type:

str

Returns:

name of the ModelQuantity

get_sym()

ModelQuantity symbol

Return type:

sympy.core.symbol.Symbol

Returns:

Symbol of the ModelQuantity

get_val()

ModelQuantity value

Return type:

sympy.core.expr.Expr

Returns:

value of the ModelQuantity

set_val(val)

Set ModelQuantity value

Returns:

value of the ModelQuantity

class amici.de_model_components.ModelQuantity(symbol, name, value)[source]

Base class for model components

__init__(symbol, name, value)[source]

Create a new ModelQuantity instance.

Parameters:
get_id()[source]

ModelQuantity identifier

Return type:

str

Returns:

identifier of the ModelQuantity

get_name()[source]

ModelQuantity name

Return type:

str

Returns:

name of the ModelQuantity

get_sym()[source]

ModelQuantity symbol

Return type:

sympy.core.symbol.Symbol

Returns:

Symbol of the ModelQuantity

get_val()[source]

ModelQuantity value

Return type:

sympy.core.expr.Expr

Returns:

value of the ModelQuantity

set_val(val)[source]

Set ModelQuantity value

Returns:

value of the ModelQuantity

class amici.de_model_components.NoiseParameter(symbol, name)[source]

A NoiseParameter is an input variable for the computation of sigma that can be specified in a data-point specific manner, abbreviated by np. Only used for jax models.

__init__(symbol, name)[source]

Create a new Expression instance.

Parameters:
  • symbol (sympy.core.symbol.Symbol) – unique symbol of the NoiseParameter

  • name (str) – individual name of the NoiseParameter (does not need to be unique)

get_id()

ModelQuantity identifier

Return type:

str

Returns:

identifier of the ModelQuantity

get_name()

ModelQuantity name

Return type:

str

Returns:

name of the ModelQuantity

get_sym()

ModelQuantity symbol

Return type:

sympy.core.symbol.Symbol

Returns:

Symbol of the ModelQuantity

get_val()

ModelQuantity value

Return type:

sympy.core.expr.Expr

Returns:

value of the ModelQuantity

set_val(val)

Set ModelQuantity value

Returns:

value of the ModelQuantity

class amici.de_model_components.Observable(symbol, name, value, measurement_symbol=None, transformation=ObservableTransformation.LIN)[source]

An Observable links model simulations to experimental measurements, abbreviated by y.

Variables:
  • _measurement_symbol – sympy symbol used in the objective function to represent measurements to this observable

  • trafo – observable transformation, only applies when evaluating objective function or residuals

__init__(symbol, name, value, measurement_symbol=None, transformation=ObservableTransformation.LIN)[source]

Create a new Observable instance.

Parameters:
get_id()

ModelQuantity identifier

Return type:

str

Returns:

identifier of the ModelQuantity

get_measurement_symbol()[source]
Return type:

sympy.core.symbol.Symbol

get_name()

ModelQuantity name

Return type:

str

Returns:

name of the ModelQuantity

get_regularization_symbol()[source]
Return type:

sympy.core.symbol.Symbol

get_sym()

ModelQuantity symbol

Return type:

sympy.core.symbol.Symbol

Returns:

Symbol of the ModelQuantity

get_val()

ModelQuantity value

Return type:

sympy.core.expr.Expr

Returns:

value of the ModelQuantity

set_val(val)

Set ModelQuantity value

Returns:

value of the ModelQuantity

class amici.de_model_components.ObservableParameter(symbol, name)[source]

A NoiseParameter is an input variable for the computation of y that can be specified in a data-point specific manner, abbreviated by op. Only used for jax models.

__init__(symbol, name)[source]

Create a new Expression instance.

Parameters:
  • symbol (sympy.core.symbol.Symbol) – unique symbol of the ObservableParameter

  • name (str) – individual name of the ObservableParameter (does not need to be unique)

get_id()

ModelQuantity identifier

Return type:

str

Returns:

identifier of the ModelQuantity

get_name()

ModelQuantity name

Return type:

str

Returns:

name of the ModelQuantity

get_sym()

ModelQuantity symbol

Return type:

sympy.core.symbol.Symbol

Returns:

Symbol of the ModelQuantity

get_val()

ModelQuantity value

Return type:

sympy.core.expr.Expr

Returns:

value of the ModelQuantity

set_val(val)

Set ModelQuantity value

Returns:

value of the ModelQuantity

class amici.de_model_components.Parameter(symbol, name, value)[source]

A Parameter is a free variable in the model with respect to which sensitivities may be computed, abbreviated by p.

__init__(symbol, name, value)[source]

Create a new Expression instance.

Parameters:
get_id()

ModelQuantity identifier

Return type:

str

Returns:

identifier of the ModelQuantity

get_name()

ModelQuantity name

Return type:

str

Returns:

name of the ModelQuantity

get_sym()

ModelQuantity symbol

Return type:

sympy.core.symbol.Symbol

Returns:

Symbol of the ModelQuantity

get_val()

ModelQuantity value

Return type:

sympy.core.expr.Expr

Returns:

value of the ModelQuantity

set_val(val)

Set ModelQuantity value

Returns:

value of the ModelQuantity

class amici.de_model_components.SigmaY(symbol, name, value)[source]

Standard deviation for observables

__init__(symbol, name, value)

Create a new Standard Deviation instance.

Parameters:
get_id()

ModelQuantity identifier

Return type:

str

Returns:

identifier of the ModelQuantity

get_name()

ModelQuantity name

Return type:

str

Returns:

name of the ModelQuantity

get_sym()

ModelQuantity symbol

Return type:

sympy.core.symbol.Symbol

Returns:

Symbol of the ModelQuantity

get_val()

ModelQuantity value

Return type:

sympy.core.expr.Expr

Returns:

value of the ModelQuantity

set_val(val)

Set ModelQuantity value

Returns:

value of the ModelQuantity

class amici.de_model_components.SigmaZ(symbol, name, value)[source]

Standard deviation for event observables

__init__(symbol, name, value)

Create a new Standard Deviation instance.

Parameters:
get_id()

ModelQuantity identifier

Return type:

str

Returns:

identifier of the ModelQuantity

get_name()

ModelQuantity name

Return type:

str

Returns:

name of the ModelQuantity

get_sym()

ModelQuantity symbol

Return type:

sympy.core.symbol.Symbol

Returns:

Symbol of the ModelQuantity

get_val()

ModelQuantity value

Return type:

sympy.core.expr.Expr

Returns:

value of the ModelQuantity

set_val(val)

Set ModelQuantity value

Returns:

value of the ModelQuantity

class amici.de_model_components.State(symbol, name, value)[source]

Base class for differential and algebraic model states

__init__(symbol, name, value)

Create a new ModelQuantity instance.

Parameters:
get_dx_rdata_dx_solver(state_id)[source]

Returns the expression that allows computation of dx_rdata_dx_solver for this state, accounting for conservation laws.

Returns:

dx_rdata_dx_solver expression

get_id()

ModelQuantity identifier

Return type:

str

Returns:

identifier of the ModelQuantity

get_name()

ModelQuantity name

Return type:

str

Returns:

name of the ModelQuantity

get_sym()

ModelQuantity symbol

Return type:

sympy.core.symbol.Symbol

Returns:

Symbol of the ModelQuantity

get_val()

ModelQuantity value

Return type:

sympy.core.expr.Expr

Returns:

value of the ModelQuantity

get_x_rdata()[source]

Returns the expression that allows computation of x_rdata for this state, accounting for conservation laws.

Returns:

x_rdata expression

abstract has_conservation_law()[source]

Checks whether this state has a conservation law assigned.

Returns:

True if assigned, False otherwise

set_val(val)

Set ModelQuantity value

Returns:

value of the ModelQuantity