00001
00002
00003
00004
00005
00006
00007
00008
00009 #ifndef __IPIPOPTNLP_HPP__
00010 #define __IPIPOPTNLP_HPP__
00011
00012 #include "IpNLP.hpp"
00013 #include "IpJournalist.hpp"
00014 #include "IpNLPScaling.hpp"
00015
00016 namespace Ipopt
00017 {
00018
00019 class IteratesVector;
00020
00028 class IpoptNLP : public ReferencedObject
00029 {
00030 public:
00033 IpoptNLP(const SmartPtr<NLPScalingObject> nlp_scaling)
00034 :
00035 nlp_scaling_(nlp_scaling)
00036 {}
00037
00039 virtual ~IpoptNLP()
00040 {}
00042
00045 virtual bool Initialize(const Journalist& jnlst,
00046 const OptionsList& options,
00047 const std::string& prefix)
00048 {
00049 bool ret = true;
00050 if (IsValid(nlp_scaling_)) {
00051 ret = nlp_scaling_->Initialize(jnlst, options, prefix);
00052 }
00053 return ret;
00054 }
00055
00059 DECLARE_STD_EXCEPTION(Eval_Error);
00061
00063 virtual bool InitializeStructures(SmartPtr<Vector>& x,
00064 bool init_x,
00065 SmartPtr<Vector>& y_c,
00066 bool init_y_c,
00067 SmartPtr<Vector>& y_d,
00068 bool init_y_d,
00069 SmartPtr<Vector>& z_L,
00070 bool init_z_L,
00071 SmartPtr<Vector>& z_U,
00072 bool init_z_U,
00073 SmartPtr<Vector>& v_L,
00074 SmartPtr<Vector>& v_U
00075 ) = 0;
00076
00078 virtual bool GetWarmStartIterate(IteratesVector& warm_start_iterate)=0;
00079
00083 virtual Number f(const Vector& x) = 0;
00084
00086 virtual SmartPtr<const Vector> grad_f(const Vector& x) = 0;
00087
00089 virtual SmartPtr<const Vector> c(const Vector& x) = 0;
00090
00092 virtual SmartPtr<const Matrix> jac_c(const Vector& x) = 0;
00093
00096 virtual SmartPtr<const Vector> d(const Vector& x) = 0;
00097
00099 virtual SmartPtr<const Matrix> jac_d(const Vector& x) = 0;
00100
00102 virtual SmartPtr<const SymMatrix> h(const Vector& x,
00103 Number obj_factor,
00104 const Vector& yc,
00105 const Vector& yd
00106 ) = 0;
00107
00109 virtual SmartPtr<const Vector> x_L() = 0;
00110
00112 virtual SmartPtr<const Matrix> Px_L() = 0;
00113
00115 virtual SmartPtr<const Vector> x_U() = 0;
00116
00118 virtual SmartPtr<const Matrix> Px_U() = 0;
00119
00121 virtual SmartPtr<const Vector> d_L() = 0;
00122
00124 virtual SmartPtr<const Matrix> Pd_L() = 0;
00125
00127 virtual SmartPtr<const Vector> d_U() = 0;
00128
00130 virtual SmartPtr<const Matrix> Pd_U() = 0;
00131
00134 virtual SmartPtr<const SymMatrixSpace> HessianMatrixSpace() const = 0;
00136
00138 virtual void GetSpaces(SmartPtr<const VectorSpace>& x_space,
00139 SmartPtr<const VectorSpace>& c_space,
00140 SmartPtr<const VectorSpace>& d_space,
00141 SmartPtr<const VectorSpace>& x_l_space,
00142 SmartPtr<const MatrixSpace>& px_l_space,
00143 SmartPtr<const VectorSpace>& x_u_space,
00144 SmartPtr<const MatrixSpace>& px_u_space,
00145 SmartPtr<const VectorSpace>& d_l_space,
00146 SmartPtr<const MatrixSpace>& pd_l_space,
00147 SmartPtr<const VectorSpace>& d_u_space,
00148 SmartPtr<const MatrixSpace>& pd_u_space,
00149 SmartPtr<const MatrixSpace>& Jac_c_space,
00150 SmartPtr<const MatrixSpace>& Jac_d_space,
00151 SmartPtr<const SymMatrixSpace>& Hess_lagrangian_space) = 0;
00152
00155 virtual void AdjustVariableBounds(const Vector& new_x_L,
00156 const Vector& new_x_U,
00157 const Vector& new_d_L,
00158 const Vector& new_d_U)=0;
00159
00162 virtual Index f_evals() const = 0;
00163 virtual Index grad_f_evals() const = 0;
00164 virtual Index c_evals() const = 0;
00165 virtual Index jac_c_evals() const = 0;
00166 virtual Index d_evals() const = 0;
00167 virtual Index jac_d_evals() const = 0;
00168 virtual Index h_evals() const = 0;
00170
00180 virtual bool objective_depends_on_mu() const
00181 {
00182 return false;
00183 }
00184
00187 virtual Number f(const Vector& x, Number mu) = 0;
00188
00191 virtual SmartPtr<const Vector> grad_f(const Vector& x, Number mu) = 0;
00192
00195 virtual SmartPtr<const SymMatrix> h(const Vector& x,
00196 Number obj_factor,
00197 const Vector& yc,
00198 const Vector& yd,
00199 Number mu) = 0;
00200
00204 virtual SmartPtr<const SymMatrix> uninitialized_h() = 0;
00206
00209 virtual void FinalizeSolution(SolverReturn status,
00210 const Vector& x, const Vector& z_L, const Vector& z_U,
00211 const Vector& c, const Vector& d,
00212 const Vector& y_c, const Vector& y_d,
00213 Number obj_value)=0;
00214
00215 virtual bool IntermediateCallBack(AlgorithmMode mode,
00216 Index iter, Number obj_value,
00217 Number inf_pr, Number inf_du,
00218 Number mu, Number d_norm,
00219 Number regularization_size,
00220 Number alpha_du, Number alpha_pr,
00221 Index ls_trials,
00222 SmartPtr<const IpoptData> ip_data,
00223 SmartPtr<IpoptCalculatedQuantities> ip_cq)=0;
00225
00227 SmartPtr<NLPScalingObject> NLP_scaling() const
00228 {
00229 DBG_ASSERT(IsValid(nlp_scaling_));
00230 return nlp_scaling_;
00231 }
00232
00233 private:
00234
00243
00245 IpoptNLP(const IpoptNLP&);
00246
00248 void operator=(const IpoptNLP&);
00250
00251 SmartPtr<NLPScalingObject> nlp_scaling_;
00252 };
00253
00254 }
00255
00256 #endif