Bonmin 1.8.9
Loading...
Searching...
No Matches
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
16namespace Bonmin
17{
18
19
23 {
24 public:
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
48
55
60
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,
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,
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,
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:
172 vector<QuadRow *> quadRows_;
173
175 AdjustableMat H_;
176
178 void printH();
180 int curr_nnz_jac_;
181
183 vector<double> obj_;
185 double c_;
186 };
187
188} // namespace Ipopt
189
190#endif
191
Generalizes OsiCuts to handle quadratic cuts.
This is a derived class fro TMINLP2TNLP to handle adding quadratic cuts.
TMINLP2TNLPQuadCuts(const TMINLP2TNLPQuadCuts &)
Copy Constructor.
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.
void addCuts(const Cuts &cuts, bool safe)
Add some linear or quadratic cuts to the problem formulation if some of the OsiRowCuts are quadratic ...
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.
void addRowCuts(const OsiCuts &cuts, bool safe)
Add some cuts to the problem formulaiton (handles Quadratics).
TMINLP2TNLPQuadCuts(const Ipopt::SmartPtr< Bonmin::TMINLP > tminlp)
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.
virtual bool get_constraints_linearity(Ipopt::Index m, Ipopt::TNLP::LinearityType *const_types)
Returns the constraint linearity.
virtual ~TMINLP2TNLPQuadCuts()
Destructor.
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.
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_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 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.
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
void removeCuts(unsigned int number, const int *toRemove)
Remove some cuts from the formulation.
virtual Bonmin::TMINLP2TNLP * clone() const
Virtual copy.
TMINLP2TNLPQuadCuts()
Default Constructor.
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).
TMINLP2TNLPQuadCuts & operator=(const TMINLP2TNLP &)
Overloaded Equals Operator.
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
void set_linear_objective(int n_var, const double *obj, double c_0)
Change objective to a linear one whith given objective function.
virtual void addCuts(unsigned int numberCuts, const OsiRowCut **cuts)
Add some linear cuts to the problem formulation.
void addCuts(const OsiCuts &cuts)
Add some cuts to the problem formulaiton (handles Quadratics).
This is an adapter class that converts a TMINLP to a TNLP to be solved by Ipopt.
TNLP::IndexStyleEnum index_style() const
Acces index_style.
const Ipopt::Number * x_u()
Get the current values for the upper bounds.
const Ipopt::Number * g_l()
Get the current values for constraints lower bounds.
Ipopt::Number obj_value() const
Get the objective value.
Ipopt::Index nnz_h_lag()
Get the nomber of nz in hessian.
const Ipopt::Number * x_l()
Get the current values for the lower bounds.
Ipopt::Index nnz_jac_g() const
Access number of entries in tminlp_ hessian.
const Ipopt::Number * g_u()
Get the current values for constraints upper bounds.
A small wrap around std::vector to give easy access to array for interfacing with fortran code.
Definition BonTypes.hpp:9
(C) Copyright International Business Machines Corporation 2007
std::map< matEntry, matIdx > AdjustableMat
ipindex Index
ipnumber Number