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
37namespace abacus {
38
41public:
42
44
51 Master *master,
52 int variable,
53 double lBound,
54 double uBound)
55 : BranchRule(master), variable_(variable), lBound_(lBound), uBound_(uBound) { }
56
57
58 virtual ~BoundBranchRule() { }
59
61
69 friend std::ostream &operator<<(std::ostream &out, const BoundBranchRule &rhs);
70
71
73
79 virtual int extract(Sub *sub) {
80 if (sub->fsVarStat(variable_)->fixedOrSet())
81 return 1;
82
83 sub->lBound(variable_, lBound_);
84 sub->uBound(variable_, uBound_);
85
86 return 0;
87 }
88
89
91
94 virtual void extract(LpSub *lp) {
95 oldLpLBound_ = lp->lBound(variable_);
96 oldLpUBound_ = lp->uBound(variable_);
97
98 lp->changeLBound(variable_, lBound_);
99 lp->changeUBound(variable_, uBound_);
100 }
101
102
103 virtual void unExtract(LpSub *lp) {
104 lp->changeLBound(variable_, oldLpLBound_);
105 lp->changeUBound(variable_, oldLpUBound_);
106 }
107
108
110 int variable() const {
111 return variable_;
112 }
113
115 double lBound() const {
116 return lBound_;
117 }
118
120 double uBound() const {
121 return uBound_;
122 }
123
124private:
126 double lBound_;
127 double uBound_;
130};
131
132
133inline std::ostream &operator<<(std::ostream &out, const BoundBranchRule &rhs)
134{
135 return out << rhs.lBound_ << " <= x" << rhs.variable_ << " <= " << rhs.uBound_;
136}
137
138}
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:59
bool fixedOrSet() const
Returns false if the status is Free, true otherwise.
Definition fsvarstat.h:160
The linear program of a subproblem.
Definition lpsub.h:61
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:69
The subproblem.
Definition sub.h:68
double uBound(int i) const
Can be used to access the upper of an active variable of the subproblem.
Definition sub.h:266
double lBound(int i) const
Can be used to access the lower of an active variable of the subproblem.
Definition sub.h:245
FSVarStat * fsVarStat(int i) const
Returns a pointer to the status of fixing/setting of the i-th variable.
Definition sub.h:291
#define OGDF_EXPORT
Specifies that a function or class is exported by the OGDF DLL.
Definition config.h:101
std::ostream & operator<<(std::ostream &out, const Active< BaseType, CoType > &rhs)