00001
00002
00003
00004
00005
00006
00007
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
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);
00049
00055 virtual bool ProcessOptions(const OptionsList& options,
00056 const std::string& prefix)
00057 {
00058 return true;
00059 }
00060
00064 virtual bool GetSpaces(SmartPtr<const VectorSpace>& x_space,
00065 SmartPtr<const VectorSpace>& c_space,
00066 SmartPtr<const VectorSpace>& d_space,
00067 SmartPtr<const VectorSpace>& x_l_space,
00068 SmartPtr<const MatrixSpace>& px_l_space,
00069 SmartPtr<const VectorSpace>& x_u_space,
00070 SmartPtr<const MatrixSpace>& px_u_space,
00071 SmartPtr<const VectorSpace>& d_l_space,
00072 SmartPtr<const MatrixSpace>& pd_l_space,
00073 SmartPtr<const VectorSpace>& d_u_space,
00074 SmartPtr<const MatrixSpace>& pd_u_space,
00075 SmartPtr<const MatrixSpace>& Jac_c_space,
00076 SmartPtr<const MatrixSpace>& Jac_d_space,
00077 SmartPtr<const SymMatrixSpace>& Hess_lagrangian_space)=0;
00078
00080 virtual bool GetBoundsInformation(const Matrix& Px_L,
00081 Vector& x_L,
00082 const Matrix& Px_U,
00083 Vector& x_U,
00084 const Matrix& Pd_L,
00085 Vector& d_L,
00086 const Matrix& Pd_U,
00087 Vector& d_U)=0;
00088
00092 virtual bool GetStartingPoint(
00093 SmartPtr<Vector> x,
00094 bool need_x,
00095 SmartPtr<Vector> y_c,
00096 bool need_y_c,
00097 SmartPtr<Vector> y_d,
00098 bool need_y_d,
00099 SmartPtr<Vector> z_L,
00100 bool need_z_L,
00101 SmartPtr<Vector> z_U,
00102 bool need_z_U
00103 )=0;
00104
00108 virtual bool GetWarmStartIterate(IteratesVector& warm_start_iterate)
00109 {
00110 return false;
00111 }
00113
00117 virtual bool Eval_f(const Vector& x, Number& f) = 0;
00118
00119 virtual bool Eval_grad_f(const Vector& x, Vector& g_f) = 0;
00120
00121 virtual bool Eval_c(const Vector& x, Vector& c) = 0;
00122
00123 virtual bool Eval_jac_c(const Vector& x, Matrix& jac_c) = 0;
00124
00125 virtual bool Eval_d(const Vector& x, Vector& d) = 0;
00126
00127 virtual bool Eval_jac_d(const Vector& x, Matrix& jac_d) = 0;
00128
00129 virtual bool Eval_h(const Vector& x,
00130 Number obj_factor,
00131 const Vector& yc,
00132 const Vector& yd,
00133 SymMatrix& h) = 0;
00135
00144 virtual void FinalizeSolution(SolverReturn status,
00145 const Vector& x, const Vector& z_L,
00146 const Vector& z_U,
00147 const Vector& c, const Vector& d,
00148 const Vector& y_c, const Vector& y_d,
00149 Number obj_value)
00150 {}
00151
00167 virtual bool IntermediateCallBack(AlgorithmMode mode,
00168 Index iter, Number obj_value,
00169 Number inf_pr, Number inf_du,
00170 Number mu, Number d_norm,
00171 Number regularization_size,
00172 Number alpha_du, Number alpha_pr,
00173 Index ls_trials,
00174 const IpoptData* ip_data,
00175 IpoptCalculatedQuantities* ip_cq)
00176 {
00177 return true;
00178 }
00180
00185 virtual void GetScalingParameters(
00186 const SmartPtr<const VectorSpace> x_space,
00187 const SmartPtr<const VectorSpace> c_space,
00188 const SmartPtr<const VectorSpace> d_space,
00189 Number& obj_scaling,
00190 SmartPtr<Vector>& x_scaling,
00191 SmartPtr<Vector>& c_scaling,
00192 SmartPtr<Vector>& d_scaling) const
00193 {
00194 THROW_EXCEPTION(USER_SCALING_NOT_IMPLEMENTED,
00195 "You have set options for user provided scaling, but have"
00196 " not implemented GetScalingParameters in the NLP interface");
00197 }
00199
00213 virtual void
00214 GetQuasiNewtonApproximationSpaces(SmartPtr<VectorSpace>& approx_space,
00215 SmartPtr<Matrix>& P_approx)
00216 {
00217 approx_space = NULL;
00218 P_approx = NULL;
00219 }
00220
00221 private:
00231 NLP(const NLP&);
00232
00234 void operator=(const NLP&);
00236 };
00237
00238 }
00239
00240 #endif