roadrunner  2.6.0
Fast simulator for SBML models
Integrator.h
Go to the documentation of this file.
1 // == PREAMBLE ================================================
2 
3 // * Licensed under the Apache License, Version 2.0; see README
4 
5 // == FILEDOC =================================================
6 
14 # ifndef RR_INTEGRATOR_H_
15 # define RR_INTEGRATOR_H_
16 
17 #include "rrLogger.h"
18 #include "rrOSSpecifics.h"
19 #include "Dictionary.h"
20 #include "rrException.h"
21 #include "Solver.h"
22 
23 #include "tr1proxy/rr_memory.h"
24 #include "tr1proxy/rr_unordered_map.h"
25 #include "Registrable.h"
26 #include "RegistrationFactory.h"
27 #include <stdexcept>
28 
29 namespace rr {
30 
31  class Integrator;
32 
33  class ExecutableModel;
34 
39  public:
40 
44  virtual uint onTimeStep(Integrator *integrator, ExecutableModel *model, double time) = 0;
45 
49  virtual uint onEvent(Integrator *integrator, ExecutableModel *model, double time) = 0;
50 
51  virtual ~IntegratorListener() {};
52  };
53 
54  typedef cxx11_ns::shared_ptr<IntegratorListener> IntegratorListenerPtr;
55 
60  class RR_DECLSPEC Integrator : public Solver {
61  public:
62 
63  using Solver::Solver;
64 
70  using Solver::setValue;
71 
72  enum IntegrationMethod {
73  Deterministic,
74  Stochastic,
75  Hybrid,
76  Other
77  };
78 
79  explicit Integrator(ExecutableModel* model);
80 
81  Integrator();
82 
83  virtual ~Integrator() {};
84 
85  virtual IntegrationMethod getIntegrationMethod() const = 0;
86 
92  virtual void syncWithModel(ExecutableModel *m);
93 
94  virtual void loadConfigSettings();
95 
96  virtual void loadSBMLSettings(const std::string &filename);
97 
98  virtual double integrate(double t0, double hstep) = 0;
99 
100  virtual void restart(double t0) = 0;
101 
110  virtual void tweakTolerances();
111 
116  virtual void setIndividualTolerance(std::string sid, double value);
117 
118 
124  virtual std::vector<double> getAbsoluteToleranceVector();
125 
126 
127  /* CARRYOVER METHODS */
128  virtual void setListener(IntegratorListenerPtr) = 0;
129 
130  virtual IntegratorListenerPtr getListener() = 0;
131 
132  std::string toString() const;
133 
138  virtual std::string toRepr() const;
139  /* !-- END OF CARRYOVER METHODS */
140 
141  void setIntegrationStartTime(double time);
142 
143  protected:
144  double mIntegrationStartTime;
145 
146  };
147 
151  class IntegratorException : public std::runtime_error {
152  public:
153  explicit IntegratorException(const std::string &what) :
154  std::runtime_error(what) {
155  }
156 
157  explicit IntegratorException(const std::string &what, const std::string &where) :
158  std::runtime_error(what + "; In " + where) {
159  }
160  };
161 
162 }
163 
164 # endif /* RR_INTEGRATOR_H_ */
Contains the base class for RoadRunner solvers.
Base class for all code generation systems; allows compiling and evaluating the model.
Definition: rrExecutableModel.h:118
The exception class thrown by the Integrator.
Definition: Integrator.h:151
IntegratorListener listens for integrator events.
Definition: Integrator.h:38
virtual uint onEvent(Integrator *integrator, ExecutableModel *model, double time)=0
whenever model event occurs and after it is procesed.
virtual uint onTimeStep(Integrator *integrator, ExecutableModel *model, double time)=0
is called after the internal integrator completes each internal time step.
Integrator is an abstract base class that provides an interface to specific integrator class implemen...
Definition: Integrator.h:60
Base class for all integrators and steady state solvers.
Definition: Solver.h:39