dple_impl.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_DPLE_IMPL_HPP
27 #define CASADI_DPLE_IMPL_HPP
28 
29 #include "dple.hpp"
30 #include "function_internal.hpp"
31 #include "plugin_interface.hpp"
32 
34 namespace casadi {
36  class CASADI_EXPORT Dple : public FunctionInternal, public PluginInterface<Dple> {
37  public:
38 
39  // Constructor
40  Dple(const std::string& name, const SpDict &st);
41 
42  // Destructor
43  ~Dple() override = 0;
44 
46 
49  size_t get_n_in() override { return DPLE_NUM_IN;}
50  size_t get_n_out() override { return DPLE_NUM_OUT;}
52 
54 
57  Sparsity get_sparsity_in(casadi_int i) override;
58  Sparsity get_sparsity_out(casadi_int i) override;
60 
62 
65  std::string get_name_in(casadi_int i) override { return dple_in(i);}
66  std::string get_name_out(casadi_int i) override { return dple_out(i);}
68 
70 
73  static const Options options_;
74  const Options& get_options() const override { return options_;}
76 
77  // Initialize
78  void init(const Dict& opts) override;
79 
81 
84  bool has_forward(casadi_int nfwd) const override { return true;}
85  Function get_forward(casadi_int nfwd, const std::string& name,
86  const std::vector<std::string>& inames,
87  const std::vector<std::string>& onames,
88  const Dict& opts) const override;
90 
92 
95  bool has_reverse(casadi_int nadj) const override { return true;}
96  Function get_reverse(casadi_int nadj, const std::string& name,
97  const std::vector<std::string>& inames,
98  const std::vector<std::string>& onames,
99  const Dict& opts) const override;
101 
102  // Creator function for internal class
103  typedef Dple* (*Creator)(const std::string& name,
104  const std::map<std::string, Sparsity>& st);
105 
106  // No static functions exposed
107  struct Exposed{ };
108 
110  static std::map<std::string, Plugin> solvers_;
111 
112 #ifdef CASADI_WITH_THREADSAFE_SYMBOLICS
113  static std::mutex mutex_solvers_;
114 #endif // CASADI_WITH_THREADSAFE_SYMBOLICS
115 
117  static const std::string infix_;
118 
120  static std::string shortname() { return "dple";}
121 
122  protected:
123 
126 
129 
131  casadi_int K_;
132 
135 
137  bool pos_def_;
138 
141 
144 
146  casadi_int nrhs_;
147 
148  };
149 
150 
151 } // namespace casadi
153 #endif // CASADI_DPLE_IMPL_HPP
Internal class.
Definition: dple_impl.hpp:36
Sparsity A_
List of sparsities of A_i.
Definition: dple_impl.hpp:125
static std::map< std::string, Plugin > solvers_
Collection of solvers.
Definition: dple_impl.hpp:110
double eps_unstable_
Margin for instability detection.
Definition: dple_impl.hpp:143
size_t get_n_out() override
Number of function inputs and outputs.
Definition: dple_impl.hpp:50
static const std::string infix_
Infix.
Definition: dple_impl.hpp:117
bool error_unstable_
Throw an error when system is unstable.
Definition: dple_impl.hpp:140
casadi_int K_
Period.
Definition: dple_impl.hpp:131
bool const_dim_
Constant dimensions.
Definition: dple_impl.hpp:134
std::string get_name_out(casadi_int i) override
Names of function input and outputs.
Definition: dple_impl.hpp:66
static std::string shortname()
Short name.
Definition: dple_impl.hpp:120
size_t get_n_in() override
Number of function inputs and outputs.
Definition: dple_impl.hpp:49
bool has_reverse(casadi_int nadj) const override
Generate a function that calculates nadj adjoint derivatives.
Definition: dple_impl.hpp:95
casadi_int nrhs_
Number of right hand sides.
Definition: dple_impl.hpp:146
static const Options options_
Options.
Definition: dple_impl.hpp:73
bool has_forward(casadi_int nfwd) const override
Generate a function that calculates nfwd forward derivatives.
Definition: dple_impl.hpp:84
std::string get_name_in(casadi_int i) override
Names of function input and outputs.
Definition: dple_impl.hpp:65
Sparsity V_
List of sparsities of V_i.
Definition: dple_impl.hpp:128
const Options & get_options() const override
Options.
Definition: dple_impl.hpp:74
bool pos_def_
Assume positive definiteness of P_i.
Definition: dple_impl.hpp:137
Internal class for Function.
Function object.
Definition: function.hpp:60
Interface for accessing input and output data structures.
General sparsity class.
Definition: sparsity.hpp:106
std::vector< std::string > dple_in()
Get input scheme of DPLE solvers.
Definition: dple.cpp:102
std::vector< std::string > dple_out()
Get output scheme of DPLE solvers.
Definition: dple.cpp:108
The casadi namespace.
Definition: archiver.cpp:28
@ DPLE_NUM_IN
Definition: dple.hpp:124
@ DPLE_NUM_OUT
Number of arguments.
Definition: dple.hpp:132
GenericType::Dict Dict
C++ equivalent of Python's dict or MATLAB's struct.
std::map< std::string, Sparsity > SpDict
Definition: sparsity.hpp:1502
Options metadata for a class.
Definition: options.hpp:40