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 {
912  DYN_T,
913  DYN_X,
914  DYN_Z,
915  DYN_P,
916  DYN_U,
917  DYN_NUM_IN};
918 
920 enum DynOut {
921  DYN_ODE,
922  DYN_ALG,
923  DYN_QUAD,
924  DYN_ZERO,
925  DYN_NUM_OUT};
926 
928 enum EventIn {
929  EVENT_INDEX,
930  EVENT_T,
931  EVENT_X,
932  EVENT_Z,
933  EVENT_P,
934  EVENT_U,
935  EVENT_NUM_IN};
936 
938 enum EventOut {
939  EVENT_POST_X,
940  EVENT_POST_Z,
941  EVENT_NUM_OUT};
942 
944 enum IntegratorInput {
946  INTEGRATOR_X0,
948  INTEGRATOR_Z0,
950  INTEGRATOR_P,
952  INTEGRATOR_U,
954  INTEGRATOR_ADJ_XF,
956  INTEGRATOR_ADJ_ZF,
958  INTEGRATOR_ADJ_QF,
960  INTEGRATOR_NUM_IN
961 };
962 
964 enum IntegratorOutput {
966  INTEGRATOR_XF,
968  INTEGRATOR_ZF,
970  INTEGRATOR_QF,
972  INTEGRATOR_ADJ_X0,
974  INTEGRATOR_ADJ_Z0,
976  INTEGRATOR_ADJ_P,
978  INTEGRATOR_ADJ_U,
980  INTEGRATOR_NUM_OUT
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
Function object.
Definition: function.hpp:126
CASADI_EXPORT bool has_integrator(const std::string &name)
Check if an integrator plugin is available.
CASADI_EXPORT casadi_int integrator_n_out()
Get the number of integrator outputs.
CASADI_EXPORT casadi_int dyn_n_in()
Get the number of inputs of a DAE function.
CASADI_EXPORT std::vector< std::string > event_out()
Get the output scheme of an event transition function.
CASADI_EXPORT std::vector< std::string > dyn_out()
Get the output scheme of a DAE function.
CASADI_EXPORT std::vector< std::string > event_in()
Get the input scheme of an event transition function.
CASADI_EXPORT std::vector< std::string > integrator_in()
Get the input scheme of integrators.
CASADI_EXPORT void load_integrator(const std::string &name)
Explicitly load an integrator plugin.
CASADI_EXPORT casadi_int integrator_n_in()
Get the number of integrator inputs.
CASADI_EXPORT std::vector< std::string > integrator_out()
Get the output scheme of integrators.
CASADI_EXPORT std::vector< std::string > dyn_in()
Get the input scheme of a DAE function.
CASADI_EXPORT std::string doc_integrator(const std::string &name)
Get the documentation string of an integrator plugin.
CASADI_EXPORT casadi_int dyn_n_out()
Get the number of outputs of a DAE function.
CASADI_EXPORT Function integrator(const std::string &name, const std::string &solver, const SXDict &dae, const Dict &opts=Dict())
The casadi namespace.
Definition: archiver.hpp:32
std::map< std::string, MX > MXDict
Definition: mx.hpp:5151
std::map< std::string, SX > SXDict
Definition: sx_fwd.hpp:40
GenericType::Dict Dict
C++ equivalent of Python's dict or MATLAB's struct.