amici.de_export
C++ Export
This module provides all necessary functionality to specify a differential
equation 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()
.
Module Attributes
list of equations that have ids which may not be unique |
|
custom c++ function replacements |
|
python log manager |
Functions
Check whether x is a valid identifier for conditions, parameters, observables. |
Classes
|
The DEExporter class generates AMICI C++ files for a model as defined in symbolic expressions. |
- amici.de_export.CUSTOM_FUNCTIONS = [{'build_hint': 'Using polygamma requires libboost-math header files.', 'c++': 'boost::math::polygamma', 'include': '#include <boost/math/special_functions/polygamma.hpp>', 'sympy': 'polygamma'}, {'c++': 'amici::heaviside', 'sympy': 'Heaviside'}, {'c++': 'amici::dirac', 'sympy': 'DiracDelta'}]
custom c++ function replacements
- class amici.de_export.DEExporter(de_model, outdir=None, verbose=False, assume_pow_positivity=False, compiler=None, allow_reinit_fixpar_initcond=True, generate_sensitivity_code=True, model_name='model')[source]
The DEExporter class generates AMICI C++ files for a model as defined in symbolic expressions.
- Variables:
model – DE definition
verbose – more verbose output if True
assume_pow_positivity – if set to true, a special pow function is used to avoid problems with state variables that may become negative due to numerical errors
compiler – Absolute path to the compiler executable to be used to build the Python extension, e.g.
/usr/bin/clang
.functions – carries C++ function signatures and other specifications
model_name – name of the model that will be used for compilation
model_path – path to the generated model specific files
model_swig_path – path to the generated swig files
allow_reinit_fixpar_initcond – indicates whether reinitialization of initial states depending on fixedParameters is allowed for this model
_build_hints – If the given model uses special functions, this set contains hints for model building.
_code_printer – Code printer to generate C++ code
generate_sensitivity_code – Specifies whether code for sensitivity computation is to be generated
Note
When importing large models (several hundreds of species or parameters), import time can potentially be reduced by using multiple CPU cores. This is controlled by setting the
AMICI_IMPORT_NPROCS
environment variable to the number of parallel processes that are to be used (default: 1). Note that for small models this may (slightly) increase import times.- __init__(de_model, outdir=None, verbose=False, assume_pow_positivity=False, compiler=None, allow_reinit_fixpar_initcond=True, generate_sensitivity_code=True, model_name='model')[source]
Generate AMICI C++ files for the DE provided to the constructor.
- Parameters:
de_model (
amici.de_model.DEModel
) – DE model definitionoutdir (
pathlib.Path
|str
|None
) – seeamici.de_export.DEExporter.set_paths()
verbose (
bool
|int
|None
) – verbosity level for logging,True
/False
default tologging.Error
/logging.DEBUG
assume_pow_positivity (
bool
|None
) – if set to true, a special pow function is used to avoid problems with state variables that may become negative due to numerical errorscompiler (
str
|None
) – Absolute path to the compiler executable to be used to build the Python extension, e.g./usr/bin/clang
.allow_reinit_fixpar_initcond (
bool
|None
) – seeamici.de_export.DEExporter
generate_sensitivity_code (
bool
|None
) – specifies whether code required for sensitivity computation will be generatedmodel_name (
str
|None
) – name of the model to be used during code generation
- generate_model_code()[source]
Generates the native C++ code for the loaded model and a Matlab script that can be run to compile a mex file from the C++ code
- Return type:
- set_paths(output_dir=None)[source]
Set output paths for the model and create if necessary
- Parameters:
output_dir (
str
|pathlib.Path
|None
) – relative or absolute path where the generated model code is to be placed. IfNone
, this will default toamici-{self.model_name}
in the current working directory. will be created if it does not exist.- Return type:
- amici.de_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.de_export.logger = <Logger amici.de_export (ERROR)>
python log manager
- amici.de_export.non_unique_id_symbols = ['x_rdata', 'y']
list of equations that have ids which may not be unique