EulerIntegrator

class EulerIntegrator : public rr::Integrator

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.

This class also has two dummy variables, exampleParameter1 and exampleParameter2. These serve as examples of how to use the Dictionary interface to get/set various tuning paramters that an Integrator might have. These values will be displayed when the toString method is called, typically by Python.

An example of calling simulate in Python, and the results of specifying the parameters as keyword arguments is

r.simulate(integrator='euler', exampleParameter1=123456, exampleParameter2='some value');

print(r.integrator)
< roadrunner.EulerIntegrator()
{ 'this' : 0x101f28350
'exampleParameter1' : 123456
'exampleParameter2' : some value
}>

Public Functions

inline EulerIntegrator(ExecutableModel *m)

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
  • m – a borrowed reference to an existing ExecutableModel object.

  • o – a reference to a SimulatOptions object where the configuration parameters will be read from.

inline ~EulerIntegrator() override

delete any memory we allocated

inline virtual double integrate(double t0, double h) override

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.

inline void applyEvents(double timeEnd, std::vector<unsigned char> &previousEventStatus)
inline virtual void restart(double t0) override

This simple integrator has nothing to reset, so do nothing here.

inline virtual void setListener(IntegratorListenerPtr p) override

Clients may register a listener to listen for sbml events and time step events.

inline virtual IntegratorListenerPtr getListener() override

get the integrator listener

inline virtual std::string toString() const override

get a description of this object, compatable with python str

inline virtual std::string toRepr() const override

get a short descriptions of this object, compatable with python repr.

inline virtual std::string getName() const override

get the name of this integrator

inline virtual std::string getDescription() const override

Get the description for this integrator.

Author

JKM

Note

Delegates to getDescription

inline virtual std::string getHint() const override

Get the hint for this integrator.

Author

JKM

Note

Delegates to getHint

inline virtual Solver *construct(ExecutableModel *executableModel) const override

Constructs a new Solver of a given type.

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

Author

JKM, WBC

inline virtual IntegrationMethod getIntegrationMethod() const override

Always deterministic for Euler.

Author

JKM

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

sets the value for a key.

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

inline virtual Setting getItem(const std::string &key) const

Get a value.

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

inline virtual bool hasKey(const std::string &key) const

is there a key matching this name.

inline 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.

inline virtual std::vector<std::string> getKeys() const

list of keys in this object.

inline virtual void resetSettings() override

Reset all settings to their respective default values.

explicit Integrator(ExecutableModel *model)
Integrator()

Private Members

double exampleParameter1

a parameter which does nothing

std::string exampleParameter2

another parameter which does nothing

double *rateBuffer

two buffers to store the state std::vector rate, and new state std::vector

double *stateBufferBegin
double *stateBufferEnd
int stateVectorSize

size of state std::vector

std::vector<unsigned char> eventStatus
std::vector<unsigned char> previousEventStatus
IntegratorListenerPtr listener

Clients may register a listener to listen for time steps, or sbml events.

Time step events are much more usefull for variable time step integrators where they may take long time steps and clients may be notified when these occur.

This is a smart pointer to a object which implements the IntegratorListener interface.