Open
Graph Drawing
Framework

 v. 2023.09 (Elderberry)
 

Loading...
Searching...
No Matches
sub.h
Go to the documentation of this file.
1
30#pragma once
31
32#include <ogdf/lib/abacus/lp.h>
35
37
38
39#pragma GCC visibility push(default)
40namespace abacus {
41
42class LpSub;
43class TailOff;
44class BranchRule;
45class LPVARSTAT;
46class Variable;
47class Master;
48class InfeasCon;
49class Constraint;
50
51template<class BaseType, class CoType> class CutBuffer;
52template<class BaseType, class CoType> class Active;
53template<class BaseType, class CoType> class Pool;
54template<class BaseType, class CoType> class PoolSlot;
55template<class BaseType, class CoType> class LpSolution;
56
57
59
69class OGDF_EXPORT Sub : public AbacusRoot {
70
71 friend class Master;
72 friend class BoundBranchRule;
73 friend class OpenSub;
74 friend class LpSolution<Constraint, Variable>;
75 friend class LpSolution<Variable, Constraint>;
76
77public:
78
80 enum STATUS {
83 Dormant,
86 Fathomed
87 };
88
90 enum PHASE {
92 Cutting,
95 Fathoming
96 };
97
99
117 Master *master,
118 double conRes,
119 double varRes,
120 double nnzRes,
121 bool relativeRes = true,
122 ArrayBuffer<PoolSlot<Constraint, Variable> *> *constraints = nullptr,
123 ArrayBuffer<PoolSlot<Variable, Constraint> *> *variables = nullptr);
124
126
132 Sub(Master *master, Sub *father, BranchRule *branchRule);
133
135
145 virtual ~Sub();
146
148 bool forceExactSolver() const { return forceExactSolver_; }
149
151 int level() const { return level_; }
152
154 int id() const { return id_; }
155
157 STATUS status() const { return status_; }
158
160 int nVar() const;
161
163 int maxVar() const;
164
166 int nCon() const;
167
169 int maxCon() const;
170
172 double lowerBound() const;
173
175 double upperBound() const;
176
178
182 double dualBound() const { return dualBound_; }
183
185
196 void dualBound(double x);
197
199 const Sub *father() const { return father_; }
200
202 LpSub *lp() const { return lp_; }
203
205
211 void maxIterations(int max);
212
214 Active<Constraint, Variable> *actCon() const { return actCon_; }
215
217 Active<Variable, Constraint> *actVar() const { return actVar_; }
218
220
223 Constraint *constraint(int i) const;
224
226
229 SlackStat *slackStat(int i) const { return (*slackStat_)[i]; }
230
232
235 Variable *variable(int i) const;
236
238
246 double lBound(int i) const { return (*lBound_)[i]; }
247
249
256 void lBound(int i, double l);
257
259
267 double uBound(int i) const { return (*uBound_)[i]; }
268
270
277 void uBound(int i, double u);
278
280
292 FSVarStat *fsVarStat(int i) const { return (*fsVarStat_)[i]; }
293
295
298 LPVARSTAT *lpVarStat(int i) const { return (*lpVarStat_)[i]; }
299
301
304 double xVal(int i) const { return xVal_[i]; }
305
307
310 double yVal(int i) const { return yVal_[i]; }
311
313
318 bool ancestor(const Sub *sub) const;
319
321 Master *master() { return master_; }
322
324 const Master *master() const { return master_; }
325
327
335
337
344 void removeVar(int i) { removeVarBuffer_->push(i); }
345
347 double nnzReserve() const { return nnzReserve_; }
348
353 bool relativeReserve() const { return relativeReserve_; }
354
356 BranchRule *branchRule() const { return branchRule_; }
357
359
372 bool objAllInteger() const;
373
375
380 virtual void removeCons(ArrayBuffer<int> &remove);
381
383
386 virtual void removeCon(int i);
387
389
396 int addConBufferSpace() const;
397
399
406 int addVarBufferSpace() const;
407
409 int nDormantRounds() const { return nDormantRounds_; }
410
412
425
427
436 virtual int addBranchingConstraint(PoolSlot<Constraint, Variable> *slot);
437
438protected:
439
441
458 virtual int addCons(ArrayBuffer<Constraint*> &constraints,
459 Pool<Constraint, Variable> *pool = nullptr,
460 ArrayBuffer<bool> *keepInPool = nullptr,
461 ArrayBuffer<double> *rank = nullptr);
462
464
469 virtual int addCons(
471
473
490 virtual int addVars(ArrayBuffer<Variable*> &variables,
491 Pool<Variable, Constraint> *pool = nullptr,
492 ArrayBuffer<bool> *keepInPool = nullptr,
493 ArrayBuffer<double> *rank = nullptr);
494
496
507 virtual int addVars(
509
511
526 int ranking = 0,
527 Pool<Variable, Constraint> *pool = nullptr,
528 double minViolation = 0.001);
529
531
548 int ranking = 0,
549 Pool<Constraint, Variable> *pool = nullptr,
550 double minViolation = 0.001);
551
553
556 virtual void activate() { }
557
559
564 virtual void deactivate () { }
565
567
577 return branchingOnVariable(rules);
578 }
579
581
592
594
607 virtual int selectBranchingVariable(int &variable);
608
610
641
643
655 virtual int selectBestBranchingSample(int nSamples,
656 ArrayBuffer<BranchRule*> **samples);
657
659
665 Array<double> &rank);
666
668
677 virtual double rankBranchingRule(BranchRule *branchRule);
678
680
694 double lpRankBranchingRule(BranchRule *branchRule, int iterLimit = -1);
695
697
709 Array<double> &rank2);
710
712
721 int closeHalfExpensive(int &branchVar, VarType::TYPE branchVarType);
722
724 /***
725 * Those variables with fractional part close to \f$0.5\f$ and high absolute objective function
726 * coefficient are selected..
727 *
728 * \param variables Holds the numbers of possible branching variables if
729 * at least one is found. We try to find as many
730 * candidates as fit into this buffer. We abort
731 * the function with a fatal error if the size
732 * of the buffer is 0.
733 * \param branchVarType The type of the branching variable can be restricted either
734 * to VarType::Binary or VarType::Integer.
735 *
736 * \return 0 If at least one branching variable is found, 1 otherwise.
737 */
739 VarType::TYPE branchVarType);
740
742
749 int closeHalf(int &branchVar, VarType::TYPE branchVarType);
750
752
759 int closeHalf(ArrayBuffer<int> &branchVar, VarType::TYPE branchVarType);
760
762
770 VarType::TYPE branchVarType);
771
773
780 int findNonFixedSet(int &branchVar, VarType::TYPE branchVarType);
781
783
798 virtual int initMakeFeas(
799 ArrayBuffer<InfeasCon*> &infeasCon,
800 ArrayBuffer<Variable*> &newVars,
802 {
803 return 1;
804 }
805
807
823 virtual int makeFeasible() { return 1; }
824
836 virtual bool goodCol(Column &col, Array<double> &row,
837 double x, double lb, double ub);
838
840
846 virtual void setByLogImp(ArrayBuffer<int> &variable,
847 ArrayBuffer<FSVarStat*> &status) { }
848
850
857 virtual bool feasible() = 0;
858
860
868
870
880 virtual bool primalSeparation();
881
883
888 virtual int separate();
889
891
900 virtual void conEliminate(ArrayBuffer<int> &remove);
901
903
907
909
912 virtual void basicConEliminate(ArrayBuffer<int> &remove);
913
915
921 virtual void varEliminate(ArrayBuffer<int> &remove);
922
924
928
930
935 virtual int pricing() { return 0; }
936
938
946 virtual int improve(double &primalValue);
947
949
952 virtual Sub *generateSon(BranchRule *rule) = 0;
953
955 bool boundCrash() const;
956
969 virtual bool pausing() { return false; }
970
973
975
978 virtual void varRealloc(int newSize);
979
981
984 virtual void conRealloc(int newSize);
985
987
1000 virtual LP::METHOD chooseLpMethod(int nVarRemoved, int nConRemoved,
1001 int nVarAdded, int nConAdded);
1002
1004
1015 virtual bool tailingOff() { return true; }
1016
1018 bool betterDual(double x) const;
1019
1021
1025 virtual void selectVars() { }
1026
1028
1032 virtual void selectCons() { }
1033
1035
1046 virtual int fixByRedCost(bool &newValues, bool saveCand);
1047
1049 /***
1050 * The default implementation of \a fixByLogImp() does nothing. This
1051 * function has to be redefined if variables should be fixed by logical
1052 * implications in derived classes.
1053 *
1054 * \param variables The variables which should be fixed.
1055 * \param status The statuses these variables should be fixed to.
1056 */
1057 virtual void fixByLogImp(ArrayBuffer<int> &variables,
1058 ArrayBuffer<FSVarStat*> &status) { }
1059
1061
1074 virtual int fixAndSet(bool &newValues);
1075
1077
1087 virtual int fixing(bool &newValues, bool saveCand = false);
1088
1090
1099 virtual int setting(bool &newValues);
1100
1102
1105 virtual int setByRedCost();
1106
1108
1131 virtual void fathom(bool reoptimize);
1132
1134
1139 virtual bool fixAndSetTime() { return true; }
1140
1142
1157 virtual int fix(int i, FSVarStat *newStat, bool &newValue);
1158
1160
1170 virtual int set(int i, FSVarStat *newStat, bool &newValue);
1171
1173
1182 virtual int set(int i, FSVarStat::STATUS newStat, bool &newValue);
1183
1185
1195 virtual int set(int i, FSVarStat::STATUS newStat, double value,
1196 bool &newValue);
1197
1207 virtual double dualRound(double x);
1208
1210
1213 virtual double guarantee() const;
1214
1219 virtual bool guaranteed() const;
1220
1229
1231
1237 virtual int prepareBranching(bool &lastIteration);
1238
1240
1251 virtual void fathomTheSubTree();
1252
1254
1272 virtual int optimize();
1273
1275
1291 virtual void reoptimize();
1292
1294
1297 virtual void initializeVars(int maxVar);
1298
1300
1303 virtual void initializeCons(int maxCon);
1304
1306
1326 virtual PHASE branching();
1327
1329
1353 virtual PHASE fathoming();
1354
1356
1366 virtual PHASE cutting();
1367
1369
1377 virtual LpSub *generateLp();
1378
1380
1391 virtual int initializeLp();
1392
1394
1408 virtual int solveLp();
1409
1411
1416 virtual bool exceptionFathom() { return false; }
1417
1419
1425 virtual bool exceptionBranch() { return false; }
1426
1433 virtual bool solveApproxNow() { return false; }
1434
1435
1438
1441
1444
1447
1450
1452
1460
1463
1466
1469
1472
1475
1478
1481
1484
1487
1490
1496
1499
1502
1505
1508
1511
1513 double *xVal_;
1514
1516 double *yVal_;
1517
1519 double *bInvRow_;
1520
1523
1526
1529
1530private:
1531
1533 virtual int _separate();
1534
1536
1541 virtual int _conEliminate();
1542
1544
1547 virtual int _varEliminate();
1548
1573 virtual int _pricing(bool &newValues, bool doFixSet = true);
1574
1576
1588 virtual int _improve(double &primalValue);
1589
1591
1595 virtual int _fixByLogImp(bool &newValues);
1596
1598
1602 virtual void updateBoundInLp(int i);
1603
1605 virtual double fixSetNewBound(int i);
1606
1608
1612 virtual void newDormantRound() { ++nDormantRounds_; }
1613
1615
1648 virtual PHASE _activate();
1649
1651
1660 virtual void _deactivate();
1661
1663
1675 virtual int _initMakeFeas();
1676
1685 virtual int _makeFeasible();
1686
1688
1697 virtual int _setByLogImp(bool &newValues);
1698
1700
1703 virtual void infeasibleSub();
1704
1706 virtual void getBase();
1707
1709
1714
1716
1722 ArrayBuffer<FSVarStat*> *localStatus = nullptr);
1723
1725
1729
1732
1734 virtual int _removeVars(ArrayBuffer<int> &remove);
1735
1737 virtual int _removeCons(ArrayBuffer<int> &remove);
1738
1740 bool _atUpperBound(int i);
1741
1743 bool _atLowerBound(int i);
1744
1745
1748
1750 int id_;
1751
1754
1757
1760
1763
1773
1776
1779
1782
1785
1787
1792
1794
1799
1802
1804
1807
1808 Sub(const Sub &rhs);
1809 const Sub &operator=(const Sub &rhs);
1810};
1811
1812}
1813#pragma GCC visibility pop
1814
1815// NOW declaration of sub is complete. its definitions below need full declarations of the below types...
1816
1819#include <ogdf/lib/abacus/active.h>
1821#include <ogdf/lib/abacus/lpsub.h>
1822
1823#pragma GCC visibility push(default)
1824namespace abacus {
1825
1827{
1828 return addConBuffer_->insert(slot, true);
1829}
1830
1831inline int Sub::addConBufferSpace() const
1832{
1833 return addConBuffer_->space();
1834}
1835
1836inline int Sub::addVarBufferSpace() const
1837{
1838 return addVarBuffer_->space();
1839}
1840
1841inline int Sub::nVar() const
1842{
1843 return actVar_->number();
1844}
1845
1846inline int Sub::nCon() const
1847{
1848 return actCon_->number();
1849}
1850
1851inline int Sub::maxVar() const
1852{
1853 return actVar_->max();
1854}
1855
1856inline int Sub::maxCon() const
1857{
1858 return actCon_->max();
1859}
1860
1861inline Constraint *Sub::constraint(int i) const
1862{
1863 return (*actCon_)[i];
1864}
1865
1866inline Variable *Sub::variable(int i) const
1867{
1868 return (*actVar_)[i];
1869}
1870
1875
1876inline double Sub::lowerBound() const
1877{
1878 if (master_->optSense()->max())
1879 return master_->primalBound();
1880 else
1881 return dualBound_;
1882}
1883
1884inline double Sub::upperBound() const
1885{
1886 if (master_->optSense()->min())
1887 return master_->primalBound();
1888 else
1889 return dualBound_;
1890}
1891
1892inline bool Sub::betterDual(double x) const
1893{
1894 if (master_->optSense()->max())
1895 return x < dualBound_ ? true : false;
1896 else
1897 return x > dualBound_ ? true : false;
1898}
1899
1900inline bool Sub::boundCrash() const
1901{
1903}
1904
1905inline void Sub::removeCon(int i)
1906{
1908}
1909
1910inline void Sub::lBound(int i, double l)
1911{
1912 (*lBound_)[i] = l;
1913 if (lp_)
1914 lp_->changeLBound(i, l);
1915}
1916
1917inline void Sub::uBound(int i, double u)
1918{
1919 (*uBound_)[i] = u;
1920 if (lp_)
1921 lp_->changeUBound(i, u);
1922}
1923
1924}
1925#pragma GCC visibility pop
Declaration of stopwatch classes.
Base class of all other classes of ABACUS.
Definition abacusroot.h:69
Implements the sets of active constraints and variables which are associated with each subproblem.
Definition active.h:63
Implements a branching rule for modifying the lower and the upper bound of a variable.
Abstract base class for all branching rules.
Definition branchrule.h:60
Representation of variables in column format.
Definition column.h:48
Forms the virtual base class for all possible constraints given in pool format.
Definition constraint.h:57
Cut buffers.
Definition cutbuffer.h:53
Status of fixed and set variables.
Definition fsvarstat.h:47
STATUS
The enumeration defining the different statuses of variables from the point of view of fixing and set...
Definition fsvarstat.h:51
METHOD
The solution method for the linear program.
Definition lp.h:94
status of variables.
Definition lpvarstat.h:51
LP solutions.
Definition lpsolution.h:65
The linear program of a subproblem.
Definition lpsub.h:62
virtual void changeUBound(int i, double newUb) override
Sets the upper bound of variable i to newUb.
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
int nStrongBranchingIterations() const
The number of simplex iterations that are performed when testing candidates for branching variables w...
Definition master.h:555
bool primalViolated(double x) const
Can be used to compare a value with the one of the best known primal bound.
double primalBound() const
Returns the value of the primal bound.
Definition master.h:279
const OptSense * optSense() const
Returns a pointer to the object holding the optimization sense of the problem.
Definition master.h:443
Maintains open subproblems.
Definition opensub.h:50
bool min() const
Returns true If it is minimization problem,, false otherwise.
Definition optsense.h:85
bool max() const
Returns true if it is maximization problem,, false otherwise.
Definition optsense.h:91
Base class for constraint/variabe pools.
Definition pool.h:63
Stores constraints and variables.
Definition poolslot.h:78
Status of slack variables.
Definition slackstat.h:48
The subproblem.
Definition sub.h:69
const Sub & operator=(const Sub &rhs)
virtual void setByLogImp(ArrayBuffer< int > &variable, ArrayBuffer< FSVarStat * > &status)
The default implementation of setByLogImp() does nothing.
Definition sub.h:846
virtual int makeFeasible()
The default implementation of makeFeasible()does nothing.
Definition sub.h:823
virtual int selectBranchingVariable(int &variable)
Chooses a branching variable.
double uBound(int i) const
Can be used to access the upper of an active variable of the subproblem.
Definition sub.h:267
ArrayBuffer< int > * removeVarBuffer_
The buffer of the variables which are removed at the beginning of the next iteration.
Definition sub.h:1507
int maxVar() const
Returns the maximum number of variables which can be handled without reallocation.
Definition sub.h:1851
Sub(const Sub &rhs)
void dualBound(double x)
Sets the dual bound of the subproblem.
virtual void removeCon(int i)
Adds a single constraint to the set of constraints which are removed from the active set at the begin...
Definition sub.h:1905
bool infeasible()
Returns true if the subproblem does not contain a feasible solution, false otherwise.
LP::METHOD lpMethod_
The solution method for the next linear program.
Definition sub.h:1498
virtual bool tailingOff()
Called when a tailing off effect according to the parameters TailOffPercent and TailOffNLps is observ...
Definition sub.h:1015
int lastIterConAdd_
The last iteration in which constraints have been added.
Definition sub.h:1483
virtual int _pricing(bool &newValues, bool doFixSet=true)
If doFixSet is true, then we try to fix and set variables, if all inactive variables price out correc...
int infeasVar_
The number of an infeasible variable.
Definition sub.h:1525
virtual void addVarsToLp(ArrayBuffer< PoolSlot< Variable, Constraint > * > &newVars, ArrayBuffer< FSVarStat * > *localStatus=nullptr)
Adds the variables stored in the pool slots of newVars to the linear program. localStatus can specify...
virtual void fathom(bool reoptimize)
Fathoms a node and recursively tries to fathom its father.
virtual int separate()
Must be redefined in derived classes for the generation of cutting planes.
Array< double > * uBound_
A pointer to an array with the local upper bounds of the active variables.
Definition sub.h:1468
virtual void initializeCons(int maxCon)
Initializes the active constraint set.
virtual int selectBestBranchingSample(int nSamples, ArrayBuffer< BranchRule * > **samples)
Evaluates branching samples.
virtual void conRealloc(int newSize)
Reallocates memory that at most newSize constraints can be handled in the subproblem.
virtual int fixing(bool &newValues, bool saveCand=false)
Tries to fix variables by reduced cost criteria and logical implications.
double yVal(int i) const
Returns the value of the i-th dual variable in the last solved linear program.
Definition sub.h:310
BranchRule * branchRule_
The branching rule for the subproblem.
Definition sub.h:1489
virtual void nonBindingConEliminate(ArrayBuffer< int > &remove)
Retrieves the dynamic constraints with slack exceeding the value given by the parameter ConElimEps.
virtual ~Sub()
The destructor only deletes the sons of the node.
virtual int selectBranchingVariableCandidates(ArrayBuffer< int > &candidates)
Selects candidates for branching variables.
int closeHalf(ArrayBuffer< int > &branchVar, VarType::TYPE branchVarType)
Searches searches several possible branching variable of type branchVarType, with fraction as close t...
virtual int _fixByLogImp(bool &newValues)
Returns 1, if a contradiction has been found, 0 otherwise.
virtual bool primalSeparation()
Controls if during the cutting plane phase a (primal) separation step or a pricing step (dual separat...
virtual int fixByRedCost(bool &newValues, bool saveCand)
Tries to fix variables according to the reduced cost criterion.
virtual int fixAndSet(bool &newValues)
Tries to fix and set variables both by logical implications and reduced cost criteria.
virtual void deactivate()
Can be used as entrance point for problem specific deactivations after the subproblem optimization.
Definition sub.h:564
bool boundCrash() const
Returns true if the dual bound is worse than the best known primal bound, false otherwise.
Definition sub.h:1900
virtual PHASE cutting()
Iteratively solves the LP-relaxation, generates constraints and/or variables.
virtual void fixByLogImp(ArrayBuffer< int > &variables, ArrayBuffer< FSVarStat * > &status)
Should collect the numbers of the variables to be fixed in variable and the respective statuses in st...
Definition sub.h:1057
virtual double rankBranchingRule(BranchRule *branchRule)
Computes the rank of a branching rule.
Definition sub.h:1871
virtual void conEliminate(ArrayBuffer< int > &remove)
Can be used as an entry point for application specific elimination of constraints.
virtual void activateVars(ArrayBuffer< PoolSlot< Variable, Constraint > * > &newVars)
Adds the variables stored in the pool slots of newVars to the set of active variables,...
int level_
The level of the subproblem in the enumeration tree.
Definition sub.h:1747
BranchRule * branchRule() const
Returns a pointer to the branching rule of the subproblem.
Definition sub.h:356
bool activated_
The variable is true if the function activate() has been called from the function _activate().
Definition sub.h:1791
virtual PHASE _activate()
Allocates and initializes memory of the subproblem at the beginning of the optimization.
virtual int _improve(double &primalValue)
Tries to find a better feasible solution.
virtual int set(int i, FSVarStat::STATUS newStat, double value, bool &newValue)
Sets a variable.
virtual void rankBranchingSample(ArrayBuffer< BranchRule * > &sample, Array< double > &rank)
Computes for each branching rule of a branching sample a rank with the function rankBranchingRule().
STATUS
A subproblem can have different statuses.
Definition sub.h:80
@ Unprocessed
The status after generation, but before optimization of the subproblem.
Definition sub.h:81
@ Processed
The subproblem is completely processed but could not be fathomed.
Definition sub.h:85
@ ActiveSub
The subproblem is currently processed.
Definition sub.h:82
bool relativeReserve() const
Definition sub.h:353
Constraint * constraint(int i) const
Returns a pointer to the i-th active constraint.
Definition sub.h:1861
virtual int improve(double &primalValue)
Can be redefined in order to implement primal heuristics for finding feasible solutions.
virtual Sub * generateSon(BranchRule *rule)=0
Returns a pointer to an object of a problem specific subproblem, which is generated from the current ...
STATUS status_
The status of the subproblem.
Definition sub.h:1753
virtual int compareBranchingSampleRanks(Array< double > &rank1, Array< double > &rank2)
Compares the ranks of two branching samples.
virtual void updateBoundInLp(int i)
Adapts the bound of a fixed or set variable i also in the linear program.
virtual void varEliminate(ArrayBuffer< int > &remove)
Entry point for application specific variable elimination.
virtual int branchingOnVariable(ArrayBuffer< BranchRule * > &rules)
Generates branching rules for two new subproblems by selecting a branching variable with the function...
bool _atUpperBound(int i)
Returns true iff the current value of variable i in the primal lp is equal to its upper bound.
bool betterDual(double x) const
Returns true if x is better than the best known dual bound of the subproblem, false otherwise.
Definition sub.h:1892
bool forceExactSolver() const
Returns whether using the exact solver is forced.
Definition sub.h:148
virtual bool exceptionBranch()
Can be used to specify a problem specific criteria for enforcing a branching step.
Definition sub.h:1425
virtual PHASE branching()
Performs branching.
double dualBound_
The dual bound of the subproblem.
Definition sub.h:1477
virtual int set(int i, FSVarStat::STATUS newStat, bool &newValue)
Sets a variable.
virtual void _deactivate()
Deallocates the memory which is not required after the optimization of the subproblem.
int addVarBufferSpace() const
Can be used to determine the maximal number of the variables which still can be added to the variable...
Definition sub.h:1836
bool objAllInteger() const
Tests if all active variables and objective function coefficients are integer.
virtual int _removeCons(ArrayBuffer< int > &remove)
Removes the constraints with numbers remove from the set of active constraints.
const Master * master() const
Returns the const master of the optimization.
Definition sub.h:324
bool allBranchOnSetVars_
If true, then the branching rule of the subproblem and of all ancestor on the path to the root node a...
Definition sub.h:1495
ArrayBuffer< int > * removeConBuffer_
The buffer of the constraints which are removed at the beginning of the next iteration.
Definition sub.h:1510
void redCostVarEliminate(ArrayBuffer< int > &remove)
Retrieves all variables with "wrong" reduced costs.
int id() const
Returns the identity number of the subproblem.
Definition sub.h:154
double lBound(int i) const
Can be used to access the lower of an active variable of the subproblem.
Definition sub.h:246
LpSub * lp_
A pointer to the corresponding linear program.
Definition sub.h:1449
double * bInvRow_
A row of the basis inverse associated with the infeasible variable infeasVar_ or slack variable infea...
Definition sub.h:1519
int nIter_
The number of iterations in the cutting plane phase.
Definition sub.h:1480
int findNonFixedSet(ArrayBuffer< int > &branchVar, VarType::TYPE branchVarType)
Selects the first variables that are neither fixed nor set.
virtual int initializeLp()
Initializes the linear program.
virtual void selectCons()
Is called before constraint are selected from the constraint buffer.
Definition sub.h:1032
Variable * variable(int i) const
Returns a pointer to the i-th active variable.
Definition sub.h:1866
int lastIterVarAdd_
The last iteration in which variables have been added.
Definition sub.h:1486
CutBuffer< Variable, Constraint > * addVarBuffer_
The buffer of the newly generated variables.
Definition sub.h:1501
virtual int pricing()
Should generate inactive variables which do not price out correctly.
Definition sub.h:935
virtual int optimize()
Performs the optimization of the subproblem.
Array< LPVARSTAT * > * lpVarStat_
A pointer to an array storing the status of each active variable in the linear program.
Definition sub.h:1462
virtual void reoptimize()
Repeats the optimization of an already optimized subproblem.
int nOpt_
The number of optimizations of the subproblem.
Definition sub.h:1762
int findNonFixedSet(int &branchVar, VarType::TYPE branchVarType)
Selects the first variable that is neither fixed nor set.
virtual int addCons(ArrayBuffer< Constraint * > &constraints, Pool< Constraint, Variable > *pool=nullptr, ArrayBuffer< bool > *keepInPool=nullptr, ArrayBuffer< double > *rank=nullptr)
Tries to add new constraints to the constraint buffer and a pool.
bool relativeReserve_
If this member is true then the space reserve of the following three members varReserve_,...
Definition sub.h:1772
virtual LP::METHOD chooseLpMethod(int nVarRemoved, int nConRemoved, int nVarAdded, int nConAdded)
Controls the method used to solve a linear programming relaxation.
TailOff * tailOff_
A pointer to the tailing off manager.
Definition sub.h:1474
FSVarStat * fsVarStat(int i) const
Returns a pointer to the status of fixing/setting of the i-th variable.
Definition sub.h:292
virtual void _selectCons(ArrayBuffer< PoolSlot< Constraint, Variable > * > &newCons)
Selects the master_->maxConAdd() best constraints from the buffered constraints and stores them in ne...
int id_
The number of the subproblem.
Definition sub.h:1750
double dualBound() const
Returns a bound which is "better" than the optimal solution of the subproblem w.r....
Definition sub.h:182
virtual PHASE fathoming()
Fathoms the node, and if certain conditions are satisfied, also its ancestor.
virtual void initializeVars(int maxVar)
Initializes the active variable set.
virtual int _setByLogImp(bool &newValues)
Tries to set variables according to logical implications of already set and fixed variables.
virtual void getBase()
Updates the status of the variables and the slack variables.
virtual bool exceptionFathom()
Can be used to specify a problem specific fathoming criterium that is checked before the separation o...
Definition sub.h:1416
virtual int _conEliminate()
Returns the number of eliminated constraints.
bool forceExactSolver_
Indicates whether to force the use of an exact solver to prepare branching etc.
Definition sub.h:1806
virtual int addCons(ArrayBuffer< PoolSlot< Constraint, Variable > * > &newCons)
Adds constraints to the active constraints and the linear program.
virtual bool pausing()
Sometimes it is appropriate to put a subproblem back into the list of open subproblems.
Definition sub.h:969
virtual int _makeFeasible()
Is called if the LP is infeasible and adds inactive variables, which can make the LP feasible again,...
int addConBufferSpace() const
Can be used to determine the maximal number of the constraints which still can be added to the constr...
Definition sub.h:1831
bool ancestor(const Sub *sub) const
Returns true if this subproblem is an ancestor of the subproblem sub, false otherwise.
ArrayBuffer< Sub * > * sons_
The sons of the node in the branch-and-cut tree.
Definition sub.h:1756
bool integerFeasible()
Can be used to check if the solution of the LP-relaxation is primally feasible if integrality is sufi...
bool genNonLiftCons_
If true, then the management of non-liftable constraints is performed.
Definition sub.h:1528
double upperBound() const
Returns an upper bound on the optimal solution of the subproblem.
Definition sub.h:1884
virtual void selectVars()
Is called before variables are selected from the variable buffer.
Definition sub.h:1025
Sub(Master *master, double conRes, double varRes, double nnzRes, bool relativeRes=true, ArrayBuffer< PoolSlot< Constraint, Variable > * > *constraints=nullptr, ArrayBuffer< PoolSlot< Variable, Constraint > * > *variables=nullptr)
Creates the root node of the enumeration tree.
LPVARSTAT * lpVarStat(int i) const
Returns a pointer to the status of the variable i in the last solved linear program.
Definition sub.h:298
double nnzReserve() const
Returns the additional space for nonzero elements of the constraint matrix when it is passed to the L...
Definition sub.h:347
virtual int initMakeFeas(ArrayBuffer< InfeasCon * > &infeasCon, ArrayBuffer< Variable * > &newVars, Pool< Variable, Constraint > **pool)
The default implementation of the virtual initMakeFeas() does nothing.
Definition sub.h:798
virtual void newDormantRound()
Increments the counter for the number of rounds the subproblem is dormant.
Definition sub.h:1612
PHASE
The optimization of the subproblem can be in one of the following phases.
Definition sub.h:90
@ Done
The optimization is done.
Definition sub.h:91
@ Branching
We try to generate further subproblems as sons of this subproblem.
Definition sub.h:94
virtual int fix(int i, FSVarStat *newStat, bool &newValue)
Fixes a variable.
virtual int generateBranchRules(ArrayBuffer< BranchRule * > &rules)
Tries to find rules for splitting the current subproblem in further subproblems.
Definition sub.h:576
ogdf::StopwatchCPU localTimer_
Definition sub.h:1803
Active< Variable, Constraint > * actVar_
The active variables of the subproblem.
Definition sub.h:1443
virtual int addBranchingConstraint(PoolSlot< Constraint, Variable > *slot)
Adds a branching constraint to the constraint buffer.
Definition sub.h:1826
Array< FSVarStat * > * fsVarStat_
A pointer to an array storing the status of fixing and setting of the active variables.
Definition sub.h:1459
STATUS status() const
Returns the status of the subproblem optimization.
Definition sub.h:157
Sub * father_
A pointer to the father in the branch-and-cut tree.
Definition sub.h:1446
double * xVal_
The last LP-solution.
Definition sub.h:1513
virtual int _varEliminate()
Returns the number of eliminated variables.
int nVar() const
Returns the number of active variables.
Definition sub.h:1841
virtual int _separate()
Returns the number of generated cutting planes.
CutBuffer< Constraint, Variable > * addConBuffer_
The buffer of the newly generated constraints.
Definition sub.h:1504
virtual int solveLp()
Solves the LP-relaxation of the subproblem.
int closeHalfExpensive(int &branchVar, VarType::TYPE branchVarType)
Selects a single branching variable of type branchVarType, with fractional part close to and high ab...
int nCon() const
Returns the number of active constraints.
Definition sub.h:1846
void ignoreInTailingOff()
Can be used to control better the tailing-off effect.
virtual void removeCons(ArrayBuffer< int > &remove)
Adds constraints to the buffer of the removed constraints.
virtual int variablePoolSeparation(int ranking=0, Pool< Variable, Constraint > *pool=nullptr, double minViolation=0.001)
Tries to generate inactive variables from a pool.
int closeHalf(int &branchVar, VarType::TYPE branchVarType)
Searches a branching variable of type branchVarType, with fraction as close to as possible.
int nDormantRounds() const
Definition sub.h:409
double lowerBound() const
Returns a lower bound on the optimal solution of the subproblem.
Definition sub.h:1876
Active< Variable, Constraint > * actVar() const
Returns a pointer to the currently active variables.
Definition sub.h:217
virtual int constraintPoolSeparation(int ranking=0, Pool< Constraint, Variable > *pool=nullptr, double minViolation=0.001)
Tries to generate inactive constraints from a pool.
int infeasCon_
The number of an infeasible constraint.
Definition sub.h:1522
virtual int _removeVars(ArrayBuffer< int > &remove)
Removes the variables with numbers remove from the set of active variables.
Array< double > * lBound_
A pointer to an array with the local lower bound of the active variables.
Definition sub.h:1465
Sub(Master *master, Sub *father, BranchRule *branchRule)
Creates a non-root node of the enumeration tree.
double lpRankBranchingRule(BranchRule *branchRule, int iterLimit=-1)
Computes the rank of a branching rule by modifying the linear programming relaxation of the subproble...
LP::METHOD lastLP_
The method that was used to solve the last LP.
Definition sub.h:1801
virtual int set(int i, FSVarStat *newStat, bool &newValue)
Sets a variable.
virtual double fixSetNewBound(int i)
Returns the value which the upper and lower bounds of a variable should take after it is fixed or set...
Array< SlackStat * > * slackStat_
A pointer to an array storing the statuses of the slack variables of the last solved linear program.
Definition sub.h:1471
virtual int _initMakeFeas()
Tries to add variables to restore infeasibilities detected at initialization time.
virtual int prepareBranching(bool &lastIteration)
Is called before a branching step to remove constraints.
virtual void varRealloc(int newSize)
Reallocates memory that at most newSize variables can be handled in the subproblem.
virtual void _selectVars(ArrayBuffer< PoolSlot< Variable, Constraint > * > &newVars)
Selects the master_->maxVarAdd() best variables from the buffered variables.
int maxIterations_
The maximum number of iterations in the cutting plane phase.
Definition sub.h:1759
virtual bool goodCol(Column &col, Array< double > &row, double x, double lb, double ub)
virtual bool solveApproxNow()
The default implementation always returns false.
Definition sub.h:1433
virtual int setByRedCost()
Tries to set variables according to the reduced cost criterion.
virtual LpSub * generateLp()
Instantiates an LP for the solution of the LP-relaxation in this subproblem.
Master * master_
A pointer to the corresponding master of the optimization.
Definition sub.h:1437
virtual void basicConEliminate(ArrayBuffer< int > &remove)
Retrieves all dynamic constraints having basic slack variable.
Active< Constraint, Variable > * actCon_
The active constraints of the subproblem.
Definition sub.h:1440
bool _atLowerBound(int i)
Returns true iff the current value of variable i in the primal lp is equal to its lower bound.
int level() const
Returns the level of the subproblem in the branch-and-bound tree.
Definition sub.h:151
double varReserve_
The additional space for variables.
Definition sub.h:1775
double nnzReserve_
The additional space for nonzeros.
Definition sub.h:1781
virtual void fathomTheSubTree()
Fathoms all nodes in the subtree rooted at this subproblem.
double * yVal_
The dual variables of the last linear program.
Definition sub.h:1516
Active< Constraint, Variable > * actCon() const
Returns a pointer to the currently active constraints.
Definition sub.h:214
virtual void activate()
Can be used as an entrance point for problem specific activations.
Definition sub.h:556
double conReserve_
The additional space for constraints.
Definition sub.h:1778
virtual bool fixAndSetTime()
Controls if variables should be fixed or set when all variables price out correctly.
Definition sub.h:1139
void removeVar(int i)
Remove variable i from the set of active variables.
Definition sub.h:344
virtual double guarantee() const
May not be called if the lower bound is 0 and upper bound not equal to 0.
void removeVars(ArrayBuffer< int > &remove)
Removes the variables in remove from the set of active variables.
int closeHalfExpensive(ArrayBuffer< int > &variables, VarType::TYPE branchVarType)
Selects several candidates for branching variables of type branchVarType.
virtual bool removeNonLiftableCons()
virtual int addVars(ArrayBuffer< PoolSlot< Variable, Constraint > * > &newVars)
Adds both the variables in newVars to the set of active variables and to the linear program of the su...
void maxIterations(int max)
Sets the maximal number of iterations in the cutting plane phase.
double xVal(int i) const
Returns the value of the i-th variable in the last solved linear program.
Definition sub.h:304
virtual int addVars(ArrayBuffer< Variable * > &variables, Pool< Variable, Constraint > *pool=nullptr, ArrayBuffer< bool > *keepInPool=nullptr, ArrayBuffer< double > *rank=nullptr)
Tries to add new variables to the variable buffer and a pool.
int nDormantRounds_
The number of subproblem optimizations the subproblem has already the status Dormant.
Definition sub.h:1784
virtual int setting(bool &newValues)
Tries to set variables by reduced cost criteria and logical implications like fixing().
bool ignoreInTailingOff_
If this flag is set to true then the next LP-solution is ignored in the tailing-off control.
Definition sub.h:1798
virtual void infeasibleSub()
Should be called if a subproblem turns out to be infeasible.
virtual bool feasible()=0
Must check the feasibility of a solution of the LP-relaxation.
SlackStat * slackStat(int i) const
Returns a pointer to the status of the slack variable i in the last solved linear program.
Definition sub.h:229
Master * master()
Returns the master of the optimization.
Definition sub.h:321
int maxCon() const
Returns the maximum number of constraints which can be handled without reallocation.
Definition sub.h:1856
virtual bool guaranteed() const
virtual double dualRound(double x)
LpSub * lp() const
Returns a pointer to the linear program of the subproblem.
Definition sub.h:202
const Sub * father() const
Returns a pointer to the father of the subproblem in the branch-and-bound tree.
Definition sub.h:199
Tailing off manager.
Definition tailoff.h:58
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
An array that keeps track of the number of inserted elements; also usable as an efficient stack.
Definition ArrayBuffer.h:64
void push(E e)
Puts a new element in the buffer.
The parameterized class Array implements dynamic arrays of type E.
Definition Array.h:219
Implements a stopwatch measuring CPU time.
Definition Stopwatch.h:157
#define OGDF_EXPORT
Specifies that a function or class is exported by the OGDF dynamic library (shared object / DLL),...
Definition config.h:117
constraint.
cutbuffer.
status of fixed and set variables.
linear program.
linear program of a subproblem.
variable.
vartype.