roadrunner  2.6.0
Fast simulator for SBML models
Public Member Functions | Friends | List of all members
rr::CVODEIntegrator Class Reference

A RoadRunner integrator based on CVODE; serves as RoadRunner's main integrator for ODEs. More...

#include <CVODEIntegrator.h>

Inheritance diagram for rr::CVODEIntegrator:
rr::Integrator rr::Solver rr::Registrable

Public Member Functions

 CVODEIntegrator (ExecutableModel *oModel)
 Constructor: takes an executable model, does not own the pointer. More...
 
 ~CVODEIntegrator () override
 Destructor. More...
 
void syncWithModel (ExecutableModel *m) override
 Called whenever a new model is loaded to allow integrator to reset internal state. More...
 
void loadConfigSettings () override
 It looks like this method only get used inside resetSettings.
 
void loadSBMLSettings (const std::string &filename) override
 Load an SBML settings file and apply the configuration options. More...
 
std::string getName () const override
 Get the name for this integrator. More...
 
std::string getDescription () const override
 Get the description for this integrator. More...
 
std::string getHint () const override
 Get the hint for this integrator. More...
 
Solverconstruct (ExecutableModel *executableModel) const override
 construct an instance of type CVODEIntegrator. More...
 
IntegrationMethod getIntegrationMethod () const override
 Always deterministic for CVODE. More...
 
void setValue (const std::string &setting, Setting value) override
 Sets the value of an integrator setting (e.g. absolute_tolerance) More...
 
void setMaxOrder (int newValue)
 sets the value of maximum order, which defaults to 12 for Adams (non-stiff) and 5 for BDF (Stiff). More...
 
void setIndividualTolerance (std::string sid, double value) override
 Sets tolerance for individual species. More...
 
void resetSettings () override
 Reset all integrator settings to their respective default values. More...
 
void tweakTolerances () override
 Fix tolerances for SBML tests. More...
 
double integrate (double t0, double hstep) override
 Main integration routine. More...
 
void restart (double timeStart) override
 Reset time to zero and reinitialize model. More...
 
IntegratorListenerPtr getListener () override
 Gets the integrator listener. More...
 
void setListener (IntegratorListenerPtr) override
 Sets the integrator listener. More...
 
void checkType () const
 Does a RT type check which throws if it fails, EVEN IF RTTI IS DISABLED. More...
 
void checkVectorSize (int expected, size_t real) const
 Does a size check which throws if it fails. More...
 
void checkIndex (int index, int size) const
 Does a index check which throws if it is out of bound. More...
 
std::string ToString (int val) const
 Converts integer to std::string for error print. More...
 
std::string ToString (size_t val) const
 Converts size_t to std::string for error print. More...
 
N_Vector getStateVector () const
 getter for the internal state std::vector
 
SUNNonlinearSolver getSolver () const
 getter for the internal Sundials linear solver object
 
void * getCvodeMemory () const
 getter for the internal CVode memory buffer
 
std::vector< double > getAbsoluteToleranceVector () override
 Get the absolute tolerance vector for the solver. More...
 
 Integrator (ExecutableModel *model)
 
 Integrator ()
 
- Public Member Functions inherited from rr::Integrator
 Integrator (ExecutableModel *model)
 
std::string toString () const
 Return a std::string representation of the solver. More...
 
virtual std::string toRepr () const
 Return std::string representation a la Python repr method. More...
 
void setIntegrationStartTime (double time)
 
 Solver ()=default
 
 Solver (ExecutableModel *model)
 
virtual void setValue (const std::string &key, Setting value)
 Pull down the setValue from superclass. More...
 
- Public Member Functions inherited from rr::Solver
 Solver (ExecutableModel *model)
 
void updateSettings (Dictionary *inputSettings)
 Update settings values. More...
 
std::vector< std::string > getSettings () const
 Get a list of all settings for this solver. More...
 
std::unordered_map< std::string, Setting > & getSettingsMap ()
 get settings for this solver More...
 
virtual Setting getValue (const std::string &key) const
 Get the value of an integrator setting. More...
 
virtual Setting hasValue (const std::string &key) const
 Return true if this setting is supported by the integrator. More...
 
virtual size_t getNumParams () const
 Get the number of parameters. More...
 
virtual std::string getParamName (size_t n) const
 Get the name of the parameter at index n. More...
 
virtual std::string getParamDisplayName (int n) const
 Get the display name of the parameter at index n. More...
 
virtual std::string getParamHint (int n) const
 Get the hint of the parameter at index n. More...
 
virtual std::string getParamDesc (int n) const
 Get the description of the parameter at index n. More...
 
virtual std::string getValueAsString (const std::string &key)
 Wrapper for getValue which converts output to a specific type. More...
 
virtual std::string getSettingsRepr () const
 Get the solver settings as a std::string. More...
 
virtual std::string settingsPyDictRepr () const
 Python dictionary-style std::string representation of settings. More...
 
const std::string & getDisplayName (const std::string &key) const
 Gets the hint associated with a given key. More...
 
const std::string & getHint (const std::string &key) const
 Gets the hint associated with a given key. More...
 
const std::string & getDescription (const std::string &key) const
 Gets the description associated with a given key. More...
 
Setting::TypeId getType (const std::string &key) const
 Gets the type associated with a given key. More...
 
virtual ExecutableModelgetModel () const
 returns the pointer to the ExecutableModel
 
virtual std::string getName () const=0
 Gets the name associated with this Solver type. More...
 
virtual std::string getHint () const=0
 Gets the hint associated with this Solver type. More...
 
virtual std::string getDescription () const=0
 Gets the description associated with this Solver type. More...
 

Friends

class ForwardSensitivitySolver
 
int cvodeDyDtFcn (double t, N_Vector cv_y, N_Vector cv_ydot, void *f_data)
 
int cvodeEventAndPiecewiseRootFcn (double t, N_Vector y, double *gout, void *g_data)
 

Additional Inherited Members

- Public Types inherited from rr::Integrator
enum  IntegrationMethod { Deterministic , Stochastic , Hybrid , Other }
 
- Public Types inherited from rr::Solver
using SettingsList = std::vector< std::string >
 
using SettingsMap = std::unordered_map< std::string, Setting >
 
using DisplayNameMap = std::unordered_map< std::string, std::string >
 
using HintMap = std::unordered_map< std::string, std::string >
 
using DescriptionMap = std::unordered_map< std::string, std::string >
 
- Public Attributes inherited from rr::Solver
SettingsList sorted_settings
 
SettingsMap settings
 
DisplayNameMap display_names_
 
HintMap hints
 
DescriptionMap descriptions
 
- Protected Member Functions inherited from rr::Solver
void addSetting (const std::string &name, const Setting &val, const std::string &display_name, const std::string &hint, const std::string &description)
 
- Protected Attributes inherited from rr::Integrator
double mIntegrationStartTime
 
- Protected Attributes inherited from rr::Solver
ExecutableModelmModel = nullptr
 non-owning pointer to model
 

Detailed Description

A RoadRunner integrator based on CVODE; serves as RoadRunner's main integrator for ODEs.

Author
WBC, ETS, MTK

Provides a wrapper around CVODE from the SUNDIALS suite. CVODE has two main solvers: an Adams-Moulton solver for non-stiff problems, and a backward differentiation formula (BDF) solver for stiff problems. See: https://computation.llnl.gov/casc/sundials/documentation/toms_sundials.pdf

Constructor & Destructor Documentation

◆ CVODEIntegrator()

rr::CVODEIntegrator::CVODEIntegrator ( ExecutableModel oModel)
explicit

Constructor: takes an executable model, does not own the pointer.

Author
WBC, ETS, MTK

◆ ~CVODEIntegrator()

rr::CVODEIntegrator::~CVODEIntegrator ( )
override

Destructor.

Author
WBC, ETS, MTK

Member Function Documentation

◆ checkIndex()

void rr::CVODEIntegrator::checkIndex ( int  index,
int  size 
) const

Does a index check which throws if it is out of bound.

Author
FY

◆ checkType()

void rr::CVODEIntegrator::checkType ( ) const

Does a RT type check which throws if it fails, EVEN IF RTTI IS DISABLED.

Author
JKM

◆ checkVectorSize()

void rr::CVODEIntegrator::checkVectorSize ( int  expected,
size_t  real 
) const

Does a size check which throws if it fails.

Author
FY

◆ construct()

Solver * rr::CVODEIntegrator::construct ( ExecutableModel executableModel) const
overridevirtual

construct an instance of type CVODEIntegrator.

implements the Registrar interface. Used in factory creation of Integrators.

Implements rr::Registrable.

◆ getAbsoluteToleranceVector()

vector< double > rr::CVODEIntegrator::getAbsoluteToleranceVector ( )
overridevirtual

Get the absolute tolerance vector for the solver.

The absolute tolerance vector is either set directly by the user as a vector, or is generated from the single absolute tolerance value (either default or set by the user) multiplied by the initial value of every element in the state vector (independent floating species, and elements controlled by rate rules). If that initial value is zero, the corresponding element of the absolute tolerance vector is the single value multiplied by the compartment volume for species, or by one for all other values.

Reimplemented from rr::Integrator.

◆ getDescription()

std::string rr::CVODEIntegrator::getDescription ( ) const
overridevirtual

Get the description for this integrator.

Author
WBC
Note
Delegates to getDescription

Implements rr::Registrable.

◆ getHint()

std::string rr::CVODEIntegrator::getHint ( ) const
overridevirtual

Get the hint for this integrator.

Author
WBC
Note
Delegates to getHint

Implements rr::Registrable.

◆ getIntegrationMethod()

Integrator::IntegrationMethod rr::CVODEIntegrator::getIntegrationMethod ( ) const
overridevirtual

Always deterministic for CVODE.

Author
WBC, ETS, MTK

Implements rr::Integrator.

◆ getListener()

IntegratorListenerPtr rr::CVODEIntegrator::getListener ( )
overridevirtual

Gets the integrator listener.

Author
WBC, ETS

Implements rr::Integrator.

◆ getName()

std::string rr::CVODEIntegrator::getName ( ) const
overridevirtual

Get the name for this integrator.

Author
WBC
Note
Delegates to getName

Implements rr::Registrable.

◆ integrate()

double rr::CVODEIntegrator::integrate ( double  t0,
double  hstep 
)
overridevirtual

Main integration routine.

Author
WBC, ETS, MTK

Implements rr::Integrator.

◆ loadSBMLSettings()

void rr::CVODEIntegrator::loadSBMLSettings ( const std::string &  filename)
overridevirtual

Load an SBML settings file and apply the configuration options.

Author
WBC
Note
Can assign relative and absolute tolerances

Reimplemented from rr::Integrator.

◆ resetSettings()

void rr::CVODEIntegrator::resetSettings ( )
overridevirtual

Reset all integrator settings to their respective default values.

Author
JKM

Reimplemented from rr::Solver.

◆ restart()

void rr::CVODEIntegrator::restart ( double  timeStart)
overridevirtual

Reset time to zero and reinitialize model.

Author
WBC, ETS, MTK

Applies events which occur before time zero. Reinitializes CVODE and the executable model.

Implements rr::Integrator.

◆ setIndividualTolerance()

void rr::CVODEIntegrator::setIndividualTolerance ( std::string  sid,
double  value 
)
overridevirtual

Sets tolerance for individual species.

Author
FY

Reimplemented from rr::Integrator.

◆ setListener()

void rr::CVODEIntegrator::setListener ( IntegratorListenerPtr  p)
overridevirtual

Sets the integrator listener.

Author
WBC, ETS

Implements rr::Integrator.

◆ setMaxOrder()

void rr::CVODEIntegrator::setMaxOrder ( int  newValue)

sets the value of maximum order, which defaults to 12 for Adams (non-stiff) and 5 for BDF (Stiff).

Once a CVODEIntegrator has been created, increasing the order value beyond the original value is not possible (because the underlying sundials objects require more memory). Attempts to do so will simply be ignored.

◆ setValue()

void rr::CVODEIntegrator::setValue ( const std::string &  setting,
Setting  value 
)
overridevirtual

Sets the value of an integrator setting (e.g. absolute_tolerance)

Author
WBC, ETS, MTK

Values and keys are stored in the settings std::map, which is updated in every call to setValue. In addition, changing CVODE-specific parameters requires a call into the CVODE library to synchronize CVODE's internal memory with the settings std::map.

The default value is ADAMS Q MAX = 12 for the Adams-Moulton method and BDF Q MAX = 5 for the BDF method. Since maxord affects the memory requirements for the internal cvodes memory block, its value cannot be increased past its previous value.

Reimplemented from rr::Solver.

◆ syncWithModel()

void rr::CVODEIntegrator::syncWithModel ( ExecutableModel m)
overridevirtual

Called whenever a new model is loaded to allow integrator to reset internal state.

Author
JKM

Reimplemented from rr::Integrator.

◆ ToString() [1/2]

std::string rr::CVODEIntegrator::ToString ( int  val) const

Converts integer to std::string for error print.

Author
FY

◆ ToString() [2/2]

std::string rr::CVODEIntegrator::ToString ( size_t  val) const

Converts size_t to std::string for error print.

Author
LPS

◆ tweakTolerances()

void rr::CVODEIntegrator::tweakTolerances ( )
overridevirtual

Fix tolerances for SBML tests.

Author
JKM, WBC, ETS, MTK

In order to ensure that the results of the SBML test suite remain valid, this method enforces a lower bound on tolerance values. Sets minimum absolute and relative tolerances to Config::CVODE_MIN_ABSOLUTE and Config::CVODE_MIN_RELATIVE resp.

Reimplemented from rr::Integrator.


The documentation for this class was generated from the following files: