Open
Graph Drawing
Framework

 v. 2023.09 (Elderberry)
 

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(std::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 }
abacus::Active
Implements the sets of active constraints and variables which are associated with each subproblem.
Definition: active.h:43
abacus::Variable::varType
VarType::TYPE varType() const
Returns the type of the variable.
Definition: variable.h:96
abacus::VarType
Variable types.
Definition: vartype.h:43
abacus::Variable::Variable
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
abacus::ConVar::sub
const Sub * sub() const
Returns a const pointer to the subproblem associated with the constraint/variable.
Definition: convar.h:199
abacus::Variable::integer
bool integer() const
Returns true If the type of the variable is Integer, false otherwise.
Definition: variable.h:108
OGDF_ASSERT
#define OGDF_ASSERT(expr)
Assert condition expr. See doc/build.md for more information.
Definition: basic.h:66
fsvarstat.h
status of fixed and set variables.
constraint.h
constraint.
convar.h
constraints and variables.
abacus::Variable::discrete
bool discrete() const
Returns true if the type of the variable is Integer or Binary, false otherwise.
Definition: variable.h:100
abacus::Variable::obj
virtual double obj() const
Returns the objective function coefficient.
Definition: variable.h:112
abacus::FSVarStat
Status of fixed and set variables.
Definition: fsvarstat.h:46
abacus::Variable::type_
VarType type_
The type of the variable.
Definition: variable.h:267
abacus::Variable::fsVarStat
FSVarStat * fsVarStat()
Definition: variable.h:144
abacus
Definition: ILPClusterPlanarity.h:50
abacus::Variable::lBound
double lBound() const
Returns the lower bound of the variable.
Definition: variable.h:127
abacus::ConVar::sub_
const Sub * sub_
A pointer to the subproblem associated with the constraint/variable.
Definition: convar.h:289
ogdf::AlgorithmFailureCode::Constraint
@ Constraint
abacus::Variable::fsVarStat_
FSVarStat fsVarStat_
The global status of fixing and setting of the variable.
Definition: variable.h:263
abacus::ConVar
Common base class for constraints (Constraint) and variables (Variable).
Definition: convar.h:65
abacus::Variable::valid
virtual bool valid(const Sub *sub) const
Returns true if the variable is valid, false otherwise.
Definition: variable.h:270
backward::Color::type
type
Definition: backward.hpp:1716
abacus::Variable::obj_
double obj_
The objective function coefficient of the variable.
Definition: variable.h:264
abacus::Variable
Forms the virtual base class for all possible variables given in pool format.
Definition: variable.h:59
ogdf::AlgorithmFailureCode::Active
@ Active
abacus::Variable::binary
bool binary() const
Returns true If the type of the variable is Binary, false otherwise.
Definition: variable.h:104
abacus::Variable::coeff
virtual double coeff(const Constraint *con) const
Computes the coefficient of the variable in the constraint con.
Definition: variable.h:188
abacus::Column
Representation of variables in column format.
Definition: column.h:47
abacus::ConVar::local_
bool local_
true if the constraint/variable is only locally valid
Definition: convar.h:312
abacus::Constraint::coeff
virtual double coeff(const Variable *v) const =0
Returns the coefficient of the variable v in the constraint.
master.h
the master of the optimization.
abacus::Variable::lBound_
double lBound_
The lower bound of the variable.
Definition: variable.h:265
abacus::Variable::~Variable
virtual ~Variable()
Definition: variable.h:92
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::Constraint
Forms the virtual base class for all possible constraints given in pool format.
Definition: constraint.h:56
abacus::Variable::lBound
void lBound(double newBound)
Sets the lower bound of the variable to newBound.
Definition: variable.h:134
abacus::Variable::uBound_
double uBound_
The upper bound of the variable.
Definition: variable.h:266
vartype.h
vartype.
abacus::VarType::TYPE
TYPE
The enumeration with the different variable types.
Definition: vartype.h:47
abacus::Variable::uBound
void uBound(double newBound)
Sets the upper bound of the variable to newBound.
Definition: variable.h:123
abacus::Sub::ancestor
bool ancestor(const Sub *sub) const
Returns true if this subproblem is an ancestor of the subproblem sub, false otherwise.
abacus::Variable::fsVarStat
const FSVarStat * fsVarStat() const
Definition: variable.h:153
abacus::Master
The master of the optimization.
Definition: master.h:69
abacus::Variable::uBound
double uBound() const
Returns the upper bound of the variable.
Definition: variable.h:116