Open
Graph Drawing
Framework

 v. 2023.09 (Elderberry)
 

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)
38 namespace abacus {
39 
42 public:
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 
125 private:
126  int variable_;
127  double lBound_;
128  double uBound_;
129  double oldLpLBound_;
130  double oldLpUBound_;
131 };
132 
133 
134 inline 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
abacus::LpSub::uBound
double uBound(int i) const
We have to redefine the function uBound(i) since variables may have been eliminated.
branchrule.h
Base class for branching rules.
sub.h
abacus::BoundBranchRule::oldLpLBound_
double oldLpLBound_
Definition: boundbranchrule.h:129
abacus::BoundBranchRule::lBound_
double lBound_
The lower bound of the branching variable.
Definition: boundbranchrule.h:127
abacus::BoundBranchRule::unExtract
virtual void unExtract(LpSub *lp)
Should undo the modifictions of the linear programming relaxtion |lp|.
Definition: boundbranchrule.h:104
abacus::BranchRule
Abstract base class for all branching rules.
Definition: branchrule.h:60
abacus::LpSub::changeLBound
virtual void changeLBound(int i, double newLb) override
Sets the lower bound of variable i to newLb.
abacus::BoundBranchRule::extract
virtual int extract(Sub *sub)
Modifies a subproblem by changing the lower and the upper bound of the branching variable.
Definition: boundbranchrule.h:80
abacus::operator<<
std::ostream & operator<<(std::ostream &out, const Active< BaseType, CoType > &rhs)
abacus::BoundBranchRule::variable
int variable() const
Returns the number of the branching variable.
Definition: boundbranchrule.h:111
abacus::Sub::fsVarStat
FSVarStat * fsVarStat(int i) const
Returns a pointer to the status of fixing/setting of the i-th variable.
Definition: sub.h:292
abacus
Definition: ILPClusterPlanarity.h:50
abacus::BoundBranchRule
Implements a branching rule for modifying the lower and the upper bound of a variable.
Definition: boundbranchrule.h:41
abacus::Sub::lBound
double lBound(int i) const
Can be used to access the lower of an active variable of the subproblem.
Definition: sub.h:246
abacus::BoundBranchRule::variable_
int variable_
The branching variable.
Definition: boundbranchrule.h:126
abacus::BoundBranchRule::lBound
double lBound() const
Returns the lower bound of the branching variable.
Definition: boundbranchrule.h:116
abacus::LpSub::changeUBound
virtual void changeUBound(int i, double newUb) override
Sets the upper bound of variable i to newUb.
abacus::BoundBranchRule::BoundBranchRule
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.
Definition: boundbranchrule.h:51
abacus::LpSub::lBound
double lBound(int i) const
We have to redefine the function lBound(i) since variables may have been eliminated.
abacus::BoundBranchRule::extract
virtual void extract(LpSub *lp)
Pverloaded to modify directly the linear programming relaxation.
Definition: boundbranchrule.h:95
abacus::BoundBranchRule::oldLpUBound_
double oldLpUBound_
Definition: boundbranchrule.h:130
abacus::LpSub
The linear program of a subproblem.
Definition: lpsub.h:62
abacus::FSVarStat::fixedOrSet
bool fixedOrSet() const
Returns false if the status is Free, true otherwise.
Definition: fsvarstat.h:161
abacus::BoundBranchRule::~BoundBranchRule
virtual ~BoundBranchRule()
Definition: boundbranchrule.h:59
OGDF_EXPORT
#define OGDF_EXPORT
Specifies that a function or class is exported by the OGDF dynamic library (shared object / DLL),...
Definition: config.h:117
abacus::Sub
The subproblem.
Definition: sub.h:69
abacus::Sub::uBound
double uBound(int i) const
Can be used to access the upper of an active variable of the subproblem.
Definition: sub.h:267
abacus::BoundBranchRule::uBound_
double uBound_
The upper bound of the branching variable.
Definition: boundbranchrule.h:128
abacus::BoundBranchRule::uBound
double uBound() const
Returns the upper bound of the branching variable.
Definition: boundbranchrule.h:121
abacus::Master
The master of the optimization.
Definition: master.h:70