Bonmin  1.8.8
BonTMINLP2Quad.hpp
Go to the documentation of this file.
1 // (C) Copyright International Business Machines Corporation 2007
2 // All Rights Reserved.
3 // This code is published under the Eclipse Public License.
4 //
5 // Authors :
6 // Pierre Bonami, International Business Machines Corporation
7 //
8 // Date : 10/06/2007
9 
10 #ifndef __TMINLPQuad_HPP__
11 #define __TMINLPQuad_HPP__
12 
13 #include "BonTMINLP2TNLP.hpp"
14 #include "BonQuadRow.hpp"
15 
16 namespace Bonmin
17 {
18 
19 
23  {
24  public:
27  TMINLP2TNLPQuadCuts(const Ipopt::SmartPtr<Bonmin::TMINLP> tminlp
28 #ifdef WARM_STARTER
29  ,
30  const OptionsList& options
31 #endif
32  );
33 
34 
39 
41  virtual Bonmin::TMINLP2TNLP * clone() const{
42  printf("Cloning TMINLP2TNLPQuadCuts.\n");
43  return new TMINLP2TNLPQuadCuts(*this);}
44 
46  virtual ~TMINLP2TNLPQuadCuts();
48 
52  virtual bool get_nlp_info(Ipopt::Index& n, Ipopt::Index& m, Ipopt::Index& nnz_jac_g,
53  Ipopt::Index& nnz_h_lag,
54  Ipopt::TNLP::IndexStyleEnum& index_style);
55 
58  virtual bool get_bounds_info(Ipopt::Index n, Ipopt::Number* x_l, Ipopt::Number* x_u,
59  Ipopt::Index m, Ipopt::Number* g_l, Ipopt::Number* g_u);
60 
61  virtual bool get_constraints_linearity(Ipopt::Index m, Ipopt::TNLP::LinearityType* const_types);
62 
65  virtual bool get_starting_point(Ipopt::Index n, bool init_x, Ipopt::Number* x,
66  bool init_z, Ipopt::Number* z_L, Ipopt::Number* z_U,
67  Ipopt::Index m, bool init_lambda,
68  Ipopt::Number* lambda);
69 
73  virtual bool get_scaling_parameters(Ipopt::Number& obj_scaling,
74  bool& use_x_scaling, Ipopt::Index n,
75  Ipopt::Number* x_scaling,
76  bool& use_g_scaling, Ipopt::Index m,
77  Ipopt::Number* g_scaling);
78 
79 
81  virtual bool eval_f(Ipopt::Index n, const Ipopt::Number* x, bool new_x,
82  Ipopt::Number& obj_value);
83 
86  virtual bool eval_grad_f(Ipopt::Index n, const Ipopt::Number* x, bool new_x,
87  Ipopt::Number* grad_f);
88 
90  virtual bool eval_g(Ipopt::Index n, const Ipopt::Number* x, bool new_x,
91  Ipopt::Index m, Ipopt::Number* g);
92 
98  virtual bool eval_jac_g(Ipopt::Index n, const Ipopt::Number* x, bool new_x,
99  Ipopt::Index m, Ipopt::Index nele_jac, Ipopt::Index* iRow,
100  Ipopt::Index *jCol, Ipopt::Number* values);
102  virtual bool eval_gi(Ipopt::Index n, const Ipopt::Number* x, bool new_x,
103  Ipopt::Index i, Ipopt::Number& gi);
106  virtual bool eval_grad_gi(Ipopt::Index n, const Ipopt::Number* x, bool new_x,
107  Ipopt::Index i, Ipopt::Index& nele_grad_gi, Ipopt::Index* jCol,
108  Ipopt::Number* values);
116  virtual bool eval_h(Ipopt::Index n, const Ipopt::Number* x, bool new_x,
117  Ipopt::Number obj_factor, Ipopt::Index m, const Ipopt::Number* lambda,
118  bool new_lambda, Ipopt::Index nele_hess,
119  Ipopt::Index* iRow, Ipopt::Index* jCol, Ipopt::Number* values);
121 
122 
125 
126 
129  void addCuts(const Cuts& cuts, bool safe);
130 
131 
133  void addCuts(const OsiCuts &cuts);
134 
136  virtual void addCuts(unsigned int numberCuts, const OsiRowCut ** cuts);
137 
138 
140  void removeCuts(unsigned int number ,const int * toRemove);
141 
143  //
145  void set_linear_objective(int n_var, const double * obj, double c_0);
146 
149  obj_.clear();
150  }
151 
152  protected:
154  void addRowCuts(const OsiCuts &cuts, bool safe);
165 
169 
170  private:
173 
176 
178  void printH();
181 
185  double c_;
186  };
187 
188 } // namespace Ipopt
189 
190 #endif
191 
void printH()
print H_ for debug.
virtual bool get_constraints_linearity(Ipopt::Index m, Ipopt::TNLP::LinearityType *const_types)
This call is just passed onto parent class and add number of quadratic cuts.
int curr_nnz_jac_
Current umber of entries in the jacobian.
virtual bool eval_gi(Ipopt::Index n, const Ipopt::Number *x, bool new_x, Ipopt::Index i, Ipopt::Number &gi)
compute the value of a single constraint
double c_
constant term in objective function.
TMINLP2TNLPQuadCuts()
Default Constructor.
virtual ~TMINLP2TNLPQuadCuts()
Destructor.
A small wrap around std::vector to give easy access to array for interfacing with fortran code...
Definition: BonTypes.hpp:9
Ipopt::Index nnz_h_lag()
Get the nomber of nz in hessian.
Generalizes OsiCuts to handle quadratic cuts.
Definition: BonQuadCut.hpp:101
vector< double > obj_
Store user passed linear objective.
vector< QuadRow * > quadRows_
Some storage for quadratic cuts.
virtual bool get_nlp_info(Ipopt::Index &n, Ipopt::Index &m, Ipopt::Index &nnz_jac_g, Ipopt::Index &nnz_h_lag, Ipopt::TNLP::IndexStyleEnum &index_style)
This call is just passed onto parent class and add number of quadratic cuts.
AdjustableMat H_
Storage for the original hessian of the problem.
TMINLP2TNLPQuadCuts & operator=(const TMINLP2TNLP &)
Overloaded Equals Operator.
Ipopt::Number obj_value() const
Get the objective value.
const Ipopt::Number * x_l()
Get the current values for the lower bounds.
const Ipopt::Number * x_u()
Get the current values for the upper bounds.
void addCuts(const Cuts &cuts, bool safe)
Add some linear or quadratic cuts to the problem formulation if some of the OsiRowCuts are quadratic ...
void addRowCuts(const OsiCuts &cuts, bool safe)
Add some cuts to the problem formulaiton (handles Quadratics).
const Ipopt::Number * g_l()
Get the current values for constraints lower bounds.
This is a derived class fro TMINLP2TNLP to handle adding quadratic cuts.
void removeCuts(unsigned int number, const int *toRemove)
Remove some cuts from the formulation.
virtual bool eval_grad_f(Ipopt::Index n, const Ipopt::Number *x, bool new_x, Ipopt::Number *grad_f)
Returns the vector of the gradient of the objective w.r.t.
virtual bool get_scaling_parameters(Ipopt::Number &obj_scaling, bool &use_x_scaling, Ipopt::Index n, Ipopt::Number *x_scaling, bool &use_g_scaling, Ipopt::Index m, Ipopt::Number *g_scaling)
Method that returns scaling parameters (passed to parent all quadratic not scaled).
void reset_objective()
Reset objective to original one.
virtual bool eval_f(Ipopt::Index n, const Ipopt::Number *x, bool new_x, Ipopt::Number &obj_value)
Returns the value of the objective function in x.
std::map< matEntry, matIdx > AdjustableMat
Definition: BonQuadRow.hpp:26
TNLP::IndexStyleEnum index_style() const
Acces index_style.
virtual bool eval_jac_g(Ipopt::Index n, const Ipopt::Number *x, bool new_x, Ipopt::Index m, Ipopt::Index nele_jac, Ipopt::Index *iRow, Ipopt::Index *jCol, Ipopt::Number *values)
Returns the jacobian of the constraints.
virtual Bonmin::TMINLP2TNLP * clone() const
Virtual copy.
This is an adapter class that converts a TMINLP to a TNLP to be solved by Ipopt.
virtual bool get_bounds_info(Ipopt::Index n, Ipopt::Number *x_l, Ipopt::Number *x_u, Ipopt::Index m, Ipopt::Number *g_l, Ipopt::Number *g_u)
This call is just passed onto parent class and add bounds of quadratic cuts.
void set_linear_objective(int n_var, const double *obj, double c_0)
Change objective to a linear one whith given objective function.
virtual bool eval_h(Ipopt::Index n, const Ipopt::Number *x, bool new_x, Ipopt::Number obj_factor, Ipopt::Index m, const Ipopt::Number *lambda, bool new_lambda, Ipopt::Index nele_hess, Ipopt::Index *iRow, Ipopt::Index *jCol, Ipopt::Number *values)
Return the hessian of the lagrangian.
virtual bool eval_g(Ipopt::Index n, const Ipopt::Number *x, bool new_x, Ipopt::Index m, Ipopt::Number *g)
Returns the vector of constraint values in x (appends constraint values for quadratics).
virtual bool eval_grad_gi(Ipopt::Index n, const Ipopt::Number *x, bool new_x, Ipopt::Index i, Ipopt::Index &nele_grad_gi, Ipopt::Index *jCol, Ipopt::Number *values)
compute the structure or values of the gradient for one constraint
virtual bool get_starting_point(Ipopt::Index n, bool init_x, Ipopt::Number *x, bool init_z, Ipopt::Number *z_L, Ipopt::Number *z_U, Ipopt::Index m, bool init_lambda, Ipopt::Number *lambda)
This call is just passed onto parent class and add lambda for quadratic cuts.
const Ipopt::Number * g_u()
Get the current values for constraints upper bounds.
Ipopt::Index nnz_jac_g() const
Access number of entries in tminlp_ hessian.