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

An example class intended to show how to create an Integrator. More...

#include <EulerIntegrator.h>

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

Public Member Functions

 EulerIntegrator (ExecutableModel *m)
 Creates a new EulerIntegrator. More...
 
 ~EulerIntegrator () override
 delete any memory we allocated
 
virtual double integrate (double t0, double h) override
 integrates the model from t0 to t0 + hstep More...
 
void applyEvents (double timeEnd, std::vector< unsigned char > &previousEventStatus)
 
virtual void restart (double t0) override
 This simple integrator has nothing to reset, so do nothing here.
 
virtual void setListener (IntegratorListenerPtr p) override
 Clients may register a listener to listen for sbml events and time step events.
 
virtual IntegratorListenerPtr getListener () override
 get the integrator listener
 
virtual std::string toString () const override
 get a description of this object, compatable with python str
 
virtual std::string toRepr () const override
 get a short descriptions of this object, compatable with python repr.
 
std::string getName () const override
 get the name of this integrator
 
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
 Constructs a new Solver of a given type. More...
 
IntegrationMethod getIntegrationMethod () const override
 Always deterministic for Euler. More...
 
virtual void setItem (const std::string &key, const rr::Setting &value)
 sets the value for a key. More...
 
virtual Setting getItem (const std::string &key) const
 Get a value. More...
 
virtual bool hasKey (const std::string &key) const
 is there a key matching this name.
 
virtual int deleteItem (const std::string &key)
 remove a value, this example class does not support deleting keys, so just raise an exception if someone tries to do so.
 
virtual std::vector< std::string > getKeys () const
 list of keys in this object.
 
void resetSettings () override
 Reset all settings to their respective default values.
 
 Integrator (ExecutableModel *model)
 
 Integrator ()
 
- Public Member Functions inherited from rr::Integrator
 Integrator (ExecutableModel *model)
 
virtual void syncWithModel (ExecutableModel *m)
 Called whenever a new model is loaded to allow integrator to reset internal state. More...
 
virtual void loadConfigSettings ()
 
virtual void loadSBMLSettings (const std::string &filename)
 
virtual void tweakTolerances ()
 Fix tolerances for SBML tests. More...
 
virtual void setIndividualTolerance (std::string sid, double value)
 Set tolerance for floating species or variables that have a rate rule, will only be used in CVODEIntegrator. More...
 
virtual std::vector< double > getAbsoluteToleranceVector ()
 Get the absolute tolerance vector for the solver. More...
 
std::string toString () const
 Return a std::string representation of the solver. 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 void setValue (const std::string &key, Setting value)
 
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...
 

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

An example class intended to show how to create an Integrator.

This class implements the most basic possible integration algorithm: the forward Euler method.

This integrator should not really be used in practice as the forward Euler algorithm is highly unstable and will seldomly yield numerically correct values.

An example of calling simulate in Python is

rr.setIntegrator('euler')
rr.simulate();
print(rr.integrator)
< roadrunner.EulerIntegrator()
{ 'this' : 0x101f28350
}>

Constructor & Destructor Documentation

◆ EulerIntegrator()

rr::EulerIntegrator::EulerIntegrator ( ExecutableModel m)
inline

Creates a new EulerIntegrator.

The IntegratorFactory is the ONLY object that creates integrators.

Integrators are created when the IntegratorFactory::New method is called, typically by the top level RoadRunner object.

The integrator will hold onto the ExecutableModel pointer, m, and when the integrate method is called, will advance the model object forward in time.

Parameters
ma borrowed reference to an existing ExecutableModel object.

Member Function Documentation

◆ construct()

Solver* rr::EulerIntegrator::construct ( ExecutableModel model) const
inlineoverridevirtual

Constructs a new Solver of a given type.

Author
JKM, WBC

the caller is responsible for deleting memory associated with the returned Solver*.

Implements rr::Registrable.

◆ getDescription()

std::string rr::EulerIntegrator::getDescription ( ) const
inlineoverridevirtual

Get the description for this integrator.

Author
JKM
Note
Delegates to getDescription

Implements rr::Registrable.

◆ getHint()

std::string rr::EulerIntegrator::getHint ( ) const
inlineoverridevirtual

Get the hint for this integrator.

Author
JKM
Note
Delegates to getHint

Implements rr::Registrable.

◆ getIntegrationMethod()

IntegrationMethod rr::EulerIntegrator::getIntegrationMethod ( ) const
inlineoverridevirtual

Always deterministic for Euler.

Author
JKM

Implements rr::Integrator.

◆ getItem()

virtual Setting rr::EulerIntegrator::getItem ( const std::string &  key) const
inlinevirtual

Get a value.

This integrator only supports two parameters, those are the only valid ones to get.

◆ integrate()

virtual double rr::EulerIntegrator::integrate ( double  t0,
double  h 
)
inlineoverridevirtual

integrates the model from t0 to t0 + hstep

In this implementation, this performs a basic forward Euler step. This method also demonstrates how to notify the listener that a timestep has completed.

Returns
the end time.

Implements rr::Integrator.

◆ setItem()

virtual void rr::EulerIntegrator::setItem ( const std::string &  key,
const rr::Setting value 
)
inlinevirtual

sets the value for a key.

This integrator only supports 2 values, so those are the only two valid items to set.


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