00001
00002
00003
00004
00005
00006
00007
00008 #ifndef _TNLP2FPNLP_HPP_
00009 #define _TNLP2FPNLP_HPP_
00010
00011 #include "IpTNLP.hpp"
00012 #include "BonTMINLP.hpp"
00013 #include "IpSmartPtr.hpp"
00014 #include "BonTypes.hpp"
00015
00016 namespace Bonmin
00017 {
00022 class TNLP2FPNLP : public Ipopt::TNLP
00023 {
00024 public:
00027 TNLP2FPNLP(const SmartPtr<TNLP> tnlp, double objectiveScalingFactor = 100);
00028
00030 virtual ~TNLP2FPNLP();
00032
00041 void set_dist2point_obj(int n, const Number * vals, const Index * inds);
00042
00044 void setSigma(double sigma){
00045 assert(sigma >= 0.);
00046 sigma_ = sigma;}
00048 void setLambda(double lambda){
00049 assert(lambda >= 0. && lambda <= 1.);
00050 lambda_ = lambda;}
00052 void setNorm(int norm){
00053 assert(norm >0 && norm < 3);
00054 norm_ = norm;}
00056
00060 virtual bool get_nlp_info(Index& n, Index& m, Index& nnz_jac_g,
00061 Index& nnz_h_lag, TNLP::IndexStyleEnum& index_style);
00062
00065 virtual bool get_bounds_info(Index n, Number* x_l, Number* x_u,
00066 Index m, Number* g_l, Number* g_u)
00067 {
00068 return tnlp_->get_bounds_info(n, x_l , x_u, m, g_l, g_u);
00069 }
00070
00073 virtual bool get_starting_point(Index n, bool init_x, Number* x,
00074 bool init_z, Number* z_L, Number* z_U,
00075 Index m, bool init_lambda,
00076 Number* lambda)
00077 {
00078 return tnlp_->get_starting_point(n, init_x, x,
00079 init_z, z_L, z_U, m, init_lambda, lambda);
00080 }
00081
00083 virtual bool eval_f(Index n, const Number* x, bool new_x,
00084 Number& obj_value);
00085
00088 virtual bool eval_grad_f(Index n, const Number* x, bool new_x,
00089 Number* grad_f);
00090
00092 virtual bool eval_g(Index n, const Number* x, bool new_x,
00093 Index m, Number* g)
00094 {
00095 return tnlp_->eval_g(n, x, new_x, m, g);
00096 }
00097
00099 virtual bool eval_jac_g(Index n, const Number* x, bool new_x,
00100 Index m, Index nele_jac, Index* iRow,
00101 Index *jCol, Number* values)
00102 {
00103 return tnlp_->eval_jac_g(n, x, new_x, m, nele_jac, iRow, jCol, values);
00104 }
00105
00107 virtual bool eval_h(Index n, const Number* x, bool new_x,
00108 Number obj_factor, Index m, const Number* lambda,
00109 bool new_lambda, Index nele_hess,
00110 Index* iRow, Index* jCol, Number* values);
00112
00116 virtual void finalize_solution(SolverReturn status,
00117 Index n, const Number* x, const Number* z_L, const Number* z_U,
00118 Index m, const Number* g, const Number* lambda,
00119 Number obj_value,
00120 const IpoptData* ip_data,
00121 IpoptCalculatedQuantities* ip_cq);
00123
00126 void setObjectiveScaling(double value)
00127 {
00128 objectiveScalingFactor_ = value;
00129 }
00130 double getObjectiveScaling() const
00131 {
00132 return objectiveScalingFactor_;
00133 }
00134
00135 private:
00139 double dist2point(const Number *x);
00141
00150 TNLP2FPNLP();
00151
00153 TNLP2FPNLP(const TNLP2FPNLP&);
00154
00156 void operator=(const TNLP2FPNLP&);
00158
00160 SmartPtr<TNLP> tnlp_;
00161
00164
00165 vector<Index> inds_;
00167 vector<Number> vals_;
00170 double lambda_;
00172 double sigma_;
00174 int norm_;
00176
00178 double objectiveScalingFactor_;
00179
00180 };
00181
00182 }
00183
00184 #endif