00001
00002
00003
00004
00005
00006
00007
00008 #ifndef _TNLP2FPNLP_HPP_
00009 #define _TNLP2FPNLP_HPP_
00010
00011 #include "IpTNLP.hpp"
00012 #include "TMINLP.hpp"
00013 #include "IpSmartPtr.hpp"
00014
00015 namespace Ipopt
00016 {
00021 class TNLP2FPNLP : public TNLP
00022 {
00023 public:
00026 TNLP2FPNLP(const SmartPtr<TNLP> tnlp, double objectiveScalingFactor = 100);
00027
00029 virtual ~TNLP2FPNLP();
00031
00040 void set_dist2point_obj(int n, const Number * vals, const Index * inds);
00042
00046 virtual bool get_nlp_info(Index& n, Index& m, Index& nnz_jac_g,
00047 Index& nnz_h_lag, TNLP::IndexStyleEnum& index_style);
00048
00051 virtual bool get_bounds_info(Index n, Number* x_l, Number* x_u,
00052 Index m, Number* g_l, Number* g_u)
00053 {
00054 return tnlp_->get_bounds_info(n, x_l , x_u, m, g_l, g_u);
00055 }
00056
00059 virtual bool get_starting_point(Index n, bool init_x, Number* x,
00060 bool init_z, Number* z_L, Number* z_U,
00061 Index m, bool init_lambda,
00062 Number* lambda)
00063 {
00064 return tnlp_->get_starting_point(n, init_x, x,
00065 init_z, z_L, z_U, m, init_lambda, lambda);
00066 }
00067
00069 virtual bool eval_f(Index n, const Number* x, bool new_x,
00070 Number& obj_value);
00071
00074 virtual bool eval_grad_f(Index n, const Number* x, bool new_x,
00075 Number* grad_f);
00076
00078 virtual bool eval_g(Index n, const Number* x, bool new_x,
00079 Index m, Number* g)
00080 {
00081 return tnlp_->eval_g(n, x, new_x, m, g);
00082 }
00083
00085 virtual bool eval_jac_g(Index n, const Number* x, bool new_x,
00086 Index m, Index nele_jac, Index* iRow,
00087 Index *jCol, Number* values)
00088 {
00089 return tnlp_->eval_jac_g(n, x, new_x, m, nele_jac, iRow, jCol, values);
00090 }
00091
00093 virtual bool eval_h(Index n, const Number* x, bool new_x,
00094 Number obj_factor, Index m, const Number* lambda,
00095 bool new_lambda, Index nele_hess,
00096 Index* iRow, Index* jCol, Number* values);
00098
00102 virtual void finalize_solution(SolverReturn status,
00103 Index n, const Number* x, const Number* z_L, const Number* z_U,
00104 Index m, const Number* g, const Number* lambda,
00105 Number obj_value);
00107
00110 void setObjectiveScaling(double value)
00111 {
00112 objectiveScalingFactor_ = value;
00113 }
00114 double getObjectiveScaling() const
00115 {
00116 return objectiveScalingFactor_;
00117 }
00118
00119 private:
00123 double dist2point(const Number *x);
00125
00134 TNLP2FPNLP();
00135
00137 TNLP2FPNLP(const TNLP2FPNLP&);
00138
00140 void operator=(const TNLP2FPNLP&);
00142
00144 SmartPtr<TNLP> tnlp_;
00145
00148
00149 Index n_;
00151 Index nMax_;
00153 Index * inds_;
00155 Number * vals_;
00157
00159 double objectiveScalingFactor_;
00160
00161 };
00162
00163 }
00164
00165 #endif