amici.ode_export
C++ Export
This module provides all necessary functionality specify an ODE model and
generate executable C++ simulation code. The user generally won’t have to
directly call any function from this module as this will be done by
amici.pysb_import.pysb2amici()
,
amici.sbml_import.SbmlImporter.sbml2amici()
and
amici.petab_import.import_model()
Classes
|
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 k |
|
An Event defines either a SBML event or a root of the argument of a Heaviside function. |
|
An Expressions is a recurring elements in symbolic formulas. |
|
A LogLikelihood defines the distance between measurements and experiments for a particular observable. |
|
Base class for model components |
|
The ODEExporter class generates AMICI C++ files for ODE model as defined in symbolic expressions. |
|
Defines an Ordinary Differential Equation as set of ModelQuantities. |
|
An Observable links model simulations to experimental measurements, abbreviated by y |
|
A Parameter is a free variable in the model with respect to which sensitivities may be computed, abbreviated by p |
|
A Standard Deviation SigmaY rescales the distance between simulations and measurements when computing residuals or objective functions, abbreviated by sigmay |
|
A State variable defines an entity that evolves with time according to the provided time derivative, abbreviated by x |
|
Template format used in AMICI (see string.template for more details). |
Functions Summary
|
Load source file, apply template substitution as provided in templateData and save as targetFile. |
|
Typecasts the value to sympy.Float if possible, and ensures the value is a symbolic expression. |
|
Generate identifier symbol for a reaction flux. |
|
Generates the appropriate measurement symbol for the provided observable |
|
Constructs the extern function declaration for a given function |
|
Constructs amici::Model::* override implementation for a given function |
|
Constructs the function declaration for an index function of a given function |
|
Constructs the amici::Model:: function implementation for an index function of a given function |
Check whether x is a valid identifier for conditions, parameters, observables. |
|
|
Strips typedef info from a function signature |
A faster implementation of sympy's is_zero_matrix |
|
|
Wrapper around symbolic jacobian with some additional checks that reduce computation time for large matrices |
|
Wrapper around symbolic multiplication with some additional checks that reduce computation time for large matrices |
|
Strips pysb info from a |
|
Central function to create symbols with consistent, canonical assumptions |
|
Checks if the values for a symbolic variable is passed in the signature of a function |
Functions
- amici.ode_export.apply_template(source_file, target_file, template_data)[source]
Load source file, apply template substitution as provided in templateData and save as targetFile.
- amici.ode_export.cast_to_sym(value, input_name)[source]
Typecasts the value to sympy.Float if possible, and ensures the value is a symbolic expression.
- Parameters
value (
typing.Union
[typing.SupportsFloat
,sympy.core.expr.Expr
,sympy.logic.boolalg.BooleanAtom
]) – value to be castinput_name (
str
) – name of input variable
- Return type
- Returns
typecast value
- amici.ode_export.generate_flux_symbol(reaction_index, name=None)[source]
Generate identifier symbol for a reaction flux. This function will always return the same unique python object for a given entity.
- Parameters
reaction_index (
int
) – index of the reaction to which the flux correspondsname (
typing.Optional
[str
]) – an optional identifier of the reaction to which the flux corresponds
- Return type
- Returns
identifier symbol
- amici.ode_export.generate_measurement_symbol(observable_id)[source]
Generates the appropriate measurement symbol for the provided observable
- Parameters
observable_id (
typing.Union
[str
,sympy.core.symbol.Symbol
]) – symbol (or string representation) of the observable- Returns
symbol for the corresponding measurement
- amici.ode_export.get_function_extern_declaration(fun, name)[source]
Constructs the extern function declaration for a given function
- amici.ode_export.get_model_override_implementation(fun, name, nobody=False)[source]
Constructs amici::Model::* override implementation for a given function
- amici.ode_export.get_sunindex_extern_declaration(fun, name, indextype)[source]
Constructs the function declaration for an index function of a given function
- amici.ode_export.get_sunindex_override_implementation(fun, name, indextype, nobody=False)[source]
Constructs the amici::Model:: function implementation for an index function of a given function
- amici.ode_export.is_valid_identifier(x)[source]
Check whether x is a valid identifier for conditions, parameters, observables… . Identifiers may only contain upper and lower case letters, digits and underscores, and must not start with a digit.
- amici.ode_export.smart_is_zero_matrix(x)[source]
A faster implementation of sympy’s is_zero_matrix
Avoids repeated indexer type checks and double iteration to distinguish False/None. Found to be about 100x faster for large matrices.
- Parameters
x (
typing.Union
[sympy.matrices.dense.MutableDenseMatrix
,sympy.matrices.sparse.MutableSparseMatrix
]) – Matrix to check- Return type
- amici.ode_export.smart_jacobian(eq, sym_var)[source]
Wrapper around symbolic jacobian with some additional checks that reduce computation time for large matrices
- Parameters
eq (
sympy.matrices.dense.MutableDenseMatrix
) – equationsym_var (
sympy.matrices.dense.MutableDenseMatrix
) – differentiation variable
- Return type
- Returns
jacobian of eq wrt sym_var
- amici.ode_export.smart_multiply(x, y)[source]
Wrapper around symbolic multiplication with some additional checks that reduce computation time for large matrices
- Parameters
x (
typing.Union
[sympy.matrices.dense.MutableDenseMatrix
,sympy.matrices.sparse.MutableSparseMatrix
]) – educt 1y (
sympy.matrices.dense.MutableDenseMatrix
) – educt 2
- Return type
typing.Union
[sympy.matrices.dense.MutableDenseMatrix
,sympy.matrices.sparse.MutableSparseMatrix
]- Returns
product
- amici.ode_export.strip_pysb(symbol)[source]
Strips pysb info from a
pysb.Component
object- Parameters
symbol (
sympy.core.basic.Basic
) – symbolic expression- Return type
- Returns
stripped expression
- amici.ode_export.symbol_with_assumptions(name)[source]
Central function to create symbols with consistent, canonical assumptions
- Parameters
name (
str
) – name of the symbol- Returns
symbol with canonical assumptions