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 namespace abacus {
38 
41 public:
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 
124 private:
125  int variable_;
126  double lBound_;
127  double uBound_;
128  double oldLpLBound_;
129  double oldLpUBound_;
130 };
131 
132 
133 inline std::ostream &operator<<(std::ostream &out, const BoundBranchRule &rhs)
134 {
135  return out << rhs.lBound_ << " <= x" << rhs.variable_ << " <= " << rhs.uBound_;
136 }
137 
138 }
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:128
abacus::BoundBranchRule::lBound_
double lBound_
The lower bound of the branching variable.
Definition: boundbranchrule.h:126
abacus::BoundBranchRule::unExtract
virtual void unExtract(LpSub *lp)
Should undo the modifictions of the linear programming relaxtion |lp|.
Definition: boundbranchrule.h:103
abacus::BranchRule
Abstract base class for all branching rules.
Definition: branchrule.h:59
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:79
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:110
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:291
abacus
Definition: abacusroot.h:48
abacus::BoundBranchRule
Implements a branching rule for modifying the lower and the upper bound of a variable.
Definition: boundbranchrule.h:40
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:245
abacus::BoundBranchRule::variable_
int variable_
The branching variable.
Definition: boundbranchrule.h:125
abacus::BoundBranchRule::lBound
double lBound() const
Returns the lower bound of the branching variable.
Definition: boundbranchrule.h:115
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:50
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:94
abacus::BoundBranchRule::oldLpUBound_
double oldLpUBound_
Definition: boundbranchrule.h:129
abacus::LpSub
The linear program of a subproblem.
Definition: lpsub.h:61
abacus::FSVarStat::fixedOrSet
bool fixedOrSet() const
Returns false if the status is Free, true otherwise.
Definition: fsvarstat.h:160
abacus::BoundBranchRule::~BoundBranchRule
virtual ~BoundBranchRule()
Definition: boundbranchrule.h:58
OGDF_EXPORT
#define OGDF_EXPORT
Specifies that a function or class is exported by the OGDF DLL.
Definition: config.h:101
abacus::Sub
The subproblem.
Definition: sub.h:68
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:266
abacus::BoundBranchRule::uBound_
double uBound_
The upper bound of the branching variable.
Definition: boundbranchrule.h:127
abacus::BoundBranchRule::uBound
double uBound() const
Returns the upper bound of the branching variable.
Definition: boundbranchrule.h:120
abacus::Master
The master of the optimization.
Definition: master.h:69