Open
Graph Drawing
Framework

 v. 2023.09 (Elderberry)
 

Loading...
Searching...
No Matches
boundbranchrule.h
Go to the documentation of this file.
1
32#pragma once
33
35#include <ogdf/lib/abacus/sub.h>
36
37#pragma GCC visibility push(default)
38namespace abacus {
39
42public:
43
45
52 Master *master,
53 int variable,
54 double lBound,
55 double uBound)
56 : BranchRule(master), variable_(variable), lBound_(lBound), uBound_(uBound) { }
57
58
59 virtual ~BoundBranchRule() { }
60
62
70 friend std::ostream &operator<<(std::ostream &out, const BoundBranchRule &rhs);
71
72
74
80 virtual int extract(Sub *sub) {
81 if (sub->fsVarStat(variable_)->fixedOrSet())
82 return 1;
83
84 sub->lBound(variable_, lBound_);
85 sub->uBound(variable_, uBound_);
86
87 return 0;
88 }
89
90
92
95 virtual void extract(LpSub *lp) {
96 oldLpLBound_ = lp->lBound(variable_);
97 oldLpUBound_ = lp->uBound(variable_);
98
99 lp->changeLBound(variable_, lBound_);
100 lp->changeUBound(variable_, uBound_);
101 }
102
103
104 virtual void unExtract(LpSub *lp) {
105 lp->changeLBound(variable_, oldLpLBound_);
106 lp->changeUBound(variable_, oldLpUBound_);
107 }
108
109
111 int variable() const {
112 return variable_;
113 }
114
116 double lBound() const {
117 return lBound_;
118 }
119
121 double uBound() const {
122 return uBound_;
123 }
124
125private:
127 double lBound_;
128 double uBound_;
131};
132
133
134inline std::ostream &operator<<(std::ostream &out, const BoundBranchRule &rhs)
135{
136 return out << rhs.lBound_ << " <= x" << rhs.variable_ << " <= " << rhs.uBound_;
137}
138
139}
140#pragma GCC visibility pop
Base class for branching rules.
Implements a branching rule for modifying the lower and the upper bound of a variable.
int variable() const
Returns the number of the branching variable.
double uBound() const
Returns the upper bound of the branching variable.
double lBound() const
Returns the lower bound of the branching variable.
virtual int extract(Sub *sub)
Modifies a subproblem by changing the lower and the upper bound of the branching variable.
virtual void extract(LpSub *lp)
Pverloaded to modify directly the linear programming relaxation.
double uBound_
The upper bound of the branching variable.
virtual void unExtract(LpSub *lp)
Should undo the modifictions of the linear programming relaxtion |lp|.
BoundBranchRule(Master *master, int variable, double lBound, double uBound)
Creates a bound branch rule for given branching variable, lower bound lBound and upper bound uBound.
int variable_
The branching variable.
double lBound_
The lower bound of the branching variable.
Abstract base class for all branching rules.
Definition branchrule.h:60
bool fixedOrSet() const
Returns false if the status is Free, true otherwise.
Definition fsvarstat.h:161
The linear program of a subproblem.
Definition lpsub.h:62
double uBound(int i) const
We have to redefine the function uBound(i) since variables may have been eliminated.
double lBound(int i) const
We have to redefine the function lBound(i) since variables may have been eliminated.
virtual void changeUBound(int i, double newUb) override
Sets the upper bound of variable i to newUb.
virtual void changeLBound(int i, double newLb) override
Sets the lower bound of variable i to newLb.
The master of the optimization.
Definition master.h:70
The subproblem.
Definition sub.h:69
double uBound(int i) const
Can be used to access the upper of an active variable of the subproblem.
Definition sub.h:267
double lBound(int i) const
Can be used to access the lower of an active variable of the subproblem.
Definition sub.h:246
FSVarStat * fsVarStat(int i) const
Returns a pointer to the status of fixing/setting of the i-th variable.
Definition sub.h:292
#define OGDF_EXPORT
Specifies that a function or class is exported by the OGDF dynamic library (shared object / DLL),...
Definition config.h:117
std::ostream & operator<<(std::ostream &out, const Active< BaseType, CoType > &rhs)