Open
Graph Drawing
Framework

 v. snapshot-2017-02-16
 

variable.h
Go to the documentation of this file.
1 
30 #pragma once
31 
32 #include <ogdf/lib/abacus/convar.h>
33 #include <ogdf/lib/abacus/master.h>
37 
38 namespace abacus {
39 
40 
41 class Master;
42 class Sub;
43 #if 0
44 class VarType;
45 #endif
46 class Column;
47 class Constraint;
48 
49 template<class BaseType, class CoType> class Active;
50 
51 
53 
59 class OGDF_EXPORT Variable : public ConVar {
60 public:
61 
63 
79  Master *master,
80  const Sub *sub,
81  bool dynamic,
82  bool local,
83  double obj,
84  double lBound,
85  double uBound,
87  : ConVar(master, sub, dynamic, local),
88  fsVarStat_(master), obj_(obj), lBound_(lBound), uBound_(uBound), type_(type)
89  { }
90 
91 
92  virtual ~Variable() { }
93 
94 
96  VarType::TYPE varType() const { return type_.type(); }
97 
98 
100  bool discrete() const { return type_.discrete(); }
101 
102 
104  bool binary() const { return type_.binary(); }
105 
106 
108  bool integer() const { return type_.integer(); }
109 
110 
112  virtual double obj() const { return obj_; }
113 
114 
116  double uBound() const { return uBound_; }
117 
118 
120 
123  void uBound(double newBound) { uBound_ = newBound; }
124 
125 
127  double lBound() const { return lBound_; }
128 
129 
131 
134  void lBound(double newBound) { lBound_ = newBound; }
135 
136 
144  FSVarStat *fsVarStat() { return &fsVarStat_; }
145 
153  const FSVarStat *fsVarStat() const { return &fsVarStat_; }
154 
156 
164  virtual bool valid(const Sub *sub) const;
165 
167 
177  virtual int genColumn(Active<Constraint, Variable> *actCon, Column &col) const;
178 
180 
188  virtual double coeff(const Constraint *con) const {
189  return con->coeff(this);
190  }
191 
192 
194 
202  virtual bool violated(double rc) const;
203 
205 
217  virtual bool violated(Active<Constraint, Variable> *constraints,
218  double *y, double *slack = nullptr) const;
219 
221 
231  virtual double redCost(Active<Constraint, Variable> *actCon,
232  double *y) const;
233 
235 
249  virtual bool useful(Active<Constraint, Variable> *actCon,
250  double *y,
251  double lpVal) const;
252 
254 
258  void printCol(ostream &out,
259  Active<Constraint, Variable> *constraints) const;
260 
261 protected:
262 
264  double obj_;
265  double lBound_;
266  double uBound_;
268 };
269 
270 inline bool Variable::valid(const Sub *sub) const
271 {
272  OGDF_ASSERT(!local_ || sub != nullptr);
273 
274  return (!local_ || sub->ancestor(sub_));
275 }
276 
277 
278 
279 } //namespace abacus
virtual double obj() const
Returns the objective function coefficient.
Definition: variable.h:112
The master of the optimization.
Definition: master.h:69
double lBound() const
Returns the lower bound of the variable.
Definition: variable.h:127
Implements the sets of active constraints and variables which are associated with each subproblem...
Definition: active.h:43
#define OGDF_EXPORT
Specifies that a function or class is exported by the OGDF DLL.
Definition: config.h:99
Common base class for constraints (Constraint) and variables (Variable).
Definition: convar.h:65
Variable types.
Definition: vartype.h:43
double uBound_
The upper bound of the variable.
Definition: variable.h:266
status of fixed and set variables.
Representation of variables in column format.
Definition: column.h:47
bool discrete() const
Returns true if the type of the variable is Integer or Binary, false otherwise.
Definition: variable.h:100
virtual ~Variable()
Definition: variable.h:92
The subproblem.
Definition: sub.h:68
double lBound_
The lower bound of the variable.
Definition: variable.h:265
Status of fixed and set variables.
Definition: fsvarstat.h:46
vartype.
bool binary() const
Returns true If the type of the variable is Binary, false otherwise.
Definition: variable.h:104
double uBound() const
Returns the upper bound of the variable.
Definition: variable.h:116
const FSVarStat * fsVarStat() const
Definition: variable.h:153
the master of the optimization.
virtual bool valid(const Sub *sub) const
Returns true if the variable is valid, false otherwise.
Definition: variable.h:270
FSVarStat fsVarStat_
The global status of fixing and setting of the variable.
Definition: variable.h:263
Forms the virtual base class for all possible constraints given in pool format.
Definition: constraint.h:56
void lBound(double newBound)
Sets the lower bound of the variable to newBound.
Definition: variable.h:134
constraints and variables.
constraint.
bool integer() const
Returns true If the type of the variable is Integer, false otherwise.
Definition: variable.h:108
bool ancestor(const Sub *sub) const
Returns true if this subproblem is an ancestor of the subproblem sub, false otherwise.
double obj_
The objective function coefficient of the variable.
Definition: variable.h:264
Forms the virtual base class for all possible variables given in pool format.
Definition: variable.h:59
VarType type_
The type of the variable.
Definition: variable.h:267
VarType::TYPE varType() const
Returns the type of the variable.
Definition: variable.h:96
void uBound(double newBound)
Sets the upper bound of the variable to newBound.
Definition: variable.h:123
TYPE
The enumeration with the different variable types.
Definition: vartype.h:47
Variable(Master *master, const Sub *sub, bool dynamic, bool local, double obj, double lBound, double uBound, VarType::TYPE type)
Initializes a variable.
Definition: variable.h:78
virtual double coeff(const Variable *v) const =0
Returns the coefficient of the variable v in the constraint.
FSVarStat * fsVarStat()
Definition: variable.h:144
virtual double coeff(const Constraint *con) const
Computes the coefficient of the variable in the constraint con.
Definition: variable.h:188
#define OGDF_ASSERT(expr)
Assert condition expr. See doc/build.md for more information.
Definition: basic.h:41