1 /* 2 * This file is part of CasADi. 3 * 4 * CasADi -- A symbolic framework for dynamic optimization. 5 * Copyright (C) 2010-2014 Joel Andersson, Joris Gillis, Moritz Diehl, 6 * K.U. 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 33 /// \cond INTERNAL 34 namespace casadi { 35 /// Internal class 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 45 ///@{ 46 /** \brief Number of function inputs and outputs */ get_n_in()47 size_t get_n_in() override { return DPLE_NUM_IN;} get_n_out()48 size_t get_n_out() override { return DPLE_NUM_OUT;} 49 ///@} 50 51 /// @{ 52 /** \brief Sparsities of function inputs and outputs */ 53 Sparsity get_sparsity_in(casadi_int i) override; 54 Sparsity get_sparsity_out(casadi_int i) override; 55 /// @} 56 57 ///@{ 58 /** \brief Names of function input and outputs */ get_name_in(casadi_int i)59 std::string get_name_in(casadi_int i) override { return dple_in(i);} get_name_out(casadi_int i)60 std::string get_name_out(casadi_int i) override { return dple_out(i);} 61 /// @} 62 63 ///@{ 64 /** \brief Options */ 65 static const Options options_; get_options() const66 const Options& get_options() const override { return options_;} 67 ///@} 68 69 // Initialize 70 void init(const Dict& opts) override; 71 72 ///@{ 73 /** \brief Generate a function that calculates \a nfwd forward derivatives */ has_forward(casadi_int nfwd) const74 bool has_forward(casadi_int nfwd) const override { return true;} 75 Function get_forward(casadi_int nfwd, const std::string& name, 76 const std::vector<std::string>& inames, 77 const std::vector<std::string>& onames, 78 const Dict& opts) const override; 79 ///@} 80 81 ///@{ 82 /** \brief Generate a function that calculates \a nadj adjoint derivatives */ has_reverse(casadi_int nadj) const83 bool has_reverse(casadi_int nadj) const override { return true;} 84 Function get_reverse(casadi_int nadj, const std::string& name, 85 const std::vector<std::string>& inames, 86 const std::vector<std::string>& onames, 87 const Dict& opts) const override; 88 ///@} 89 90 // Creator function for internal class 91 typedef Dple* (*Creator)(const std::string& name, 92 const std::map<std::string, Sparsity>& st); 93 94 // No static functions exposed 95 struct Exposed{ }; 96 97 /// Collection of solvers 98 static std::map<std::string, Plugin> solvers_; 99 100 /// Infix 101 static const std::string infix_; 102 103 /// Short name shortname()104 static std::string shortname() { return "dple";} 105 106 protected: 107 108 /// List of sparsities of A_i 109 Sparsity A_; 110 111 /// List of sparsities of V_i 112 Sparsity V_; 113 114 /// Period 115 casadi_int K_; 116 117 /// Constant dimensions 118 bool const_dim_; 119 120 /// Assume positive definiteness of P_i 121 bool pos_def_; 122 123 /// Throw an error when system is unstable 124 bool error_unstable_; 125 126 /// Margin for instability detection 127 double eps_unstable_; 128 129 /// Number of right hand sides 130 casadi_int nrhs_; 131 132 }; 133 134 135 } // namespace casadi 136 /// \endcond 137 #endif // CASADI_DPLE_IMPL_HPP 138