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_NLPSOL_HPP 27 #define CASADI_NLPSOL_HPP 28 29 #include "function.hpp" 30 31 namespace casadi { 32 33 /** \defgroup main_nlpsol 34 Create an NLP solver 35 Creates a solver for the following parametric nonlinear program (NLP): 36 \verbatim 37 38 min F(x, p) 39 x 40 41 subject to 42 LBX <= x <= UBX 43 LBG <= G(x, p) <= UBG 44 p == P 45 46 nx: number of decision variables 47 ng: number of constraints 48 np: number of parameters 49 50 \endverbatim 51 52 \generalsection{Nlpsol} 53 \pluginssection{Nlpsol} 54 55 \author Joel Andersson 56 \date 2011-2015 57 */ 58 59 /** \defgroup nlpsol 60 * @copydoc main_nlpsol 61 * @{ 62 */ 63 64 /** \if EXPANDED 65 * @copydoc main_nlpsol 66 * \endif 67 */ 68 ///@{ 69 CASADI_EXPORT Function nlpsol(const std::string& name, const std::string& solver, 70 const SXDict& nlp, const Dict& opts=Dict()); 71 CASADI_EXPORT Function nlpsol(const std::string& name, const std::string& solver, 72 const MXDict& nlp, const Dict& opts=Dict()); 73 CASADI_EXPORT Function nlpsol(const std::string& name, const std::string& solver, 74 const std::string& fname, const Dict& opts=Dict()); 75 CASADI_EXPORT Function nlpsol(const std::string& name, const std::string& solver, 76 const Importer& compiler, const Dict& opts=Dict()); 77 CASADI_EXPORT Function nlpsol(const std::string& name, const std::string& solver, 78 const NlpBuilder& nl, const Dict& opts=Dict()); 79 #ifndef SWIG 80 CASADI_EXPORT Function nlpsol(const std::string& name, const std::string& solver, 81 const Function& nlp, const Dict& opts=Dict()); 82 #endif // SWIG 83 ///@} 84 85 /** \brief Get input scheme of NLP solvers 86 * \if EXPANDED 87 * @copydoc scheme_NlpsolInput 88 * \endif 89 */ 90 CASADI_EXPORT std::vector<std::string> nlpsol_in(); 91 92 /** \brief Get NLP solver output scheme of NLP solvers 93 * \if EXPANDED 94 * @copydoc scheme_NlpsolOutput 95 * \endif 96 */ 97 CASADI_EXPORT std::vector<std::string> nlpsol_out(); 98 99 /** \brief Get NLP solver input scheme name by index 100 * \if EXPANDED 101 * @copydoc scheme_NlpsolInput 102 * \endif 103 */ 104 CASADI_EXPORT std::string nlpsol_in(casadi_int ind); 105 106 /** \brief Get output scheme name by index 107 * \if EXPANDED 108 * @copydoc scheme_NlpsolOutput 109 * \endif 110 */ 111 CASADI_EXPORT std::string nlpsol_out(casadi_int ind); 112 113 /** \brief Number of NLP solver inputs */ 114 CASADI_EXPORT casadi_int nlpsol_n_in(); 115 116 /** \brief Number of NLP solver outputs */ 117 CASADI_EXPORT casadi_int nlpsol_n_out(); 118 119 ///@{ 120 /** \brief Default input for an NLP solver */ 121 CASADI_EXPORT double nlpsol_default_in(casadi_int ind); 122 CASADI_EXPORT std::vector<double> nlpsol_default_in(); 123 ///@} 124 125 /** \brief Get all options for a plugin */ 126 CASADI_EXPORT std::vector<std::string> nlpsol_options(const std::string& name); 127 128 /** \brief Get type info for a particular option */ 129 CASADI_EXPORT std::string nlpsol_option_type(const std::string& name, const std::string& op); 130 131 /** \brief Get documentation for a particular option */ 132 CASADI_EXPORT std::string nlpsol_option_info(const std::string& name, const std::string& op); 133 134 /// Check if a particular plugin is available 135 CASADI_EXPORT bool has_nlpsol(const std::string& name); 136 137 /// Explicitly load a plugin dynamically 138 CASADI_EXPORT void load_nlpsol(const std::string& name); 139 140 /// Get the documentation string for a plugin 141 CASADI_EXPORT std::string doc_nlpsol(const std::string& name); 142 143 /** @} */ 144 145 #ifndef SWIG 146 /// Input arguments of an NLP function 147 enum NLPInput { 148 /// Decision variable 149 NL_X, 150 /// Fixed parameter 151 NL_P, 152 /// Number of NLP inputs 153 NL_NUM_IN 154 }; 155 156 /// Shortname for onput arguments of an NLP function 157 const std::vector<std::string> NL_INPUTS = {"x", "p"}; 158 159 /// Output arguments of an NLP function 160 enum NLPOutput { 161 /// Objective function 162 NL_F, 163 /// Constraint function 164 NL_G, 165 /// Number of NLP outputs 166 NL_NUM_OUT 167 }; 168 169 /// Shortname for output arguments of an NLP function 170 const std::vector<std::string> NL_OUTPUTS = {"f", "g"}; 171 172 /// Input arguments of an NLP Solver 173 enum NlpsolInput { 174 /// Decision variables, initial guess (nx x 1) 175 NLPSOL_X0, 176 /// Value of fixed parameters (np x 1) 177 NLPSOL_P, 178 /// Decision variables lower bound (nx x 1), default -inf 179 NLPSOL_LBX, 180 /// Decision variables upper bound (nx x 1), default +inf 181 NLPSOL_UBX, 182 /// Constraints lower bound (ng x 1), default -inf 183 NLPSOL_LBG, 184 /// Constraints upper bound (ng x 1), default +inf 185 NLPSOL_UBG, 186 /// Lagrange multipliers for bounds on X, initial guess (nx x 1) 187 NLPSOL_LAM_X0, 188 /// Lagrange multipliers for bounds on G, initial guess (ng x 1) 189 NLPSOL_LAM_G0, 190 NLPSOL_NUM_IN 191 }; 192 193 /// Output arguments of an NLP Solver 194 enum NlpsolOutput { 195 /// Decision variables at the optimal solution (nx x 1) 196 NLPSOL_X, 197 /// Cost function value at the optimal solution (1 x 1) 198 NLPSOL_F, 199 /// Constraints function at the optimal solution (ng x 1) 200 NLPSOL_G, 201 /// Lagrange multipliers for bounds on X at the solution (nx x 1) 202 NLPSOL_LAM_X, 203 /// Lagrange multipliers for bounds on G at the solution (ng x 1) 204 NLPSOL_LAM_G, 205 /// Lagrange multipliers for bounds on P at the solution (np x 1) 206 NLPSOL_LAM_P, 207 NLPSOL_NUM_OUT 208 }; 209 #endif // SWIG 210 211 } // namespace casadi 212 213 #endif // CASADI_NLPSOL_HPP 214