Bonmin
1.8.9
Toggle main menu visibility
Loading...
Searching...
No Matches
src
Algorithms
QuadCuts
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
14
namespace
Bonmin
{
15
class
OsiTMINLPInterface
;
16
class
BabSetupBase
;
17
}
18
class
OsiSolverInterface
;
19
namespace
Bonmin
{
21
class
OuterApprox
{
22
23
public
:
24
26
OuterApprox
():
27
tiny_(-0.),
28
veryTiny_(-0.)
29
{}
30
32
OuterApprox
(
const
OuterApprox
& other):
33
tiny_(other.tiny_),
34
veryTiny_(other.veryTiny_){
35
}
36
37
39
OuterApprox
&
operator=
(
const
OuterApprox
& rhs){
40
if
(
this
!= & rhs){
41
tiny_ = rhs.tiny_;
42
veryTiny_ = rhs.veryTiny_;}
43
return
(*
this
);
44
}
45
47
~OuterApprox
(){}
48
50
void
initialize
(
Bonmin::BabSetupBase
&b);
51
53
void
extractLinearRelaxation
(
Bonmin::OsiTMINLPInterface
&minlp,
54
OsiSolverInterface
*si,
55
const
double
* x,
bool
getObj);
57
void
operator()
(
Bonmin::OsiTMINLPInterface
&minlp,
58
OsiSolverInterface
*si,
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
76
inline
77
bool
78
OuterApprox::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
Bonmin::BabSetupBase
A class to have all elements necessary to setup a branch-and-bound.
Definition
BonBabSetupBase.hpp:26
Bonmin::OsiTMINLPInterface
This is class provides an Osi interface for a Mixed Integer Linear Program expressed as a TMINLP (so ...
Definition
BonOsiTMINLPInterface.hpp:49
Bonmin::OuterApprox::operator=
OuterApprox & operator=(const OuterApprox &rhs)
Assignment operator.
Definition
BonOuterApprox.hpp:39
Bonmin::OuterApprox::extractLinearRelaxation
void extractLinearRelaxation(Bonmin::OsiTMINLPInterface &minlp, OsiSolverInterface *si, const double *x, bool getObj)
Build the Outer approximation in minlp and put it in si.
Bonmin::OuterApprox::OuterApprox
OuterApprox(const OuterApprox &other)
Copy constructor.
Definition
BonOuterApprox.hpp:32
Bonmin::OuterApprox::~OuterApprox
~OuterApprox()
Destructor.
Definition
BonOuterApprox.hpp:47
Bonmin::OuterApprox::initialize
void initialize(Bonmin::BabSetupBase &b)
Initialize using options.
Bonmin::OuterApprox::OuterApprox
OuterApprox()
Default constructor.
Definition
BonOuterApprox.hpp:26
Bonmin::OuterApprox::operator()
void operator()(Bonmin::OsiTMINLPInterface &minlp, OsiSolverInterface *si, const double *x, bool getObj)
Operator() calls extractLinearRelaxation.
Definition
BonOuterApprox.hpp:57
OsiSolverInterface
Bonmin
(C) Copyright International Business Machines Corporation 2007
Definition
BonAmplSetup.hpp:16
Generated by
1.17.0