Bonmin  1.7
BonTMINLPLinObj.hpp
Go to the documentation of this file.
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(Ipopt::SmartPtr<TMINLP> tminlp);
00049   
00055         virtual bool get_nlp_info(Ipopt::Index& n, Ipopt::Index& m, Ipopt::Index& nnz_jac_g,
00056                                   Ipopt::Index& nnz_h_lag, Ipopt::TNLP::IndexStyleEnum& index_style);
00060     virtual bool get_scaling_parameters(Ipopt::Number& obj_scaling,
00061                                         bool& use_x_scaling, Ipopt::Index n,
00062                                         Ipopt::Number* x_scaling,
00063                                         bool& use_g_scaling, Ipopt::Index m,
00064                                         Ipopt::Number* g_scaling);
00065 
00066 
00068     virtual bool get_variables_types(Ipopt::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(Ipopt::Index m, 
00078                                            Ipopt::TNLP::LinearityType* const_types);
00079 
00083     virtual bool get_bounds_info(Ipopt::Index n, Ipopt::Number* x_l, Ipopt::Number* x_u,
00084         Ipopt::Index m, Ipopt::Number* g_l, Ipopt::Number* g_u);
00085 
00089     virtual bool get_starting_point(Ipopt::Index n, bool init_x, Ipopt::Number* x,
00090                                     bool init_z, Ipopt::Number* z_L, Ipopt::Number* z_U,
00091         Ipopt::Index m, bool init_lambda,
00092         Ipopt::Number* lambda);
00093 
00096     virtual bool eval_f(Ipopt::Index n, const Ipopt::Number* x, bool new_x,
00097         Ipopt::Number& obj_value){
00098         assert(n == n_);
00099         obj_value = x[n-1];
00100        return true;}
00101 
00104     virtual bool eval_grad_f(Ipopt::Index n, const Ipopt::Number* x, bool new_x,
00105         Ipopt::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(Ipopt::Index n, const Ipopt::Number* x, bool new_x,
00117         Ipopt::Index m, Ipopt::Number* g);
00118 
00122     virtual bool eval_jac_g(Ipopt::Index n, const Ipopt::Number* x, bool new_x,
00123         Ipopt::Index m, Ipopt::Index nele_jac, Ipopt::Index* iRow,
00124         Ipopt::Index *jCol, Ipopt::Number* values);
00125 
00129     virtual bool eval_h(Ipopt::Index n, const Ipopt::Number* x, bool new_x,
00130         Ipopt::Number obj_factor, Ipopt::Index m, const Ipopt::Number* lambda,
00131         bool new_lambda, Ipopt::Index nele_hess,
00132         Ipopt::Index* iRow, Ipopt::Index* jCol, Ipopt::Number* values);
00135     virtual bool eval_gi(Ipopt::Index n, const Ipopt::Number* x, bool new_x,
00136                          Ipopt::Index i, Ipopt::Number& gi);
00140     virtual bool eval_grad_gi(Ipopt::Index n, const Ipopt::Number* x, bool new_x,
00141                               Ipopt::Index i, Ipopt::Index& nele_grad_gi, Ipopt::Index* jCol,
00142                               Ipopt::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] = Ipopt::TNLP::LINEAR;
00150       return r_val;
00151     }
00152 
00153 
00157     virtual void finalize_solution(TMINLP::SolverReturn status,
00158                                    Ipopt::Index n, const Ipopt::Number* x, Ipopt::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(Ipopt::Index n, const Ipopt::Number* x,
00187                                     Ipopt::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   Ipopt::SmartPtr<TMINLP> tminlp(){return tminlp_;}
00195   private:
00197    void gutsOfDestructor();
00198 
00200   Ipopt::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