Bonmin 1.4trunk
|
00001 // (C) Copyright International Business Machines Corporation 2007 00002 // All Rights Reserved. 00003 // 00004 // Authors : 00005 // Pierre Bonami, International Business Machines Corporation 00006 // 00007 // Date : 08/16/2007 00008 00009 00010 #ifndef TMINLPLinObj_H 00011 #define TMINLPLinObj_H 00012 00013 #include "BonTMINLP.hpp" 00014 00015 namespace Bonmin { 00039 class TMINLPLinObj: public Bonmin::TMINLP { 00040 public: 00042 TMINLPLinObj(); 00043 00045 virtual ~TMINLPLinObj(); 00046 00048 void setTminlp(SmartPtr<TMINLP> tminlp); 00049 00055 virtual bool get_nlp_info(Index& n, Index& m, Index& nnz_jac_g, 00056 Index& nnz_h_lag, TNLP::IndexStyleEnum& index_style); 00060 virtual bool get_scaling_parameters(Number& obj_scaling, 00061 bool& use_x_scaling, Index n, 00062 Number* x_scaling, 00063 bool& use_g_scaling, Index m, 00064 Number* g_scaling); 00065 00066 00068 virtual bool get_variables_types(Index n, VariableType* var_types){ 00069 assert(IsValid(tminlp_)); 00070 assert(n == n_); 00071 var_types[n-1] = TMINLP::CONTINUOUS; 00072 return tminlp_->get_variables_types(n - 1, var_types); 00073 } 00074 00077 virtual bool get_constraints_linearity(Index m, 00078 Ipopt::TNLP::LinearityType* const_types); 00079 00083 virtual bool get_bounds_info(Index n, Number* x_l, Number* x_u, 00084 Index m, Number* g_l, Number* g_u); 00085 00089 virtual bool get_starting_point(Index n, bool init_x, Number* x, 00090 bool init_z, Number* z_L, Number* z_U, 00091 Index m, bool init_lambda, 00092 Number* lambda); 00093 00096 virtual bool eval_f(Index n, const Number* x, bool new_x, 00097 Number& obj_value){ 00098 assert(n == n_); 00099 obj_value = x[n-1]; 00100 return true;} 00101 00104 virtual bool eval_grad_f(Index n, const Number* x, bool new_x, 00105 Number* grad_f){ 00106 assert(IsValid(tminlp_)); 00107 assert(n == n_); 00108 n--; 00109 for(int i = 0 ; i < n ; i++){ 00110 grad_f[i] = 0;} 00111 grad_f[n] = 1; 00112 return true;} 00113 00116 virtual bool eval_g(Index n, const Number* x, bool new_x, 00117 Index m, Number* g); 00118 00122 virtual bool eval_jac_g(Index n, const Number* x, bool new_x, 00123 Index m, Index nele_jac, Index* iRow, 00124 Index *jCol, Number* values); 00125 00129 virtual bool eval_h(Index n, const Number* x, bool new_x, 00130 Number obj_factor, Index m, const Number* lambda, 00131 bool new_lambda, Index nele_hess, 00132 Index* iRow, Index* jCol, Number* values); 00135 virtual bool eval_gi(Index n, const Number* x, bool new_x, 00136 Index i, Number& gi); 00140 virtual bool eval_grad_gi(Index n, const Number* x, bool new_x, 00141 Index i, Index& nele_grad_gi, Index* jCol, 00142 Number* values); 00144 00145 virtual bool get_variables_linearity(Ipopt::Index n, Ipopt::TNLP::LinearityType* c){ 00146 assert(IsValid(tminlp_)); 00147 assert(n == n_); 00148 bool r_val = tminlp_->get_variables_linearity(n-1, c); 00149 c[n - 1] = TNLP::LINEAR; 00150 return r_val; 00151 } 00152 00153 00157 virtual void finalize_solution(TMINLP::SolverReturn status, 00158 Index n, const Number* x, Number obj_value){ 00159 return tminlp_->finalize_solution(status, n - 1, x, 00160 obj_value); 00161 } 00163 00165 virtual const BranchingInfo * branchingInfo() const{ 00166 return tminlp_->branchingInfo(); 00167 } 00168 00171 virtual const SosInfo * sosConstraints() const{ 00172 return tminlp_->sosConstraints(); 00173 } 00175 virtual const PerturbInfo* perturbInfo() const 00176 { 00177 return tminlp_->perturbInfo(); 00178 } 00179 00181 virtual bool hasUpperBoundingObjective(){ 00182 assert(IsValid(tminlp_)); 00183 return tminlp_->hasUpperBoundingObjective();} 00184 00186 virtual bool eval_upper_bound_f(Index n, const Number* x, 00187 Number& obj_value){ 00188 assert(IsValid(tminlp_)); 00189 return tminlp_->eval_upper_bound_f(n - 1, x, obj_value); } 00190 00192 virtual bool hasLinearObjective(){return true;} 00194 SmartPtr<TMINLP> tminlp(){return tminlp_;} 00195 private: 00197 void gutsOfDestructor(); 00198 00200 SmartPtr<TMINLP> tminlp_; 00202 int m_; 00204 int n_; 00206 int nnz_jac_; 00208 int offset_; 00209 00210 }; 00211 00212 00213 }/* Ends Bonmin namepsace.*/ 00214 00215 #endif 00216