Open
Graph Drawing
Framework

 v. 2023.09 (Elderberry)
 

lpsub.h
Go to the documentation of this file.
1 
30 #pragma once
31 
32 #include <ogdf/lib/abacus/lp.h>
33 
34 
35 #pragma GCC visibility push(default)
36 namespace abacus {
37 
38 class InfeasCon;
39 class Sub;
40 class Master;
41 class FSVarStat;
42 class Constraint;
43 class Variable;
44 
45 
47 
62 class OGDF_EXPORT LpSub : public virtual LP {
63 
64  friend class Sub;
65  friend class SetBranchRule;
66  friend class BoundBranchRule;
67  friend class ValBranchRule;
68  friend class ConBranchRule;
69  friend class COPBRANCHRULE;
70 
71 public:
72 
74 
78  LpSub (Master *master, const Sub *sub);
79 
81 
87  virtual ~LpSub();
88 
89  const Sub *sub() const { return sub_; }
90 
92 
96  int trueNCol() const { return LP::nCol(); }
97 
99  int trueNnz() const { return LP::nnz(); }
100 
102 
108  double lBound(int i) const;
109 
111  /***
112  * \param i The number of a variable.
113  *
114  * \return The upper bound of variable \a i. If a variable is eliminated, we
115  * return the value the eliminated variable is fixed or set to.
116  */
117  double uBound(int i) const;
118 
120 
125  virtual double value() const override { return LP::value() + valueAdd_; }
126 
128 
131  virtual double xVal(int i) const override;
132 
134 
138  virtual double barXVal(int i) const override;
139 
141 
144  virtual double reco(int i) const override;
145 
147 
150  virtual LPVARSTAT::STATUS lpVarStat(int i) const override;
151 
152 
154 
165  virtual int getInfeas(int &infeasCon, int &infeasVar, double *bInvRow) const override;
166 
175  virtual bool infeasible() const override {
176  return (LP::infeasible() || infeasCons_.size());
177  }
178 
180  ArrayBuffer<InfeasCon*> *infeasCon() { return &infeasCons_; }
181 
183 
190  virtual void loadBasis(Array<LPVARSTAT::STATUS> &lpVarStat,
191  Array<SlackStat::STATUS> &slackStat) override;
192 
193 protected:
194 
196 
200  virtual void initialize();
201 
202 private:
203 
205 
219  virtual OPTSTAT optimize(METHOD method) override;
220 
222  virtual void removeCons(ArrayBuffer<int> &ind) {
223  LP::remRows(ind);
224  }
225 
227  virtual void removeVars(ArrayBuffer<int> &vars);
228 
230  virtual void addCons(ArrayBuffer<Constraint*> &newCons);
231 
238  virtual void addVars(
240  ArrayBuffer<FSVarStat*> &fsVarStat,
242  ArrayBuffer<double> &ub);
243 
245 
249  virtual void changeLBound(int i, double newLb) override;
250 
252 
256  virtual void changeUBound(int i, double newUb) override;
257 
259  virtual void varRealloc(int newSize);
260 
262  virtual void conRealloc(int newSize);
263 
265  void constraint2row(ArrayBuffer<Constraint*> &newCons,
266  ArrayBuffer<Row*> &newRows);
267 
269 
274  bool eliminable(int i) const;
275 
277 
282  bool eliminated(int i) const {
283  return (orig2lp_[i] == -1);
284  }
285 
287 
293  virtual double elimVal(int i) const;
294 
296 
301  virtual double elimVal(FSVarStat *stat, double lb, double ub) const;
302 
303  void initialize(
304  OptSense sense,
305  int nRow,
306  int maxRow,
307  int nCol,
308  int maxCol,
309  Array<double> &obj,
310  Array<double> &lBound,
311  Array<double> &uBound,
312  Array<Row*> &rows);
313 
314  void initialize(
315  OptSense sense,
316  int nRow,
317  int maxRow,
318  int nCol,
319  int maxCol,
320  Array<double> &obj,
321  Array<double> &lBound,
322  Array<double> &uBound,
323  Array<Row*> &rows,
324  Array<LPVARSTAT::STATUS> &lpVarStat,
325  Array<SlackStat::STATUS> &slackStat);
326 
327  int nCol() const;
328  int maxCol() const;
329  int nnz() const;
330  double obj(int i) const;
331 
332  void rowRealloc(int newSize);
333  void colRealloc(int newSize);
334 
335 
337  const Sub *sub_;
338 
346 
349 
352 
354  double valueAdd_;
355 
358 
359  LpSub(const LpSub &rhs);
360  const LpSub &operator=(const LpSub &rhs);
361 };
362 
363 }
364 #pragma GCC visibility pop
365 
366 #include <ogdf/lib/abacus/sub.h>
367 
368 #pragma GCC visibility push(default)
369 namespace abacus {
370 
371 inline LpSub::LpSub (Master *master, const Sub *sub)
372  :
373  LP(master),
374  sub_(sub),
375  orig2lp_(sub->maxVar()),
376  lp2orig_(sub->maxVar()),
377  infeasCons_(sub->maxCon(),false)
378 { }
379 
380 }
381 #pragma GCC visibility pop
ogdf::ArrayBuffer
An array that keeps track of the number of inserted elements; also usable as an efficient stack.
Definition: Array.h:53
abacus::LpSub::sub
const Sub * sub() const
Definition: lpsub.h:89
sub.h
abacus::SetBranchRule
Implements a branching rule for setting a binary variable to its lower or upper bound.
Definition: setbranchrule.h:43
abacus::LpSub::nOrigVar_
int nOrigVar_
The number of original variables of the linear program.
Definition: lpsub.h:357
abacus::LpSub::orig2lp_
Array< int > orig2lp_
After the elimination of variables the internal variables are again numbered consecutively starting w...
Definition: lpsub.h:345
abacus::LpSub::sub_
const Sub * sub_
A pointer to the corresponding subproblem.
Definition: lpsub.h:337
abacus::OptSense
Sense of optimization.
Definition: optsense.h:45
abacus::FSVarStat
Status of fixed and set variables.
Definition: fsvarstat.h:47
abacus
Definition: ILPClusterPlanarity.h:50
abacus::LPVARSTAT::STATUS
STATUS
The enumeration of the statuses a variable gets from the linear program solver.
Definition: lpvarstat.h:55
abacus::LpSub::infeasCons_
ArrayBuffer< InfeasCon * > infeasCons_
Buffer storing the infeasible constraints found be the constructor.
Definition: lpsub.h:351
abacus::BoundBranchRule
Implements a branching rule for modifying the lower and the upper bound of a variable.
Definition: boundbranchrule.h:41
abacus::LP::nnz
int nnz() const
Definition: lp.h:228
abacus::LpSub::removeCons
virtual void removeCons(ArrayBuffer< int > &ind)
Removes all constraints listed in the buffer ind from the linear program.
Definition: lpsub.h:222
abacus::ValBranchRule
Implements a branching rule for setting a variable to a certain value.
Definition: valbranchrule.h:42
abacus::LpSub::trueNnz
int trueNnz() const
Returns the number of nonzeros which are currently present in the constraint matrix of the LP-solver.
Definition: lpsub.h:99
abacus::LpSub::LpSub
LpSub(Master *master, const Sub *sub)
The constructor.
Definition: lpsub.h:371
abacus::LpSub::infeasCon
ArrayBuffer< InfeasCon * > * infeasCon()
Returns a pointer to the buffer holding the infeasible constraints.
Definition: lpsub.h:180
abacus::ConBranchRule
Implements the branching by adding a constraint to the set of active constraints.
Definition: conbranchrule.h:45
abacus::LpSub::lp2orig_
Array< int > lp2orig_
Original number of a (non-eliminated) variable.
Definition: lpsub.h:348
ogdf::AlgorithmFailureCode::Constraint
@ Constraint
abacus::LpSub::trueNCol
int trueNCol() const
Returns the number of columns which are passed to the LP-solver.
Definition: lpsub.h:96
lp.h
linear program.
abacus::LpSub::eliminated
bool eliminated(int i) const
Returns true if the variable i is actually eliminated from the LP.
Definition: lpsub.h:282
ogdf::Array
The parameterized class Array implements dynamic arrays of type E.
Definition: Array.h:219
abacus::LP
Linear programs.
Definition: lp.h:71
ogdf::AlgorithmFailureCode::InfeasCon
@ InfeasCon
abacus::LP::nCol
int nCol() const
Definition: lp.h:224
abacus::LpSub
The linear program of a subproblem.
Definition: lpsub.h:62
abacus::LP::value
virtual double value() const
Definition: lp.h:265
abacus::LP::infeasible
virtual bool infeasible() const
Definition: lp.h:316
abacus::LP::remRows
void remRows(ArrayBuffer< int > &ind)
Removes rows of the linear program.
Definition: lp.h:377
ogdf::AlgorithmFailureCode::Variable
@ Variable
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::LpSub::value
virtual double value() const override
Returns the objective function value of the linear program.
Definition: lpsub.h:125
abacus::LpSub::infeasible
virtual bool infeasible() const override
Definition: lpsub.h:175
abacus::LpSub::valueAdd_
double valueAdd_
The constant which has been added to the objective function value due to the elimination of variables...
Definition: lpsub.h:354
abacus::Master
The master of the optimization.
Definition: master.h:70