Bonmin 1.8.9
Loading...
Searching...
No Matches
BonOuterApprox.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/16/2007
9#ifndef BonminOuterApprox_H
10#define BonminOuterApprox_H
11
12#include <cmath>
13
14namespace Bonmin{
15 class OsiTMINLPInterface;
16 class BabSetupBase;
17}
19namespace Bonmin {
22
23 public:
24
27 tiny_(-0.),
28 veryTiny_(-0.)
29 {}
30
32 OuterApprox(const OuterApprox & other):
33 tiny_(other.tiny_),
34 veryTiny_(other.veryTiny_){
35 }
36
37
40 if(this != & rhs){
41 tiny_ = rhs.tiny_;
42 veryTiny_ = rhs.veryTiny_;}
43 return (*this);
44 }
45
48
51
55 const double * x, bool getObj);
59 const double * x, bool getObj){
60 extractLinearRelaxation(minlp, si, x, getObj);}
61
62 private:
64 inline bool cleanNnz(double &value, double colLower, double colUpper,
65 double rowLower, double rowUpper, double colsol,
66 double & lb, double &ub, double tiny, double veryTiny);
68 double tiny_;
70 double veryTiny_;
72 static int nTimesCalled;
73 };
74
75//A procedure to try to remove small coefficients in OA cuts (or make it non small
76inline
77bool
78OuterApprox::cleanNnz(double &value, double colLower, double colUpper,
79 double rowLower, double rowUpper, double colsol,
80 double & lb, double &ub, double tiny, double veryTiny)
81{
82 if(fabs(value)>= tiny) return 1;
83
84 if(fabs(value)<veryTiny) return 0;//Take the risk?
85
86 //try and remove
87 double infty = 1e20;
88 bool colUpBounded = colUpper < 10000;
89 bool colLoBounded = colLower > -10000;
90 bool rowNotLoBounded = rowLower <= - infty;
91 bool rowNotUpBounded = rowUpper >= infty;
92 bool pos = value > 0;
93
94 if(colLoBounded && pos && rowNotUpBounded) {
95 lb += value * (colsol - colLower);
96 return 0;
97 }
98 else
99 if(colLoBounded && !pos && rowNotLoBounded) {
100 ub += value * (colsol - colLower);
101 return 0;
102 }
103 else
104 if(colUpBounded && !pos && rowNotUpBounded) {
105 lb += value * (colsol - colUpper);
106 return 0;
107 }
108 else
109 if(colUpBounded && pos && rowNotLoBounded) {
110 ub += value * (colsol - colUpper);
111 return 0;
112 }
113 //can not remove coefficient increase it to smallest non zero
114 if(pos) value = tiny;
115 else
116 value = - tiny;
117 return 1;
118}
119
120}
121
122#endif
123
A class to have all elements necessary to setup a branch-and-bound.
This is class provides an Osi interface for a Mixed Integer Linear Program expressed as a TMINLP (so ...
A class to build outer approximations.
OuterApprox & operator=(const OuterApprox &rhs)
Assignment operator.
void extractLinearRelaxation(Bonmin::OsiTMINLPInterface &minlp, OsiSolverInterface *si, const double *x, bool getObj)
Build the Outer approximation in minlp and put it in si.
OuterApprox(const OuterApprox &other)
Copy constructor.
~OuterApprox()
Destructor.
void initialize(Bonmin::BabSetupBase &b)
Initialize using options.
OuterApprox()
Default constructor.
void operator()(Bonmin::OsiTMINLPInterface &minlp, OsiSolverInterface *si, const double *x, bool getObj)
Operator() calls extractLinearRelaxation.
(C) Copyright International Business Machines Corporation 2007