roadrunner  2.6.0
Fast simulator for SBML models
NLEQSolver.h
1 //
2 // Created by Ciaran on 08/03/2021.
3 //
4 
5 #ifndef ROADRUNNER_NLEQSOLVER_H
6 #define ROADRUNNER_NLEQSOLVER_H
7 
8 #include "rrExporter.h"
9 #include "SteadyStateSolver.h"
10 #include "LLVMExecutableModel.h"
11 
12 namespace rr {
13 
17  class RR_DECLSPEC NLEQSolver : public SteadyStateSolver {
18  public:
19  using SteadyStateSolver::SteadyStateSolver;
20 
24  explicit NLEQSolver(ExecutableModel *model);
25 
26  ~NLEQSolver() override;
27 
32  void syncWithModel(ExecutableModel *m) override;
33 
34  void loadConfigSettings() override;
35 
39  void resetSettings() override;
40 
47  template<class NLEQSolverType>
48  double solveNLEQ() {
49 
50  int size = mModel->getStateVector(nullptr);
51  double* states = new double[size];
52  for (int i=0; i<size; i++)
53  states[i] = i;
54  mModel->getStateVector(states);
55 
56  delete[] states;
57 
58  auto nleq = std::unique_ptr<NLEQSolverType>( new NLEQSolverType(mModel));
59  rrLog(Logger::LOG_DEBUG) << "NLEQSolver::solve: " << std::endl;
60  nleq->allowPreSim = getValue("allow_presimulation");
61  nleq->preSimMaximumSteps = getValue("presimulation_maximum_steps");
62  nleq->preSimTime = getValue("presimulation_time");
63  nleq->allowApprox = getValue("allow_approx");
64  nleq->approxTolerance = getValue("approx_tolerance");
65  nleq->approxMaximumSteps = getValue("approx_maximum_steps");
66  nleq->approxTime = getValue("approx_time");
67  nleq->relativeTolerance = getValue("relative_tolerance");
68  nleq->maxIterations = getValue("maximum_iterations");
69  nleq->minDamping = getValue("minimum_damping");
70  nleq->broyden = getValue("broyden_method");
71  nleq->linearity = getValue("linearity");
72 
73  double result = nleq->solve();
74  return result;
75  }
76 
77  };
78 
79 }
80 
81 
82 #endif //ROADRUNNER_NLEQSOLVER_H
LLVM executable model interface.
Contains the base class for RoadRunner solvers.
Base class for all code generation systems; allows compiling and evaluating the model.
Definition: rrExecutableModel.h:118
Base class for NLEQ type steady state solvers.
Definition: NLEQSolver.h:17
double solveNLEQ()
main solver method.
Definition: NLEQSolver.h:48
SteadyStateSolver is an abstract base class that provides an interface to specific steady-state solve...
Definition: SteadyStateSolver.h:38
C_DECL_SPEC bool rrcCallConv getValue(RRHandle handle, const char *symbolId, double *value)
Get the value for a given symbol, use getAvailableTimeCourseSymbols(void) for a list of symbols.