Open
Graph Drawing
Framework

 v. 2023.09 (Elderberry)
 

Loading...
Searching...
No Matches
variable.h
Go to the documentation of this file.
1
30#pragma once
31
37
38namespace abacus {
39
40
41class Master;
42class Sub;
43#if 0
44class VarType;
45#endif
46class Column;
47class Constraint;
48
49template<class BaseType, class CoType> class Active;
50
51
53
59class OGDF_EXPORT Variable : public ConVar {
60public:
61
63
79 Master *master,
80 const Sub *sub,
81 bool dynamic,
82 bool local,
83 double obj,
84 double lBound,
85 double uBound,
86 VarType::TYPE type)
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
218 double *y, double *slack = nullptr) const;
219
221
231 virtual double redCost(Active<Constraint, Variable> *actCon,
232 double *y) const;
233
235
250 double *y,
251 double lpVal) const;
252
254
258 void printCol(std::ostream &out,
260
261protected:
262
264 double obj_;
265 double lBound_;
266 double uBound_;
268};
269
270inline 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}
Implements the sets of active constraints and variables which are associated with each subproblem.
Definition active.h:62
Representation of variables in column format.
Definition column.h:47
Common base class for constraints (Constraint) and variables (Variable).
Definition convar.h:65
const Sub * sub_
A pointer to the subproblem associated with the constraint/variable.
Definition convar.h:289
const Sub * sub() const
Returns a const pointer to the subproblem associated with the constraint/variable.
Definition convar.h:199
bool local_
true if the constraint/variable is only locally valid
Definition convar.h:312
Forms the virtual base class for all possible constraints given in pool format.
Definition constraint.h:56
Status of fixed and set variables.
Definition fsvarstat.h:46
The master of the optimization.
Definition master.h:69
The subproblem.
Definition sub.h:68
bool ancestor(const Sub *sub) const
Returns true if this subproblem is an ancestor of the subproblem sub, false otherwise.
Variable types.
Definition vartype.h:43
TYPE
The enumeration with the different variable types.
Definition vartype.h:47
Forms the virtual base class for all possible variables given in pool format.
Definition variable.h:59
bool discrete() const
Returns true if the type of the variable is Integer or Binary, false otherwise.
Definition variable.h:100
virtual double redCost(Active< Constraint, Variable > *actCon, double *y) const
Computes the reduced cost of the variable corresponding the constraint set actCon and the dual variab...
virtual ~Variable()
Definition variable.h:92
double obj_
The objective function coefficient of the variable.
Definition variable.h:264
FSVarStat fsVarStat_
The global status of fixing and setting of the variable.
Definition variable.h:263
virtual double obj() const
Returns the objective function coefficient.
Definition variable.h:112
VarType::TYPE varType() const
Returns the type of the variable.
Definition variable.h:96
void lBound(double newBound)
Sets the lower bound of the variable to newBound.
Definition variable.h:134
void uBound(double newBound)
Sets the upper bound of the variable to newBound.
Definition variable.h:123
const FSVarStat * fsVarStat() const
Definition variable.h:153
virtual bool useful(Active< Constraint, Variable > *actCon, double *y, double lpVal) const
Returns whether an (inactive) discrete variable is useful.
virtual double coeff(const Constraint *con) const
Computes the coefficient of the variable in the constraint con.
Definition variable.h:188
virtual bool valid(const Sub *sub) const
Returns true if the variable is valid, false otherwise.
Definition variable.h:270
bool integer() const
Returns true If the type of the variable is Integer, false otherwise.
Definition variable.h:108
double uBound_
The upper bound of the variable.
Definition variable.h:266
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 int genColumn(Active< Constraint, Variable > *actCon, Column &col) const
Computes the column col of the variable associated with the active constraints *actCon.
void printCol(std::ostream &out, Active< Constraint, Variable > *constraints) const
Writes the column of the variable corresponding to the constraints to output stream out.
FSVarStat * fsVarStat()
Definition variable.h:144
double uBound() const
Returns the upper bound of the variable.
Definition variable.h:116
double lBound_
The lower bound of the variable.
Definition variable.h:265
double lBound() const
Returns the lower bound of the variable.
Definition variable.h:127
virtual bool violated(Active< Constraint, Variable > *constraints, double *y, double *slack=nullptr) const
Checks, if a variable does not price out correctly.
VarType type_
The type of the variable.
Definition variable.h:267
bool binary() const
Returns true If the type of the variable is Binary, false otherwise.
Definition variable.h:104
virtual bool violated(double rc) const
Checks, if a variable does not price out correctly.
#define OGDF_EXPORT
Specifies that a function or class is exported by the OGDF DLL.
Definition config.h:101
constraint.
constraints and variables.
status of fixed and set variables.
#define OGDF_ASSERT(expr)
Assert condition expr. See doc/build.md for more information.
Definition basic.h:41
the master of the optimization.
static MultilevelBuilder * getDoubleFactoredZeroAdjustedMerger()
vartype.