Open
Graph Drawing
Framework

 v. 2023.09 (Elderberry)
 

Loading...
Searching...
No Matches
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)
36namespace abacus {
37
38class InfeasCon;
39class Sub;
40class Master;
41class FSVarStat;
42class Constraint;
43class Variable;
44
45
47
62class 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
71public:
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
193protected:
194
196
200 virtual void initialize();
201
202private:
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,
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
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
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
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)
369namespace abacus {
370
371inline 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
Implements a branching rule for modifying the lower and the upper bound of a variable.
Implements the branching by adding a constraint to the set of active constraints.
Status of fixed and set variables.
Definition fsvarstat.h:47
Linear programs.
Definition lp.h:71
OPTSTAT
The optimization status of the linear program.
Definition lp.h:75
METHOD
The solution method for the linear program.
Definition lp.h:94
STATUS
The enumeration of the statuses a variable gets from the linear program solver.
Definition lpvarstat.h:55
The linear program of a subproblem.
Definition lpsub.h:62
virtual void varRealloc(int newSize)
Sets the maximal number of variables to newSize.
virtual double elimVal(int i) const
Returns the value the variable i to which it is fixed or set to.
virtual void loadBasis(Array< LPVARSTAT::STATUS > &lpVarStat, Array< SlackStat::STATUS > &slackStat) override
Loads a new basis for the linear program.
void colRealloc(int newSize)
virtual void removeCons(ArrayBuffer< int > &ind)
Removes all constraints listed in the buffer ind from the linear program.
Definition lpsub.h:222
int trueNnz() const
Returns the number of nonzeros which are currently present in the constraint matrix of the LP-solver.
Definition lpsub.h:99
Array< int > lp2orig_
Original number of a (non-eliminated) variable.
Definition lpsub.h:348
virtual double elimVal(FSVarStat *stat, double lb, double ub) const
Returns the value a variable is fixed or set to.
double uBound(int i) const
We have to redefine the function uBound(i) since variables may have been eliminated.
virtual void addCons(ArrayBuffer< Constraint * > &newCons)
Adds the constraints newCons to the linear program.
void initialize(OptSense sense, int nRow, int maxRow, int nCol, int maxCol, Array< double > &obj, Array< double > &lBound, Array< double > &uBound, Array< Row * > &rows, Array< LPVARSTAT::STATUS > &lpVarStat, Array< SlackStat::STATUS > &slackStat)
int nnz() const
void initialize(OptSense sense, int nRow, int maxRow, int nCol, int maxCol, Array< double > &obj, Array< double > &lBound, Array< double > &uBound, Array< Row * > &rows)
virtual int getInfeas(int &infeasCon, int &infeasVar, double *bInvRow) const override
Is called if the last linear program has been solved with the dual simplex method and is infeasible.
virtual void initialize()
This function will pass the linear program of the associated subproblem to the solver.
virtual OPTSTAT optimize(METHOD method) override
Performs the optimization of the linear program with method method.
double lBound(int i) const
We have to redefine the function lBound(i) since variables may have been eliminated.
void constraint2row(ArrayBuffer< Constraint * > &newCons, ArrayBuffer< Row * > &newRows)
Generates the row format of the constraint cons and stores it in rows.
LpSub(Master *master, const Sub *sub)
The constructor.
Definition lpsub.h:371
const Sub * sub_
A pointer to the corresponding subproblem.
Definition lpsub.h:337
double obj(int i) const
virtual double value() const override
Returns the objective function value of the linear program.
Definition lpsub.h:125
const LpSub & operator=(const LpSub &rhs)
virtual double reco(int i) const override
We define the reduced costs of eliminated variables as 0.
virtual void conRealloc(int newSize)
Sets the maximal number of constraints to newSize.
virtual void removeVars(ArrayBuffer< int > &vars)
Removes the variables with names given in vars from the linear program.
virtual LPVARSTAT::STATUS lpVarStat(int i) const override
Returns the status of the variable in the linear program.
bool eliminable(int i) const
Returns true if the function can be eliminated.
virtual void changeUBound(int i, double newUb) override
Sets the upper bound of variable i to newUb.
int maxCol() const
LpSub(const LpSub &rhs)
virtual bool infeasible() const override
Definition lpsub.h:175
virtual double barXVal(int i) const override
We have to redefine the function barXVal(i) since variables may have been eliminated.
double valueAdd_
The constant which has been added to the objective function value due to the elimination of variables...
Definition lpsub.h:354
int trueNCol() const
Returns the number of columns which are passed to the LP-solver.
Definition lpsub.h:96
const Sub * sub() const
Definition lpsub.h:89
int nCol() const
int nOrigVar_
The number of original variables of the linear program.
Definition lpsub.h:357
Array< int > orig2lp_
After the elimination of variables the internal variables are again numbered consecutively starting w...
Definition lpsub.h:345
bool eliminated(int i) const
Returns true if the variable i is actually eliminated from the LP.
Definition lpsub.h:282
virtual void addVars(ArrayBuffer< Variable * > &vars, ArrayBuffer< FSVarStat * > &fsVarStat, ArrayBuffer< double > &lb, ArrayBuffer< double > &ub)
virtual ~LpSub()
The destructor.
virtual double xVal(int i) const override
We have to redefine the function xVal(i) since variables may have been eliminated.
void rowRealloc(int newSize)
ArrayBuffer< InfeasCon * > * infeasCon()
Returns a pointer to the buffer holding the infeasible constraints.
Definition lpsub.h:180
ArrayBuffer< InfeasCon * > infeasCons_
Buffer storing the infeasible constraints found be the constructor.
Definition lpsub.h:351
virtual void changeLBound(int i, double newLb) override
Sets the lower bound of variable i to newLb.
The master of the optimization.
Definition master.h:70
Sense of optimization.
Definition optsense.h:45
Implements a branching rule for setting a binary variable to its lower or upper bound.
The subproblem.
Definition sub.h:69
Implements a branching rule for setting a variable to a certain value.
An array that keeps track of the number of inserted elements; also usable as an efficient stack.
Definition ArrayBuffer.h:64
The parameterized class Array implements dynamic arrays of type E.
Definition Array.h:219
#define OGDF_EXPORT
Specifies that a function or class is exported by the OGDF dynamic library (shared object / DLL),...
Definition config.h:117
linear program.