Bonmin  1.7
BonTMINLP2Quad.hpp
Go to the documentation of this file.
00001 // (C) Copyright International Business Machines Corporation 2007
00002 // All Rights Reserved.
00003 // This code is published under the Common Public License.
00004 //
00005 // Authors :
00006 // Pierre Bonami, International Business Machines Corporation
00007 //
00008 // Date : 10/06/2007
00009 
00010 #ifndef __TMINLPQuad_HPP__
00011 #define __TMINLPQuad_HPP__
00012 
00013 #include "BonTMINLP2TNLP.hpp"
00014 #include "BonQuadRow.hpp"
00015 
00016 namespace Bonmin
00017 {
00018 
00019 
00022   class TMINLP2TNLPQuadCuts : public Bonmin::TMINLP2TNLP
00023   {
00024   public:
00027     TMINLP2TNLPQuadCuts(const Ipopt::SmartPtr<Bonmin::TMINLP> tminlp
00028 #ifdef WARM_STARTER
00029         ,
00030         const OptionsList& options
00031 #endif
00032         );
00033 
00034 
00038     TMINLP2TNLPQuadCuts(const TMINLP2TNLPQuadCuts&);
00039 
00041     virtual Bonmin::TMINLP2TNLP * clone() const{
00042       printf("Cloning TMINLP2TNLPQuadCuts.\n");
00043       return new TMINLP2TNLPQuadCuts(*this);}
00044 
00046     virtual ~TMINLP2TNLPQuadCuts();
00048 
00052     virtual bool get_nlp_info(Ipopt::Index& n, Ipopt::Index& m, Ipopt::Index& nnz_jac_g,
00053         Ipopt::Index& nnz_h_lag,
00054         Ipopt::TNLP::IndexStyleEnum& index_style);
00055 
00058     virtual bool get_bounds_info(Ipopt::Index n, Ipopt::Number* x_l, Ipopt::Number* x_u,
00059         Ipopt::Index m, Ipopt::Number* g_l, Ipopt::Number* g_u);
00060 
00061     virtual bool get_constraints_linearity(Ipopt::Index m, Ipopt::TNLP::LinearityType* const_types);
00062 
00065     virtual bool get_starting_point(Ipopt::Index n, bool init_x, Ipopt::Number* x,
00066         bool init_z, Ipopt::Number* z_L, Ipopt::Number* z_U,
00067         Ipopt::Index m, bool init_lambda,
00068         Ipopt::Number* lambda);
00069 
00073     virtual bool get_scaling_parameters(Ipopt::Number& obj_scaling,
00074                                         bool& use_x_scaling, Ipopt::Index n,
00075                                         Ipopt::Number* x_scaling,
00076                                         bool& use_g_scaling, Ipopt::Index m,
00077                                         Ipopt::Number* g_scaling);
00078 
00079 
00081     virtual bool eval_f(Ipopt::Index n, const Ipopt::Number* x, bool new_x,
00082         Ipopt::Number& obj_value);
00083 
00086     virtual bool eval_grad_f(Ipopt::Index n, const Ipopt::Number* x, bool new_x,
00087         Ipopt::Number* grad_f);
00088 
00090     virtual bool eval_g(Ipopt::Index n, const Ipopt::Number* x, bool new_x,
00091         Ipopt::Index m, Ipopt::Number* g);
00092 
00098     virtual bool eval_jac_g(Ipopt::Index n, const Ipopt::Number* x, bool new_x,
00099         Ipopt::Index m, Ipopt::Index nele_jac, Ipopt::Index* iRow,
00100         Ipopt::Index *jCol, Ipopt::Number* values);
00102     virtual bool eval_gi(Ipopt::Index n, const Ipopt::Number* x, bool new_x,
00103                          Ipopt::Index i, Ipopt::Number& gi);
00106     virtual bool eval_grad_gi(Ipopt::Index n, const Ipopt::Number* x, bool new_x,
00107                               Ipopt::Index i, Ipopt::Index& nele_grad_gi, Ipopt::Index* jCol,
00108                               Ipopt::Number* values);
00116     virtual bool eval_h(Ipopt::Index n, const Ipopt::Number* x, bool new_x,
00117         Ipopt::Number obj_factor, Ipopt::Index m, const Ipopt::Number* lambda,
00118         bool new_lambda, Ipopt::Index nele_hess,
00119         Ipopt::Index* iRow, Ipopt::Index* jCol, Ipopt::Number* values);
00121 
00122 
00125 
00126 
00129     void addCuts(const Cuts& cuts, bool safe);
00130 
00131 
00133     void addCuts(const OsiCuts &cuts);
00134  
00136    virtual void addCuts(unsigned int numberCuts, const OsiRowCut ** cuts);
00137 
00138  
00140     void removeCuts(unsigned int number ,const int * toRemove);
00141 
00143     //
00145     void set_linear_objective(int n_var, const double * obj, double c_0);
00146 
00148     void reset_objective(){
00149       obj_.clear();
00150     }
00151 
00152   protected:
00154     void addRowCuts(const OsiCuts &cuts, bool safe);
00164     TMINLP2TNLPQuadCuts();
00165 
00167     TMINLP2TNLPQuadCuts& operator=(const TMINLP2TNLP&);
00169 
00170   private:
00172   vector<QuadRow *> quadRows_;
00173 
00175   AdjustableMat H_;
00176 
00178     void printH();
00180   int curr_nnz_jac_;
00181 
00183   vector<double> obj_;
00185   double c_;
00186   };
00187 
00188 } // namespace Ipopt
00189 
00190 #endif
00191