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 
316  CASADI_EXPORT Function integrator(const std::string& name, const std::string& solver,
317  const SXDict& dae, const Dict& opts=Dict());
318  CASADI_EXPORT Function integrator(const std::string& name, const std::string& solver,
319  const MXDict& dae, const Dict& opts=Dict());
320  CASADI_EXPORT Function integrator(const std::string& name, const std::string& solver,
321  const Function& dae, const Dict& opts=Dict());
322  CASADI_EXPORT Function integrator(const std::string& name, const std::string& solver,
323  const SXDict& dae, double t0, const std::vector<double>& tout, const Dict& opts=Dict());
324  CASADI_EXPORT Function integrator(const std::string& name, const std::string& solver,
325  const MXDict& dae, double t0, const std::vector<double>& tout, const Dict& opts=Dict());
326  CASADI_EXPORT Function integrator(const std::string& name, const std::string& solver,
327  const Function& dae, double t0, const std::vector<double>& tout, const Dict& opts=Dict());
328 #ifndef SWIGMATLAB
329  CASADI_EXPORT Function integrator(const std::string& name, const std::string& solver,
330  const SXDict& dae, double t0, double tf, const Dict& opts=Dict());
331  CASADI_EXPORT Function integrator(const std::string& name, const std::string& solver,
332  const MXDict& dae, double t0, double tf, const Dict& opts=Dict());
333  CASADI_EXPORT Function integrator(const std::string& name, const std::string& solver,
334  const Function& dae, double t0, double tf, const Dict& opts=Dict());
335 #endif // SWIGMATLAB
337 
365  CASADI_EXPORT bool has_integrator(const std::string& name);
366 
402  CASADI_EXPORT void load_integrator(const std::string& name);
403 
430  CASADI_EXPORT std::string doc_integrator(const std::string& name);
431 
474  CASADI_EXPORT std::vector<std::string> integrator_in();
475 
518  CASADI_EXPORT std::vector<std::string> integrator_out();
519 
548  CASADI_EXPORT std::string integrator_in(casadi_int ind);
549 
578  CASADI_EXPORT std::string integrator_out(casadi_int ind);
579 
604  CASADI_EXPORT casadi_int integrator_n_in();
605 
630  CASADI_EXPORT casadi_int integrator_n_out();
631 
670  CASADI_EXPORT std::vector<std::string> dyn_in();
671 
720  CASADI_EXPORT std::vector<std::string> dyn_out();
721 
749  CASADI_EXPORT std::string dyn_in(casadi_int ind);
750 
778  CASADI_EXPORT std::string dyn_out(casadi_int ind);
779 
804  CASADI_EXPORT casadi_int dyn_n_in();
805 
830  CASADI_EXPORT casadi_int dyn_n_out();
831 
872  CASADI_EXPORT std::vector<std::string> event_in();
873 
906  CASADI_EXPORT std::vector<std::string> event_out();
909 #ifndef SWIG
911 enum DynIn {
918 
920 enum DynOut {
926 
928 enum EventIn {
936 
938 enum EventOut {
942 
961 };
962 
981 };
982 
985 template<> struct enum_traits<DynIn> {
986  static const size_t n_enum = DYN_NUM_IN;
987 };
988 template<> struct enum_traits<DynOut> {
989  static const size_t n_enum = DYN_NUM_OUT;
990 };
991 template<> struct enum_traits<EventIn> {
992  static const size_t n_enum = EVENT_NUM_IN;
993 };
994 template<> struct enum_traits<EventOut> {
995  static const size_t n_enum = EVENT_NUM_OUT;
996 };
998 
1001 CASADI_EXPORT std::string to_string(DynIn v);
1002 CASADI_EXPORT std::string to_string(DynOut v);
1003 CASADI_EXPORT std::string to_string(EventIn v);
1004 CASADI_EXPORT std::string to_string(EventOut v);
1006 
1007 #endif // SWIG
1008 
1009 } // namespace casadi
1010 
1011 #endif // CASADI_INTEGRATOR_HPP
std::vector< std::string > dyn_out()
Get the output scheme of a DAE function.
Definition: integrator.cpp:236
std::vector< std::string > event_in()
Get the input scheme of an event transition function.
Definition: integrator.cpp:256
bool has_integrator(const std::string &name)
Check if an integrator plugin is available.
Definition: integrator.cpp:122
std::vector< std::string > dyn_in()
Get the 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 of a DAE function.
Definition: integrator.cpp:248
std::vector< std::string > integrator_out()
Get the output scheme of integrators.
Definition: integrator.cpp:190
std::vector< std::string > event_out()
Get the output scheme of an event transition function.
Definition: integrator.cpp:260
void load_integrator(const std::string &name)
Explicitly load an integrator plugin.
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 the 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 of an integrator plugin.
Definition: integrator.cpp:130
casadi_int dyn_n_out()
Get the number of outputs of a DAE function.
Definition: integrator.cpp:252
The casadi namespace.
Definition: archiver.cpp:28
std::map< std::string, MX > MXDict
Definition: mx.hpp:5151
IntegratorOutput
Output arguments of an integrator.
Definition: integrator.hpp:964
@ INTEGRATOR_ADJ_U
Adjoint sensitivities corresponding to the control vector.
Definition: integrator.hpp:978
@ INTEGRATOR_ADJ_Z0
Adjoint sensitivities corresponding to the algebraic variable guess.
Definition: integrator.hpp:974
@ INTEGRATOR_QF
Quadrature state at all output times.
Definition: integrator.hpp:970
@ INTEGRATOR_ADJ_P
Adjoint sensitivities corresponding to the parameter vector.
Definition: integrator.hpp:976
@ INTEGRATOR_ZF
Algebraic variable at all output times.
Definition: integrator.hpp:968
@ INTEGRATOR_XF
Differential state at all output times.
Definition: integrator.hpp:966
@ INTEGRATOR_NUM_OUT
Number of output arguments of an integrator.
Definition: integrator.hpp:980
@ INTEGRATOR_ADJ_X0
Adjoint sensitivities corresponding to the initial state.
Definition: integrator.hpp:972
IntegratorInput
Input arguments of an integrator.
Definition: integrator.hpp:944
@ INTEGRATOR_U
Piecewise constant control, a new control interval starts at each output time.
Definition: integrator.hpp:952
@ INTEGRATOR_ADJ_QF
Adjoint seeds corresponding to the quadratures at the output times.
Definition: integrator.hpp:958
@ INTEGRATOR_ADJ_ZF
Adjoint seeds corresponding to the algebraic variables at the output times.
Definition: integrator.hpp:956
@ INTEGRATOR_P
Parameters.
Definition: integrator.hpp:950
@ INTEGRATOR_ADJ_XF
Adjoint seeds corresponding to the states at the output times.
Definition: integrator.hpp:954
@ INTEGRATOR_Z0
Initial guess for the algebraic variable at the initial time.
Definition: integrator.hpp:948
@ INTEGRATOR_NUM_IN
Number of input arguments of an integrator.
Definition: integrator.hpp:960
@ INTEGRATOR_X0
Differential state at the initial time.
Definition: integrator.hpp:946
EventIn
Inputs of an event transition function.
Definition: integrator.hpp:928
@ EVENT_INDEX
Definition: integrator.hpp:929
@ EVENT_NUM_IN
Definition: integrator.hpp:935
DynIn
Inputs of the symbolic representation of the DAE.
Definition: integrator.hpp:911
@ DYN_NUM_IN
Definition: integrator.hpp:917
EventOut
Outputs of an event transition function.
Definition: integrator.hpp:938
@ EVENT_POST_Z
Definition: integrator.hpp:940
@ EVENT_POST_X
Definition: integrator.hpp:939
@ EVENT_NUM_OUT
Definition: integrator.hpp:941
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:920
@ DYN_NUM_OUT
Definition: integrator.hpp:925
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