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 #pragma GCC visibility push(default)
39 namespace abacus {
40 
41 
42 class Master;
43 class Sub;
44 #if 0
45 class VarType;
46 #endif
47 class Column;
48 class Constraint;
49 
50 template<class BaseType, class CoType> class Active;
51 
52 
54 
60 class OGDF_EXPORT Variable : public ConVar {
61 public:
62 
64 
80  Master *master,
81  const Sub *sub,
82  bool dynamic,
83  bool local,
84  double obj,
85  double lBound,
86  double uBound,
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 
250  virtual bool useful(Active<Constraint, Variable> *actCon,
251  double *y,
252  double lpVal) const;
253 
255 
259  void printCol(std::ostream &out,
260  Active<Constraint, Variable> *constraints) const;
261 
262 protected:
263 
265  double obj_;
266  double lBound_;
267  double uBound_;
269 };
270 
271 inline 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
abacus::Active
Implements the sets of active constraints and variables which are associated with each subproblem.
Definition: active.h:44
abacus::Variable::varType
VarType::TYPE varType() const
Returns the type of the variable.
Definition: variable.h:97
abacus::VarType
Variable types.
Definition: vartype.h:44
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:79
abacus::ConVar::sub
const Sub * sub() const
Returns a const pointer to the subproblem associated with the constraint/variable.
Definition: convar.h:200
abacus::Variable::integer
bool integer() const
Returns true If the type of the variable is Integer, false otherwise.
Definition: variable.h:109
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:101
abacus::Variable::obj
virtual double obj() const
Returns the objective function coefficient.
Definition: variable.h:113
abacus::FSVarStat
Status of fixed and set variables.
Definition: fsvarstat.h:47
abacus::Variable::type_
VarType type_
The type of the variable.
Definition: variable.h:268
abacus::Variable::fsVarStat
FSVarStat * fsVarStat()
Definition: variable.h:145
abacus
Definition: ILPClusterPlanarity.h:50
abacus::Variable::lBound
double lBound() const
Returns the lower bound of the variable.
Definition: variable.h:128
abacus::ConVar::sub_
const Sub * sub_
A pointer to the subproblem associated with the constraint/variable.
Definition: convar.h:290
ogdf::AlgorithmFailureCode::Constraint
@ Constraint
abacus::Variable::fsVarStat_
FSVarStat fsVarStat_
The global status of fixing and setting of the variable.
Definition: variable.h:264
abacus::ConVar
Common base class for constraints (Constraint) and variables (Variable).
Definition: convar.h:66
abacus::Variable::valid
virtual bool valid(const Sub *sub) const
Returns true if the variable is valid, false otherwise.
Definition: variable.h:271
backward::Color::type
type
Definition: backward.hpp:1716
abacus::Variable::obj_
double obj_
The objective function coefficient of the variable.
Definition: variable.h:265
abacus::Variable
Forms the virtual base class for all possible variables given in pool format.
Definition: variable.h:60
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:105
abacus::Variable::coeff
virtual double coeff(const Constraint *con) const
Computes the coefficient of the variable in the constraint con.
Definition: variable.h:189
abacus::Column
Representation of variables in column format.
Definition: column.h:48
abacus::ConVar::local_
bool local_
true if the constraint/variable is only locally valid
Definition: convar.h:313
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:266
abacus::Variable::~Variable
virtual ~Variable()
Definition: variable.h:93
OGDF_EXPORT
#define OGDF_EXPORT
Specifies that a function or class is exported by the OGDF dynamic library (shared object / DLL),...
Definition: config.h:117
abacus::Sub
The subproblem.
Definition: sub.h:69
abacus::Constraint
Forms the virtual base class for all possible constraints given in pool format.
Definition: constraint.h:57
abacus::Variable::lBound
void lBound(double newBound)
Sets the lower bound of the variable to newBound.
Definition: variable.h:135
abacus::Variable::uBound_
double uBound_
The upper bound of the variable.
Definition: variable.h:267
vartype.h
vartype.
abacus::VarType::TYPE
TYPE
The enumeration with the different variable types.
Definition: vartype.h:48
abacus::Variable::uBound
void uBound(double newBound)
Sets the upper bound of the variable to newBound.
Definition: variable.h:124
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:154
abacus::Master
The master of the optimization.
Definition: master.h:70
abacus::Variable::uBound
double uBound() const
Returns the upper bound of the variable.
Definition: variable.h:117