Open
Graph Drawing
Framework

 v. 2020.02 (Catalpa)
 

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 }
double lBound() const
Returns the lower bound of the branching variable.
double lBound(int i) const
Can be used to access the lower of an active variable of the subproblem.
Definition: sub.h:245
The master of the optimization.
Definition: master.h:69
#define OGDF_EXPORT
Specifies that a function or class is exported by the OGDF DLL.
Definition: config.h:99
double uBound() const
Returns the upper bound of the branching variable.
double lBound_
The lower bound of the branching variable.
double uBound(int i) const
We have to redefine the function uBound(i) since variables may have been eliminated.
int variable() const
Returns the number of the branching variable.
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
int variable_
The branching variable.
Implements a branching rule for modifying the lower and the upper bound of a variable.
FSVarStat * fsVarStat(int i) const
Returns a pointer to the status of fixing/setting of the i-th variable.
Definition: sub.h:291
virtual void changeLBound(int i, double newLb) override
Sets the lower bound of variable i to newLb.
bool fixedOrSet() const
Returns false if the status is Free, true otherwise.
Definition: fsvarstat.h:160
double lBound(int i) const
We have to redefine the function lBound(i) since variables may have been eliminated.
virtual void extract(LpSub *lp)
Pverloaded to modify directly the linear programming relaxation.
The linear program of a subproblem.
Definition: lpsub.h:61
Base class for branching rules.
Abstract base class for all branching rules.
Definition: branchrule.h:59
virtual void unExtract(LpSub *lp)
Should undo the modifictions of the linear programming relaxtion |lp|.
virtual void changeUBound(int i, double newUb) override
Sets the upper bound of variable i to newUb.
double uBound_
The upper 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.
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...
std::ostream & operator<<(std::ostream &out, const Active< BaseType, CoType > &rhs)