integrator.hpp
1 /*
2  * This file is part of CasADi.
3  *
4  * CasADi -- A symbolic framework for dynamic optimization.
5  * Copyright (C) 2010-2023 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_INTEGRATOR_HPP
27 #define CASADI_INTEGRATOR_HPP
28 
29 #include "function.hpp"
30 #include "linsol.hpp"
31 #include "rootfinder.hpp"
32 #include "casadi_enum.hpp"
33 
34 namespace casadi {
35 
86  CASADI_EXPORT Function integrator(const std::string& name, const std::string& solver,
87  const SXDict& dae, const Dict& opts=Dict());
88  CASADI_EXPORT Function integrator(const std::string& name, const std::string& solver,
89  const MXDict& dae, const Dict& opts=Dict());
90  CASADI_EXPORT Function integrator(const std::string& name, const std::string& solver,
91  const Function& dae, const Dict& opts=Dict());
92  CASADI_EXPORT Function integrator(const std::string& name, const std::string& solver,
93  const SXDict& dae, double t0, const std::vector<double>& tout, const Dict& opts=Dict());
94  CASADI_EXPORT Function integrator(const std::string& name, const std::string& solver,
95  const MXDict& dae, double t0, const std::vector<double>& tout, const Dict& opts=Dict());
96  CASADI_EXPORT Function integrator(const std::string& name, const std::string& solver,
97  const Function& dae, double t0, const std::vector<double>& tout, const Dict& opts=Dict());
98 #ifndef SWIGMATLAB
99  CASADI_EXPORT Function integrator(const std::string& name, const std::string& solver,
100  const SXDict& dae, double t0, double tf, const Dict& opts=Dict());
101  CASADI_EXPORT Function integrator(const std::string& name, const std::string& solver,
102  const MXDict& dae, double t0, double tf, const Dict& opts=Dict());
103  CASADI_EXPORT Function integrator(const std::string& name, const std::string& solver,
104  const Function& dae, double t0, double tf, const Dict& opts=Dict());
105 #endif // SWIGMATLAB
107 
109  CASADI_EXPORT bool has_integrator(const std::string& name);
110 
112  CASADI_EXPORT void load_integrator(const std::string& name);
113 
115  CASADI_EXPORT std::string doc_integrator(const std::string& name);
116 
120  CASADI_EXPORT std::vector<std::string> integrator_in();
121 
125  CASADI_EXPORT std::vector<std::string> integrator_out();
126 
130  CASADI_EXPORT std::string integrator_in(casadi_int ind);
131 
135  CASADI_EXPORT std::string integrator_out(casadi_int ind);
136 
140  CASADI_EXPORT casadi_int integrator_n_in();
141 
145  CASADI_EXPORT casadi_int integrator_n_out();
146 
150  CASADI_EXPORT std::vector<std::string> dyn_in();
151 
155  CASADI_EXPORT std::vector<std::string> dyn_out();
156 
160  CASADI_EXPORT std::string dyn_in(casadi_int ind);
161 
165  CASADI_EXPORT std::string dyn_out(casadi_int ind);
166 
170  CASADI_EXPORT casadi_int dyn_n_in();
171 
175  CASADI_EXPORT casadi_int dyn_n_out();
176 
180  CASADI_EXPORT std::vector<std::string> event_in();
181 
185  CASADI_EXPORT std::vector<std::string> event_out();
188 #ifndef SWIG
190 enum DynIn {
197 
199 enum DynOut {
205 
207 enum EventIn {
215 
217 enum EventOut {
221 
240 };
241 
260 };
261 
264 template<> struct enum_traits<DynIn> {
265  static const size_t n_enum = DYN_NUM_IN;
266 };
267 template<> struct enum_traits<DynOut> {
268  static const size_t n_enum = DYN_NUM_OUT;
269 };
270 template<> struct enum_traits<EventIn> {
271  static const size_t n_enum = EVENT_NUM_IN;
272 };
273 template<> struct enum_traits<EventOut> {
274  static const size_t n_enum = EVENT_NUM_OUT;
275 };
277 
280 CASADI_EXPORT std::string to_string(DynIn v);
281 CASADI_EXPORT std::string to_string(DynOut v);
282 CASADI_EXPORT std::string to_string(EventIn v);
283 CASADI_EXPORT std::string to_string(EventOut v);
285 
286 #endif // SWIG
287 
288 } // namespace casadi
289 
290 #endif // CASADI_INTEGRATOR_HPP
std::vector< std::string > dyn_out()
Get output scheme of a DAE function.
Definition: integrator.cpp:236
std::vector< std::string > event_in()
Get input scheme of an event transition function.
Definition: integrator.cpp:256
bool has_integrator(const std::string &name)
Check if a particular plugin is available.
Definition: integrator.cpp:122
std::vector< std::string > dyn_in()
Get input scheme of a DAE function.
Definition: integrator.cpp:232
casadi_int integrator_n_out()
Get the number of integrator outputs.
Definition: integrator.cpp:228
casadi_int dyn_n_in()
Get the number of inputs for a DAE function.
Definition: integrator.cpp:248
std::vector< std::string > integrator_out()
Get integrator output scheme of integrators.
Definition: integrator.cpp:190
std::vector< std::string > event_out()
Get output scheme of an event transition functions.
Definition: integrator.cpp:260
void load_integrator(const std::string &name)
Explicitly load a plugin dynamically.
Definition: integrator.cpp:126
casadi_int integrator_n_in()
Get the number of integrator inputs.
Definition: integrator.cpp:224
std::vector< std::string > integrator_in()
Get input scheme of integrators.
Definition: integrator.cpp:184
Function integrator(const std::string &name, const std::string &solver, const SXDict &dae, const Dict &opts)
Definition: integrator.cpp:134
std::string doc_integrator(const std::string &name)
Get the documentation string for a plugin.
Definition: integrator.cpp:130
casadi_int dyn_n_out()
Get the number of outputs for a DAE function.
Definition: integrator.cpp:252
The casadi namespace.
Definition: archiver.cpp:28
std::map< std::string, MX > MXDict
Definition: mx.hpp:1009
IntegratorOutput
Output arguments of an integrator.
Definition: integrator.hpp:243
@ INTEGRATOR_ADJ_U
Adjoint sensitivities corresponding to the control vector.
Definition: integrator.hpp:257
@ INTEGRATOR_ADJ_Z0
Adjoint sensitivities corresponding to the algebraic variable guess.
Definition: integrator.hpp:253
@ INTEGRATOR_QF
Quadrature state at all output times.
Definition: integrator.hpp:249
@ INTEGRATOR_ADJ_P
Adjoint sensitivities corresponding to the parameter vector.
Definition: integrator.hpp:255
@ INTEGRATOR_ZF
Algebraic variable at all output times.
Definition: integrator.hpp:247
@ INTEGRATOR_XF
Differential state at all output times.
Definition: integrator.hpp:245
@ INTEGRATOR_NUM_OUT
Number of output arguments of an integrator.
Definition: integrator.hpp:259
@ INTEGRATOR_ADJ_X0
Adjoint sensitivities corresponding to the initial state.
Definition: integrator.hpp:251
IntegratorInput
Input arguments of an integrator.
Definition: integrator.hpp:223
@ INTEGRATOR_U
Piecewise constant control, a new control interval starts at each output time.
Definition: integrator.hpp:231
@ INTEGRATOR_ADJ_QF
Adjoint seeds corresponding to the quadratures at the output times.
Definition: integrator.hpp:237
@ INTEGRATOR_ADJ_ZF
Adjoint seeds corresponding to the algebraic variables at the output times.
Definition: integrator.hpp:235
@ INTEGRATOR_P
Parameters.
Definition: integrator.hpp:229
@ INTEGRATOR_ADJ_XF
Adjoint seeds corresponding to the states at the output times.
Definition: integrator.hpp:233
@ INTEGRATOR_Z0
Initial guess for the algebraic variable at the initial time.
Definition: integrator.hpp:227
@ INTEGRATOR_NUM_IN
Number of input arguments of an integrator.
Definition: integrator.hpp:239
@ INTEGRATOR_X0
Differential state at the initial time.
Definition: integrator.hpp:225
EventIn
Inputs of an event transition function.
Definition: integrator.hpp:207
@ EVENT_INDEX
Definition: integrator.hpp:208
@ EVENT_NUM_IN
Definition: integrator.hpp:214
DynIn
Inputs of the symbolic representation of the DAE.
Definition: integrator.hpp:190
@ DYN_NUM_IN
Definition: integrator.hpp:196
EventOut
Outputs of an event transition function.
Definition: integrator.hpp:217
@ EVENT_POST_Z
Definition: integrator.hpp:219
@ EVENT_POST_X
Definition: integrator.hpp:218
@ EVENT_NUM_OUT
Definition: integrator.hpp:220
std::map< std::string, SX > SXDict
Definition: sx_fwd.hpp:40
GenericType::Dict Dict
C++ equivalent of Python's dict or MATLAB's struct.
DynOut
Outputs of the symbolic representation of the DAE.
Definition: integrator.hpp:199
@ DYN_NUM_OUT
Definition: integrator.hpp:204
std::string to_string(TypeFmi2 v)
Helper class: Specify number of entries in an enum.
Definition: casadi_enum.hpp:41
static const size_t n_enum
Definition: casadi_enum.hpp:42