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
35namespace abacus {
36
37class InfeasCon;
38class Sub;
39class Master;
40class FSVarStat;
41class Constraint;
42class Variable;
43
44
46
61class OGDF_EXPORT LpSub : public virtual LP {
62
63 friend class Sub;
64 friend class SetBranchRule;
65 friend class BoundBranchRule;
66 friend class ValBranchRule;
67 friend class ConBranchRule;
68 friend class COPBRANCHRULE;
69
70public:
71
73
77 LpSub (Master *master, const Sub *sub);
78
80
86 virtual ~LpSub();
87
88 const Sub *sub() const { return sub_; }
89
91
95 int trueNCol() const { return LP::nCol(); }
96
98 int trueNnz() const { return LP::nnz(); }
99
101
107 double lBound(int i) const;
108
110 /***
111 * \param i The number of a variable.
112 *
113 * \return The upper bound of variable \a i. If a variable is eliminated, we
114 * return the value the eliminated variable is fixed or set to.
115 */
116 double uBound(int i) const;
117
119
124 virtual double value() const override { return LP::value() + valueAdd_; }
125
127
130 virtual double xVal(int i) const override;
131
133
137 virtual double barXVal(int i) const override;
138
140
143 virtual double reco(int i) const override;
144
146
149 virtual LPVARSTAT::STATUS lpVarStat(int i) const override;
150
151
153
164 virtual int getInfeas(int &infeasCon, int &infeasVar, double *bInvRow) const override;
165
174 virtual bool infeasible() const override {
175 return (LP::infeasible() || infeasCons_.size());
176 }
177
179 ArrayBuffer<InfeasCon*> *infeasCon() { return &infeasCons_; }
180
182
189 virtual void loadBasis(Array<LPVARSTAT::STATUS> &lpVarStat,
190 Array<SlackStat::STATUS> &slackStat) override;
191
192protected:
193
195
199 virtual void initialize();
200
201private:
202
204
218 virtual OPTSTAT optimize(METHOD method) override;
219
222 LP::remRows(ind);
223 }
224
227
230
237 virtual void addVars(
239 ArrayBuffer<FSVarStat*> &fsVarStat,
242
244
248 virtual void changeLBound(int i, double newLb) override;
249
251
255 virtual void changeUBound(int i, double newUb) override;
256
258 virtual void varRealloc(int newSize);
259
261 virtual void conRealloc(int newSize);
262
266
268
273 bool eliminable(int i) const;
274
276
281 bool eliminated(int i) const {
282 return (orig2lp_[i] == -1);
283 }
284
286
292 virtual double elimVal(int i) const;
293
295
300 virtual double elimVal(FSVarStat *stat, double lb, double ub) const;
301
303 OptSense sense,
304 int nRow,
305 int maxRow,
306 int nCol,
307 int maxCol,
308 Array<double> &obj,
309 Array<double> &lBound,
310 Array<double> &uBound,
312
314 OptSense sense,
315 int nRow,
316 int maxRow,
317 int nCol,
318 int maxCol,
319 Array<double> &obj,
320 Array<double> &lBound,
321 Array<double> &uBound,
323 Array<LPVARSTAT::STATUS> &lpVarStat,
324 Array<SlackStat::STATUS> &slackStat);
325
326 int nCol() const;
327 int maxCol() const;
328 int nnz() const;
329 double obj(int i) const;
330
333
334
336 const Sub *sub_;
337
345
348
351
353 double valueAdd_;
354
357
358 LpSub(const LpSub &rhs);
359 const LpSub &operator=(const LpSub &rhs);
360};
361
362}
363
364#include <ogdf/lib/abacus/sub.h>
365
366namespace abacus {
367
368inline LpSub::LpSub (Master *master, const Sub *sub)
369 :
370 LP(master),
371 sub_(sub),
372 orig2lp_(sub->maxVar()),
373 lp2orig_(sub->maxVar()),
374 infeasCons_(sub->maxCon(),false)
375{ }
376
377}
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:46
Linear programs.
Definition lp.h:70
OPTSTAT
The optimization status of the linear program.
Definition lp.h:74
METHOD
The solution method for the linear program.
Definition lp.h:93
STATUS
The enumeration of the statuses a variable gets from the linear program solver.
Definition lpvarstat.h:54
The linear program of a subproblem.
Definition lpsub.h:61
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:221
int trueNnz() const
Returns the number of nonzeros which are currently present in the constraint matrix of the LP-solver.
Definition lpsub.h:98
Array< int > lp2orig_
Original number of a (non-eliminated) variable.
Definition lpsub.h:347
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:368
const Sub * sub_
A pointer to the corresponding subproblem.
Definition lpsub.h:336
double obj(int i) const
virtual double value() const override
Returns the objective function value of the linear program.
Definition lpsub.h:124
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:174
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:353
int trueNCol() const
Returns the number of columns which are passed to the LP-solver.
Definition lpsub.h:95
const Sub * sub() const
Definition lpsub.h:88
int nCol() const
int nOrigVar_
The number of original variables of the linear program.
Definition lpsub.h:356
Array< int > orig2lp_
After the elimination of variables the internal variables are again numbered consecutively starting w...
Definition lpsub.h:344
bool eliminated(int i) const
Returns true if the variable i is actually eliminated from the LP.
Definition lpsub.h:281
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:179
ArrayBuffer< InfeasCon * > infeasCons_
Buffer storing the infeasible constraints found be the constructor.
Definition lpsub.h:350
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:69
Sense of optimization.
Definition optsense.h:44
Implements a branching rule for setting a binary variable to its lower or upper bound.
The subproblem.
Definition sub.h:68
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:56
The parameterized class Array implements dynamic arrays of type E.
Definition Array.h:214
#define OGDF_EXPORT
Specifies that a function or class is exported by the OGDF DLL.
Definition config.h:101
linear program.
static MultilevelBuilder * getDoubleFactoredZeroAdjustedMerger()