erk.hpp
1 /*
2  * This file is part of CasADi.
3  *
4  * CasADi -- A symbolic framework for dynamic optimization.
5  * Copyright (C) 2010-2026 Joel Andersson, Joris Gillis, Moritz Diehl,
6  * KU Leuven. All rights reserved.
7  * Copyright (C) 2011-2014 Greg Horn
8  *
9  * CasADi is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU Lesser General Public
11  * License as published by the Free Software Foundation; either
12  * version 3 of the License, or (at your option) any later version.
13  *
14  * CasADi is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17  * Lesser General Public License for more details.
18  *
19  * You should have received a copy of the GNU Lesser General Public
20  * License along with CasADi; if not, write to the Free Software
21  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22  *
23  */
24 
25 
26 #ifndef CASADI_ERK_HPP
27 #define CASADI_ERK_HPP
28 
29 #include "casadi/core/runtime_integrator.hpp"
30 #include <casadi/solvers/casadi_integrator_erk_export.h>
31 
55 namespace casadi {
56 
57  // Memory
58  struct CASADI_INTEGRATOR_ERK_EXPORT ErkMemory : public RuntimeIntegratorMemory {
59  // Method data, and of the nominal integration whose steps are replayed
61  };
62 
67  class CASADI_INTEGRATOR_ERK_EXPORT Erk : public RuntimeIntegrator {
68  public:
69 
71  Erk(const std::string& name, const Function& dae, double t0,
72  const std::vector<double>& tout);
73 
75  static Integrator* creator(const std::string& name, const Function& dae,
76  double t0, const std::vector<double>& tout) {
77  return new Erk(name, dae, t0, tout);
78  }
79 
81  ~Erk() override;
82 
83  // Get name of the plugin
84  const char* plugin_name() const override { return "erk";}
85 
86  // Get name of the class
87  std::string class_name() const override { return "Erk";}
88 
90 
91  static const Options options_;
92  const Options& get_options() const override { return options_;}
94 
96  void init(const Dict& opts) override;
97 
99  void set_work(void* mem, const double**& arg, double**& res,
100  casadi_int*& iw, double*& w) const override;
101 
103  void* alloc_mem() const override { return new ErkMemory();}
104 
106  void free_mem(void *mem) const override { delete static_cast<ErkMemory*>(mem);}
107 
109  static const std::string meta_doc;
110 
112  void serialize_body(SerializingStream &s) const override;
113 
115  static ProtoFunction* deserialize(DeserializingStream& s) { return new Erk(s); }
116 
117  protected:
118 
120  explicit Erk(DeserializingStream& s);
121 
122  // Explicit stages: no linearization
123  bool needs_jacobian() const override { return false;}
124 
125  // Call the kernel
126  int kernel(RuntimeIntegratorMemory* m) const override;
127 
128  // Generate code for the problem and data of the method
129  void codegen_method(CodeGenerator& g) const override;
130 
131  private:
132  // Method coefficients
133  void set_coefficients();
134 
135  // Problem structure of the method
136  void set_erk_prob();
138 
139  // Options
140  std::string method_;
141  };
142 
143 } // namespace casadi
144 
146 #endif // CASADI_ERK_HPP
Helper class for C code generation.
Helper class for Serialization.
'erk' plugin for Integrator
Definition: erk.hpp:67
const char * plugin_name() const override
Definition: erk.hpp:84
bool needs_jacobian() const override
Does the method linearize (tasks EVAL_JAC, EVAL_JAC_ADJ)?
Definition: erk.hpp:123
static Integrator * creator(const std::string &name, const Function &dae, double t0, const std::vector< double > &tout)
Create a new integrator.
Definition: erk.hpp:75
static ProtoFunction * deserialize(DeserializingStream &s)
Deserialize into MX.
Definition: erk.hpp:115
const Options & get_options() const override
Options.
Definition: erk.hpp:92
void free_mem(void *mem) const override
Free memory block.
Definition: erk.hpp:106
static const std::string meta_doc
A documentation string.
Definition: erk.hpp:109
std::string class_name() const override
Readable name of the internal class.
Definition: erk.hpp:87
void * alloc_mem() const override
Create memory block.
Definition: erk.hpp:103
static const Options options_
Options.
Definition: erk.hpp:91
Function object.
Definition: function.hpp:126
Internal storage for integrator related data.
Base class for FunctionInternal and LinsolInternal.
Base class of one-step integrators driven by a reverse communication kernel.
Helper class for Serialization.
The casadi namespace.
Definition: archiver.cpp:28
GenericType::Dict Dict
C++ equivalent of Python's dict or MATLAB's struct.
casadi_erk_data< double > e
Definition: erk.hpp:60
Options metadata for a class.
Definition: options.hpp:40