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
38#pragma GCC visibility push(default)
39namespace abacus {
40
41
42class Master;
43class Sub;
44#if 0
45class VarType;
46#endif
47class Column;
48class Constraint;
49
50template<class BaseType, class CoType> class Active;
51
52
54
60class OGDF_EXPORT Variable : public ConVar {
61public:
62
64
80 Master *master,
81 const Sub *sub,
82 bool dynamic,
83 bool local,
84 double obj,
85 double lBound,
86 double uBound,
87 VarType::TYPE type)
88 : ConVar(master, sub, dynamic, local),
89 fsVarStat_(master), obj_(obj), lBound_(lBound), uBound_(uBound), type_(type)
90 { }
91
92
93 virtual ~Variable() { }
94
95
97 VarType::TYPE varType() const { return type_.type(); }
98
99
101 bool discrete() const { return type_.discrete(); }
102
103
105 bool binary() const { return type_.binary(); }
106
107
109 bool integer() const { return type_.integer(); }
110
111
113 virtual double obj() const { return obj_; }
114
115
117 double uBound() const { return uBound_; }
118
119
121
124 void uBound(double newBound) { uBound_ = newBound; }
125
126
128 double lBound() const { return lBound_; }
129
130
132
135 void lBound(double newBound) { lBound_ = newBound; }
136
137
145 FSVarStat *fsVarStat() { return &fsVarStat_; }
146
154 const FSVarStat *fsVarStat() const { return &fsVarStat_; }
155
157
165 virtual bool valid(const Sub *sub) const;
166
168
178 virtual int genColumn(Active<Constraint, Variable> *actCon, Column &col) const;
179
181
189 virtual double coeff(const Constraint *con) const {
190 return con->coeff(this);
191 }
192
193
195
203 virtual bool violated(double rc) const;
204
206
218 virtual bool violated(Active<Constraint, Variable> *constraints,
219 double *y, double *slack = nullptr) const;
220
222
232 virtual double redCost(Active<Constraint, Variable> *actCon,
233 double *y) const;
234
236
251 double *y,
252 double lpVal) const;
253
255
259 void printCol(std::ostream &out,
260 Active<Constraint, Variable> *constraints) const;
261
262protected:
263
265 double obj_;
266 double lBound_;
267 double uBound_;
269};
270
271inline bool Variable::valid(const Sub *sub) const
272{
273 OGDF_ASSERT(!local_ || sub != nullptr);
274
275 return (!local_ || sub->ancestor(sub_));
276}
277
278
279
280}
281#pragma GCC visibility pop
Implements the sets of active constraints and variables which are associated with each subproblem.
Definition active.h:63
Representation of variables in column format.
Definition column.h:48
Common base class for constraints (Constraint) and variables (Variable).
Definition convar.h:66
const Sub * sub_
A pointer to the subproblem associated with the constraint/variable.
Definition convar.h:290
const Sub * sub() const
Returns a const pointer to the subproblem associated with the constraint/variable.
Definition convar.h:200
bool local_
true if the constraint/variable is only locally valid
Definition convar.h:313
Forms the virtual base class for all possible constraints given in pool format.
Definition constraint.h:57
virtual double coeff(const Variable *v) const =0
Returns the coefficient of the variable v in the constraint.
Status of fixed and set variables.
Definition fsvarstat.h:47
The master of the optimization.
Definition master.h:70
The subproblem.
Definition sub.h:69
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:44
TYPE
The enumeration with the different variable types.
Definition vartype.h:48
Forms the virtual base class for all possible variables given in pool format.
Definition variable.h:60
bool discrete() const
Returns true if the type of the variable is Integer or Binary, false otherwise.
Definition variable.h:101
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:93
double obj_
The objective function coefficient of the variable.
Definition variable.h:265
FSVarStat fsVarStat_
The global status of fixing and setting of the variable.
Definition variable.h:264
virtual double obj() const
Returns the objective function coefficient.
Definition variable.h:113
VarType::TYPE varType() const
Returns the type of the variable.
Definition variable.h:97
void lBound(double newBound)
Sets the lower bound of the variable to newBound.
Definition variable.h:135
void uBound(double newBound)
Sets the upper bound of the variable to newBound.
Definition variable.h:124
const FSVarStat * fsVarStat() const
Definition variable.h:154
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:189
virtual bool valid(const Sub *sub) const
Returns true if the variable is valid, false otherwise.
Definition variable.h:271
bool integer() const
Returns true If the type of the variable is Integer, false otherwise.
Definition variable.h:109
double uBound_
The upper bound of the variable.
Definition variable.h:267
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:79
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:145
double uBound() const
Returns the upper bound of the variable.
Definition variable.h:117
double lBound_
The lower bound of the variable.
Definition variable.h:266
double lBound() const
Returns the lower bound of the variable.
Definition variable.h:128
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:268
bool binary() const
Returns true If the type of the variable is Binary, false otherwise.
Definition variable.h:105
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 dynamic library (shared object / DLL),...
Definition config.h:117
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:52
the master of the optimization.
vartype.