Bonmin 1.8.9
Loading...
Searching...
No Matches
BonCutStrengthener.hpp
Go to the documentation of this file.
1// Copyright (C) 2007 International Business Machines and others.
2// All Rights Reserved.
3// This code is published under the Eclipse Public License.
4//
5// $Id$
6//
7// Author: Andreas Waechter IBM 2007-03-29
8
9#ifndef __BONCUTSTRENGTHENER_HPP__
10#define __BONCUTSTRENGTHENER_HPP__
11
12#include "BonTMINLP.hpp"
13#include "CoinPackedVector.hpp"
14#include "BonTNLPSolver.hpp"
15
16namespace Bonmin
17{
24
29
33 {
36 class StrengtheningTNLP: public Ipopt::TNLP {
37 public:
39 StrengtheningTNLP(Ipopt::SmartPtr<TMINLP> tminlp,
40 const CoinPackedVector& cut,
41 bool lower_bound,
43 const Ipopt::Number* starting_point,
44 const double* x_l_orig,
45 const double* x_u_orig,
46 Ipopt::Index constr_index,
47 Ipopt::Index nvar_constr ,
48 const Ipopt::Index* jCol);
49
51 ~StrengtheningTNLP();
52
56 virtual bool get_nlp_info(Ipopt::Index& n, Ipopt::Index& m, Ipopt::Index& nnz_jac_g,
57 Ipopt::Index& nnz_h_lag, Ipopt::TNLP::IndexStyleEnum& index_style);
58
60 virtual bool get_bounds_info(Ipopt::Index n, Ipopt::Number* x_l, Ipopt::Number* x_u,
62
64 virtual bool get_starting_point(Ipopt::Index n, bool init_x, Ipopt::Number* x,
65 bool init_z, Ipopt::Number* z_L, Ipopt::Number* z_U,
66 Ipopt::Index m, bool init_lambda,
67 Ipopt::Number* lambda);
68
70 virtual bool eval_f(Ipopt::Index n, const Ipopt::Number* x, bool new_x, Ipopt::Number& obj_value);
71
73 virtual bool eval_grad_f(Ipopt::Index n, const Ipopt::Number* x, bool new_x, Ipopt::Number* grad_f);
74
76 virtual bool eval_g(Ipopt::Index n, const Ipopt::Number* x, bool new_x, Ipopt::Index m, Ipopt::Number* g);
77
82 virtual bool eval_jac_g(Ipopt::Index n, const Ipopt::Number* x, bool new_x,
83 Ipopt::Index m, Ipopt::Index nele_jac, Ipopt::Index* iRow, Ipopt::Index *jCol,
84 Ipopt::Number* values);
85
90 virtual bool eval_h(Ipopt::Index n, const Ipopt::Number* x, bool new_x,
91 Ipopt::Number obj_factor, Ipopt::Index m, const Ipopt::Number* lambda,
92 bool new_lambda, Ipopt::Index nele_hess, Ipopt::Index* iRow,
93 Ipopt::Index* jCol, Ipopt::Number* values);
94
96
99 virtual void finalize_solution(Ipopt::SolverReturn status,
100 Ipopt::Index n, const Ipopt::Number* x, const Ipopt::Number* z_L, const Ipopt::Number* z_U,
101 Ipopt::Index m, const Ipopt::Number* g, const Ipopt::Number* lambda,
102 Ipopt::Number obj_value,
103 const Ipopt::IpoptData* ip_data,
106
108 Ipopt::Number StrengthenedBound() const;
109
110 private:
113 StrengtheningTNLP();
114 StrengtheningTNLP(const StrengtheningTNLP&);
115 StrengtheningTNLP& operator=(const StrengtheningTNLP&);
117
120 const Ipopt::SmartPtr<TMINLP> tminlp_;
121
123 Ipopt::Number* obj_grad_;
124
126 const Ipopt::Index n_orig_;
127
129 Ipopt::Index m_orig_;
130
132 Ipopt::Number* starting_point_;
133
136 Ipopt::Number* x_full_;
137
139 Ipopt::Number* x_l_;
140
142 Ipopt::Number* x_u_;
143
145 const Ipopt::Index constr_index_;
146
148 const Ipopt::Index nvar_constr_;
149
151 Ipopt::Index* var_indices_;
152
154 bool lower_bound_;
155
157 bool have_final_bound_;
158
160 Ipopt::Number strengthened_bound_;
161
163 Ipopt::Number* grad_f_;
164
166 void update_x_full(const Ipopt::Number *x);
167 };
168
169 public:
176
180
183 TMINLP* tminlp,
184 TMINLP2TNLP* problem,
185 const int gindex, CoinPackedVector& cut,
186 double& cut_lb, double& cut_ub,
187 const double g_val, const double g_lb,
188 const double g_ub,
189 int n, const double* x,
190 double infty);
191
192 private:
203
206
208 void operator=(const CutStrengthener&);
210
212 bool StrengthenCut(Ipopt::SmartPtr<TMINLP> tminlp ,
213 int constr_index ,
214 const CoinPackedVector& row ,
215 int n ,
216 const double* x ,
217 const double* x_l ,
218 const double* x_u ,
219 double& lb,
220 double& ub);
221
223 bool HandleOneCut(bool is_tight, TMINLP* tminlp,
224 TMINLP2TNLP* problem,
225 const double* minlp_lb,
226 const double* minlp_ub,
227 const int gindex, CoinPackedVector& cut,
228 double& cut_lb, double& cut_ub,
229 int n, const double* x,
230 double infty);
231
233 Ipopt::SmartPtr<TNLPSolver> tnlp_solver_;
234
236 int cut_strengthening_type_;
238 int disjunctive_cut_type_;
240 int oa_log_level_;
241 };
242
243} // namespace Ipopt
244#endif
Class for strengthening OA cuts, and generating additional ones.
CutStrengthener(Ipopt::SmartPtr< TNLPSolver > tnlp_solver, Ipopt::SmartPtr< Ipopt::OptionsList > options)
Constructor.
virtual ~CutStrengthener()
Destructor.
bool ComputeCuts(OsiCuts &cs, TMINLP *tminlp, TMINLP2TNLP *problem, const int gindex, CoinPackedVector &cut, double &cut_lb, double &cut_ub, const double g_val, const double g_lb, const double g_ub, int n, const double *x, double infty)
Method for generating and strenghtening all desired cuts.
This is an adapter class that converts a TMINLP to a TNLP to be solved by Ipopt.
Base class for all MINLPs that use a standard triplet matrix form and dense vectors.
Definition BonTMINLP.hpp:60
(C) Copyright International Business Machines Corporation 2007
@ CS_StrengthenedGlobal_StrengthenedLocal
@ CS_UnstrengthenedGlobal_StrengthenedLocal
ipindex Index
ipnumber Number