Ipopt
trunk
|
00001 // Copyright (C) 2004, 2006 International Business Machines and others. 00002 // All Rights Reserved. 00003 // This code is published under the Eclipse Public License. 00004 // 00005 // $Id$ 00006 // 00007 // Authors: Carl Laird, Andreas Waechter IBM 2004-08-13 00008 00009 #ifndef __IPNLP_HPP__ 00010 #define __IPNLP_HPP__ 00011 00012 #include "IpUtils.hpp" 00013 #include "IpVector.hpp" 00014 #include "IpSmartPtr.hpp" 00015 #include "IpMatrix.hpp" 00016 #include "IpSymMatrix.hpp" 00017 #include "IpOptionsList.hpp" 00018 #include "IpAlgTypes.hpp" 00019 #include "IpReturnCodes.hpp" 00020 00021 namespace Ipopt 00022 { 00023 // forward declarations 00024 class IpoptData; 00025 class IpoptCalculatedQuantities; 00026 class IteratesVector; 00027 00031 class NLP : public ReferencedObject 00032 { 00033 public: 00037 NLP() 00038 {} 00039 00041 virtual ~NLP() 00042 {} 00044 00047 DECLARE_STD_EXCEPTION(USER_SCALING_NOT_IMPLEMENTED); 00048 DECLARE_STD_EXCEPTION(INVALID_NLP); 00050 00056 virtual bool ProcessOptions(const OptionsList& options, 00057 const std::string& prefix) 00058 { 00059 return true; 00060 } 00061 00065 virtual bool GetSpaces(SmartPtr<const VectorSpace>& x_space, 00066 SmartPtr<const VectorSpace>& c_space, 00067 SmartPtr<const VectorSpace>& d_space, 00068 SmartPtr<const VectorSpace>& x_l_space, 00069 SmartPtr<const MatrixSpace>& px_l_space, 00070 SmartPtr<const VectorSpace>& x_u_space, 00071 SmartPtr<const MatrixSpace>& px_u_space, 00072 SmartPtr<const VectorSpace>& d_l_space, 00073 SmartPtr<const MatrixSpace>& pd_l_space, 00074 SmartPtr<const VectorSpace>& d_u_space, 00075 SmartPtr<const MatrixSpace>& pd_u_space, 00076 SmartPtr<const MatrixSpace>& Jac_c_space, 00077 SmartPtr<const MatrixSpace>& Jac_d_space, 00078 SmartPtr<const SymMatrixSpace>& Hess_lagrangian_space)=0; 00079 00081 virtual bool GetBoundsInformation(const Matrix& Px_L, 00082 Vector& x_L, 00083 const Matrix& Px_U, 00084 Vector& x_U, 00085 const Matrix& Pd_L, 00086 Vector& d_L, 00087 const Matrix& Pd_U, 00088 Vector& d_U)=0; 00089 00093 virtual bool GetStartingPoint( 00094 SmartPtr<Vector> x, 00095 bool need_x, 00096 SmartPtr<Vector> y_c, 00097 bool need_y_c, 00098 SmartPtr<Vector> y_d, 00099 bool need_y_d, 00100 SmartPtr<Vector> z_L, 00101 bool need_z_L, 00102 SmartPtr<Vector> z_U, 00103 bool need_z_U 00104 )=0; 00105 00109 virtual bool GetWarmStartIterate(IteratesVector& warm_start_iterate) 00110 { 00111 return false; 00112 } 00114 00118 virtual bool Eval_f(const Vector& x, Number& f) = 0; 00119 00120 virtual bool Eval_grad_f(const Vector& x, Vector& g_f) = 0; 00121 00122 virtual bool Eval_c(const Vector& x, Vector& c) = 0; 00123 00124 virtual bool Eval_jac_c(const Vector& x, Matrix& jac_c) = 0; 00125 00126 virtual bool Eval_d(const Vector& x, Vector& d) = 0; 00127 00128 virtual bool Eval_jac_d(const Vector& x, Matrix& jac_d) = 0; 00129 00130 virtual bool Eval_h(const Vector& x, 00131 Number obj_factor, 00132 const Vector& yc, 00133 const Vector& yd, 00134 SymMatrix& h) = 0; 00136 00145 virtual void FinalizeSolution(SolverReturn status, 00146 const Vector& x, const Vector& z_L, 00147 const Vector& z_U, 00148 const Vector& c, const Vector& d, 00149 const Vector& y_c, const Vector& y_d, 00150 Number obj_value, 00151 const IpoptData* ip_data, 00152 IpoptCalculatedQuantities* ip_cq) 00153 {} 00154 00170 virtual bool IntermediateCallBack(AlgorithmMode mode, 00171 Index iter, Number obj_value, 00172 Number inf_pr, Number inf_du, 00173 Number mu, Number d_norm, 00174 Number regularization_size, 00175 Number alpha_du, Number alpha_pr, 00176 Index ls_trials, 00177 const IpoptData* ip_data, 00178 IpoptCalculatedQuantities* ip_cq) 00179 { 00180 return true; 00181 } 00183 00188 virtual void GetScalingParameters( 00189 const SmartPtr<const VectorSpace> x_space, 00190 const SmartPtr<const VectorSpace> c_space, 00191 const SmartPtr<const VectorSpace> d_space, 00192 Number& obj_scaling, 00193 SmartPtr<Vector>& x_scaling, 00194 SmartPtr<Vector>& c_scaling, 00195 SmartPtr<Vector>& d_scaling) const 00196 { 00197 THROW_EXCEPTION(USER_SCALING_NOT_IMPLEMENTED, 00198 "You have set options for user provided scaling, but have" 00199 " not implemented GetScalingParameters in the NLP interface"); 00200 } 00202 00216 virtual void 00217 GetQuasiNewtonApproximationSpaces(SmartPtr<VectorSpace>& approx_space, 00218 SmartPtr<Matrix>& P_approx) 00219 { 00220 approx_space = NULL; 00221 P_approx = NULL; 00222 } 00223 00224 private: 00234 NLP(const NLP&); 00235 00237 void operator=(const NLP&); 00239 }; 00240 00241 } // namespace Ipopt 00242 00243 #endif