amici.de_model_components
Objects for AMICI’s internal differential equation model representation
Classes
|
An AlgebraicEquation defines an algebraic equation. |
|
An AlgebraicState defines an entity that is algebraically determined |
|
A conservation law defines the absolute the total amount of a (weighted) sum of states |
|
A Constant is a fixed variable in the model with respect to which sensitivities cannot be computed, abbreviated by |
|
A State variable defines an entity that evolves with time according to the provided time derivative, abbreviated by |
|
An Event defines either a SBML event or a root of the argument of a Heaviside function. |
|
An Event Observable links model simulations to event related experimental measurements, abbreviated by |
|
An Expression is a recurring elements in symbolic formulas. |
|
A LogLikelihood defines the distance between measurements and experiments for a particular observable. |
|
Loglikelihood for event observables regularization |
|
Loglikelihood for observables |
|
Loglikelihood for event observables |
|
Base class for model components |
|
A NoiseParameter is an input variable for the computation of |
|
An Observable links model simulations to experimental measurements, abbreviated by |
|
A NoiseParameter is an input variable for the computation of |
|
A Parameter is a free variable in the model with respect to which sensitivities may be computed, abbreviated by |
|
A Standard Deviation Sigma rescales the distance between simulations and measurements when computing residuals or objective functions, abbreviated by |
|
Standard deviation for observables |
|
Standard deviation for event observables |
|
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 byformula == 0
- get_sym()
ModelQuantity symbol
- Return type:
- Returns:
Symbol of the ModelQuantity
- get_val()
ModelQuantity value
- Return type:
- 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:
symbol (
sympy.core.symbol.Symbol) – unique symbol of the AlgebraicStatename (
str) – individual name of the AlgebraicState (does not need to be unique)init (
sympy.core.expr.Expr) – initial value of the AlgebraicState
- get_dx_rdata_dx_solver(state_id)
Returns the expression that allows computation of
dx_rdata_dx_solverfor this state, accounting for conservation laws.- Returns:
dx_rdata_dx_solver expression
- get_sym()
ModelQuantity symbol
- Return type:
- Returns:
Symbol of the ModelQuantity
- get_val()
ModelQuantity value
- Return type:
- 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:
- 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:
symbol (
sympy.core.symbol.Symbol) – unique symbol of the ConservationLawname (
str) – individual name of the ConservationLaw (does not need to be unique)value (
sympy.core.expr.Expr) – formula (sum of states)coefficients (
dict[sympy.core.symbol.Symbol,sympy.core.expr.Expr]) – coefficients of the states in the sumstate_id (
sympy.core.symbol.Symbol) – Symbol of the state that this conservation law replaces
- 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:
- Returns:
normalized coefficient of the state
- get_sym()
ModelQuantity symbol
- Return type:
- Returns:
Symbol of the ModelQuantity
- get_val()
ModelQuantity value
- Return type:
- 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:
symbol (
sympy.core.symbol.Symbol) – unique symbol of the Constantname (
str) – individual name of the Constant (does not need to be unique)value (
numbers.Number) – numeric value
- get_sym()
ModelQuantity symbol
- Return type:
- Returns:
Symbol of the ModelQuantity
- get_val()
ModelQuantity value
- Return type:
- 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__()bydt- Parameters:
symbol (
sympy.core.symbol.Symbol) – unique symbol of the statename (
str) – individual name of the state (does not need to be unique)init (
sympy.core.expr.Expr) – initial valuedt (
sympy.core.expr.Expr) – time derivative
- get_dx_rdata_dx_solver(state_id)
Returns the expression that allows computation of
dx_rdata_dx_solverfor 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:
- Returns:
free symbols
- get_sym()
ModelQuantity symbol
- Return type:
- Returns:
Symbol of the ModelQuantity
- get_val()
ModelQuantity value
- Return type:
- 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:
- set_dt(dt)[source]
Sets the time derivative
- Parameters:
dt (
sympy.core.expr.Expr) – time derivative- Return type:
- 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
hduring 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 Eventname (
str) – individual name of the Event (does not need to be unique)value (
sympy.core.expr.Expr) – formula for the root / trigger functionassignments (
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 att==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_initial_value()[source]
Return the initial value for the root function.
- Return type:
- Returns:
initial value formula
- get_state_update(x, x_old)[source]
Get the state update (bolus) expression for the event assignment.
- Parameters:
x (
sympy.matrices.dense.MutableDenseMatrix) – The current state vector.x_old (
sympy.matrices.dense.MutableDenseMatrix) – The previous state vector. Ifuse_values_from_trigger_time=True, this is equal to x.
- Return type:
- Returns:
State-update matrix or
Noneif no state update is defined.
- get_sym()
ModelQuantity symbol
- Return type:
- 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:
- 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:
- get_val()
ModelQuantity value
- Return type:
- 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:
- set_val(val)
Set ModelQuantity value
- Returns:
value of the ModelQuantity
- 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:
symbol (
sympy.core.symbol.Symbol) – SeeObservable.__init__().name (
str) – SeeObservable.__init__().value (
sympy.core.expr.Expr) – SeeObservable.__init__().transformation (
amici.import_utils.ObservableTransformation|None) – SeeObservable.__init__().event (
sympy.core.symbol.Symbol) – Symbolic identifier of the corresponding event.
- get_event()[source]
Get the symbolic identifier of the corresponding event.
- Return type:
- Returns:
symbolic identifier
- get_measurement_symbol()
- Return type:
- get_regularization_symbol()
- Return type:
- get_sym()
ModelQuantity symbol
- Return type:
- Returns:
Symbol of the ModelQuantity
- get_val()
ModelQuantity value
- Return type:
- 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:
symbol (
sympy.core.symbol.Symbol) – unique symbol of the Expressionname (
str) – individual name of the Expression (does not need to be unique)value (
sympy.core.expr.Expr) – formula
- get_sym()
ModelQuantity symbol
- Return type:
- Returns:
Symbol of the ModelQuantity
- get_val()
ModelQuantity value
- Return type:
- 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:
symbol (
sympy.core.symbol.Symbol) – unique symbol of the LogLikelihoodname (
str) – individual name of the LogLikelihood (does not need to be unique)value (
sympy.core.expr.Expr) – formula
- get_sym()
ModelQuantity symbol
- Return type:
- Returns:
Symbol of the ModelQuantity
- get_val()
ModelQuantity value
- Return type:
- 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:
symbol (
sympy.core.symbol.Symbol) – unique symbol of the LogLikelihoodname (
str) – individual name of the LogLikelihood (does not need to be unique)value (
sympy.core.expr.Expr) – formula
- get_sym()
ModelQuantity symbol
- Return type:
- Returns:
Symbol of the ModelQuantity
- get_val()
ModelQuantity value
- Return type:
- 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:
symbol (
sympy.core.symbol.Symbol) – unique symbol of the LogLikelihoodname (
str) – individual name of the LogLikelihood (does not need to be unique)value (
sympy.core.expr.Expr) – formula
- get_sym()
ModelQuantity symbol
- Return type:
- Returns:
Symbol of the ModelQuantity
- get_val()
ModelQuantity value
- Return type:
- 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:
symbol (
sympy.core.symbol.Symbol) – Symbol of the quantity with unique identifier.name (
str) – individual name of the quantity (does not need to be unique)value (
typing.SupportsFloat|numbers.Number|sympy.core.expr.Expr) – either formula, numeric value or initial value
- class amici.de_model_components.NoiseParameter(symbol, name)[source]
A NoiseParameter is an input variable for the computation of
sigmathat can be specified in a data-point specific manner, abbreviated bynp. Only used for jax models.- __init__(symbol, name)[source]
Create a new Expression instance.
- Parameters:
symbol (
sympy.core.symbol.Symbol) – unique symbol of the NoiseParametername (
str) – individual name of the NoiseParameter (does not need to be unique)
- get_sym()
ModelQuantity symbol
- Return type:
- Returns:
Symbol of the ModelQuantity
- get_val()
ModelQuantity value
- Return type:
- 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:
symbol (
sympy.core.symbol.Symbol) – unique symbol of the Observablename (
str) – individual name of the Observable (does not need to be unique)value (
sympy.core.expr.Expr) – formulatransformation (
None|amici.import_utils.ObservableTransformation) – observable transformation, only applies when evaluating objective function or residuals
- get_sym()
ModelQuantity symbol
- Return type:
- Returns:
Symbol of the ModelQuantity
- get_val()
ModelQuantity value
- Return type:
- 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
ythat can be specified in a data-point specific manner, abbreviated byop. Only used for jax models.- __init__(symbol, name)[source]
Create a new Expression instance.
- Parameters:
symbol (
sympy.core.symbol.Symbol) – unique symbol of the ObservableParametername (
str) – individual name of the ObservableParameter (does not need to be unique)
- get_sym()
ModelQuantity symbol
- Return type:
- Returns:
Symbol of the ModelQuantity
- get_val()
ModelQuantity value
- Return type:
- 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:
symbol (
sympy.core.symbol.Symbol) – unique symbol of the Parametername (
str) – individual name of the Parameter (does not need to be unique)value (
numbers.Number) – numeric value
- get_sym()
ModelQuantity symbol
- Return type:
- Returns:
Symbol of the ModelQuantity
- get_val()
ModelQuantity value
- Return type:
- 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:
symbol (
sympy.core.symbol.Symbol) – unique symbol of the Standard Deviationname (
str) – individual name of the Standard Deviation (does not need to be unique)value (
sympy.core.expr.Expr) – formula
- get_sym()
ModelQuantity symbol
- Return type:
- Returns:
Symbol of the ModelQuantity
- get_val()
ModelQuantity value
- Return type:
- 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:
symbol (
sympy.core.symbol.Symbol) – unique symbol of the Standard Deviationname (
str) – individual name of the Standard Deviation (does not need to be unique)value (
sympy.core.expr.Expr) – formula
- get_sym()
ModelQuantity symbol
- Return type:
- Returns:
Symbol of the ModelQuantity
- get_val()
ModelQuantity value
- Return type:
- 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:
symbol (
sympy.core.symbol.Symbol) – Symbol of the quantity with unique identifier.name (
str) – individual name of the quantity (does not need to be unique)value (
typing.SupportsFloat|numbers.Number|sympy.core.expr.Expr) – either formula, numeric value or initial value
- get_dx_rdata_dx_solver(state_id)[source]
Returns the expression that allows computation of
dx_rdata_dx_solverfor this state, accounting for conservation laws.- Returns:
dx_rdata_dx_solver expression
- get_sym()
ModelQuantity symbol
- Return type:
- Returns:
Symbol of the ModelQuantity
- get_val()
ModelQuantity value
- Return type:
- 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