54template<
class BaseType,
class CoType>
class StandardPool;
99 static const char* STATUS_[];
117 static const char *ENUMSTRAT_[];
130 static const char *BRANCHINGSTRAT_[];
150 static const char* PRIMALBOUNDMODE_[];
163 static const char* SKIPPINGMODE_[];
177 static const char* CONELIMMODE_[];
189 static const char* VARELIMMODE_[];
202 static const char* VBCMODE_[];
209 enum OSISOLVER {
Cbc, Clp, CPLEX, DyLP, FortMP, GLPK, MOSEK, OSL, SoPlex, SYMPHONY, XPRESS_MP, Gurobi, Csdp };
212 static const char* OSISOLVER_[];
239 Master(
const char *problemName,
bool cutting,
bool pricing,
241 double eps = 1.0e-4,
double machineEps = 1.0e-7,
242 double infinity = 1.0e30,
268 double lowerBound()
const;
271 double upperBound()
const;
506 int nSub()
const {
return nSub_; }
509 int nLp()
const {
return nLp_; }
Declaration of stopwatch classes.
Global data and functions.
The master of the optimization.
Sub * root_
The root node of the enumeration tree.
int maxVarAdd() const
Returns the maximal number of variables which should be added in the column generation algorithm.
int varElimAge() const
Returns the age for the elimination of variables by the reduced cost criterion.
bool betterPrimal(double x) const
Can be used to check if a value is better than the best know primal bound.
ogdf::StopwatchCPU lpSolverTime_
History * history() const
Returns a pointer to the object storing the solution history of this branch and cut problem.
int maxNSub() const
Returns the maximal number of subproblems to be processed.
int maxLevel() const
Returns the maximal depth up to which the enumeration should be performed.
void defaultLpSolver(OSISOLVER osiSolver)
Changes the default Lp solver to osiSolver.
void maxVarAdd(int max)
Changes the maximal number of variables that are added in an iteration of the subproblem optimization...
int nBranchingVariableCandidates_
The number of candidates that are evaluated for branching on variables.
ENUMSTRAT enumerationStrategy_
The enumeration strategy.
void nStrongBranchingIterations(int n)
Sets the number of simplex iterations that are performed when testing candidates for branching variab...
void maxConAdd(int max)
Sets the maximal number of constraints that are added in an iteration of the cutting plane algorithm.
int bestFirstSearch(const Sub *s1, const Sub *s2) const
Implements the best first search enumeration.
bool newRootReOptimize_
If true, then an already earlier processed node is reoptimized if it becomes the new root of the rema...
int maxConBuffered_
The size of the buffer for generated cutting planes.
int maxNSub_
The maximal number of subproblems to be processed.
int highestLevel_
The highest level which has been reached in the enumeration tree.
void maxConBuffered(int max)
Changes the maximal number of constraints that are buffered in an iteration of the cutting plane algo...
CONELIMMODE conElimMode_
The way constraints are automatically eliminated in the cutting plane algorithm.
void pricingFreq(int f)
Sets the number of linear programs being solved between two additional pricing steps to f.
void enumerationStrategy(ENUMSTRAT strat)
Changes the enumeration strategy to strat.
double lowerBound() const
Returns the value of the global lower bound.
void treeInterfaceNewNode(Sub *sub) const
Adds the subproblem sub to the stream storing information for graphical output of the enumeration tre...
int nStrongBranchingIterations() const
The number of simplex iterations that are performed when testing candidates for branching variables w...
void branchingStrategy(BRANCHINGSTRAT strat)
Changes the branching strategy to strat.
ogdf::StopwatchCPU branchingTime_
The timer for the cpu time spent in determining the branching rules.
double requiredGuarantee() const
The guarantee specification for the optimization.
void primalBound(double x)
Sets the primal bound to x and makes a new entry in the solution history.
void varElimAge(int age)
Changes the age for the elimination of variables by the reduced cost criterion to age.
StandardPool< Constraint, Variable > * conPool() const
Returns a pointer to the default pool storing the constraints of the problem formulation.
void maxCowTime(int64_t seconds)
Sets the maximally allowed wall-clock time to seconds.
BRANCHINGSTRAT
This enumeration defines the two currently implemented branching variable selection strategies.
@ CloseHalf
Selects the variable with fractional part closest to 0.5.
BRANCHINGSTRAT branchingStrategy_
The branching strategy.
const ogdf::StopwatchCPU * totalTime() const
returns a pointer to the timer measuring the total cpu time for the optimization.
VARELIMMODE varElimMode() const
Returns the mode for the elimination of variables.
double rootDualBound() const
Returns the dual bound at the root node.
const ogdf::StopwatchCPU * lpSolverTime() const
Return a pointer to the timer measuring the cpu time required by the LP solver.
virtual void initializePools(ArrayBuffer< Constraint * > &constraints, ArrayBuffer< Variable * > &variables, int varPoolSize, int cutPoolSize, bool dynamicCutPool=false)
Sets up the default pools for variables, constraints, and cutting planes.
const string & optimumFileName() const
Returns the name of the file that stores the optimum solutions.
void maxNSub(int ml)
Changes the maximal number of subproblems to ml.
double tailOffPercent_
The minimal change of the LP-value on the tailing off analysis.
ENUMSTRAT enumerationStrategy() const
Returns the enumeration strategy.
StandardPool< Constraint, Variable > * cutPool_
The default pool of dynamically generated constraints.
int maxIterations() const
Returns the maximal number of iterations per subproblem optimization (-1 means no iteration limit).
void _setDefaultLpParameters()
Initializes the LP solver specific default parameters if they are not read from .abacus.
void nBranchingVariableCandidates(int n)
Sets the number of tested branching variable candidates to n.
void newFixed(int n)
Increments the counter of the number of fixed variables by n.
const ogdf::StopwatchCPU * lpTime() const
Returns a pointer to the timer measuring the cpu time spent in members of the LP-interface.
double varElimEps_
The tolerance for the elimination of variables by the mode ReducedCost.
Master(const char *problemName, bool cutting, bool pricing, OptSense::SENSE optSense=OptSense::Unknown, double eps=1.0e-4, double machineEps=1.0e-7, double infinity=1.0e30, bool readParamFromFile=false)
The constructor.
bool fixSetByRedCost() const
int maxIterations_
The maximal number of iterations of the cutting plane/column generation algorithm in the subproblem.
int nStrongBranchingIterations_
The number of simplex iterations that are performed when testing a branching variable candidate withi...
void dualBound(double x)
Sets the dual bound to x and makes a new entry in the solution history.
void addVars(int n)
Increments the counter for the total number of added variables by n.
int minDormantRounds() const
Returns the maximal number of rounds, i.e., number of subproblem optimizations, a subproblem is dorma...
Master(const Master &rhs)
bool primalViolated(double x) const
Can be used to compare a value with the one of the best known primal bound.
PRIMALBOUNDMODE pbMode_
The mode of the primal bound initialization.
void maxLevel(int ml)
This version of the function maxLevel() changes the maximal enumeration depth.
void varElimMode(VARELIMMODE mode)
Changes the variable elimination mode to mode.
int maxVarBuffered_
The size of the buffer for generated variables.
bool newRootReOptimize() const
double dualBound_
The best known dual bound.
int nNewRoot() const
Returns the number of root changes of the remaining branch-and-cut tree.
void removeCons(int n)
Increments the counter for the total number of removed constraints by n.
void minDormantRounds(int nRounds)
Sets the number of rounds a subproblem should stay dormant to nRounds.
int nRemCons_
The total number of removed constraints.
double primalBound() const
Returns the value of the primal bound.
Sub * select()
Returns a pointer to an open subproblem for further processing.
double guarantee() const
Can be used to access the guarantee which can be given for the best known feasible solution.
CONELIMMODE conElimMode() const
Returns the mode for the elimination of constraints.
STATUS
The various statuses of the optimization process.
@ Unprocessed
The initial status, before the optimization starts.
@ Error
An error occurred during the optimization process.
@ MaxLevel
The status, if subproblems are ignored since the maximum enumeration level is exceeded.
@ Processing
The status while the optimization is performed.
@ MaxCpuTime
The status, if the optimization terminates since the maximum cpu time is exceeded.
@ MaxNSub
The status, if the optimization terminates since the maximum number of subproblems is reached.
@ MaxCowTime
The status, if the optimization terminates since the maximum wall-clock time is exceeded.
const ogdf::StopwatchCPU * pricingTime() const
Returns a pointer to the timer measuring the cpu time spent in pricing.
STATUS status_
The current status of the optimization.
virtual void assignParameters()
Assigns the parameters that were read from a file to the member variables of the master.
virtual bool setSolverParameters(OsiSolverInterface *interface, bool solverIsApprox)
Sets solver specific parameters.
void optimumFileName(const char *name)
Changes the name of the file in which the value of the optimum solution is searched.
int64_t maxCpuTime() const
Returns the maximal cpu time (in seconds) which can be used by the optimization.
VARELIMMODE
This enumeration defines the ways for automatic variable elimination during the column generation alg...
@ NoVarElim
No variables are eliminated.
bool knownOptimum(double &optVal) const
Opens the file specified with the parameter OptimumFileName in the configuration file ....
bool betterDual(double x) const
Returns true if x is better than the best known dual bound; false otherwise.
virtual ~Master()
The destructor.
void rRoot(Sub *newRoot, bool reoptimize)
Sets the root of the remaining branch-and-cut tree to newRoot.
bool feasibleFound() const
We use this function, e.g., to adapt the enumeration strategy in the DiveAndBest-Strategy.
void maxCpuTime(int hour, int min, int sec)
Sets the maximally allowed cpu time for the optimization to hour, min, sec.
ogdf::StopwatchCPU improveTime_
The timer for the cpu time spent in the heuristics for the computation of feasible solutions.
bool delayedBranching(int nOpt) const
Returns true if the number of optimizations nOpt of a subproblem exceeds the delayed branching thresh...
void dbThreshold(int threshold)
Sets the number of optimizations of a subproblem until sons are created in Sub::branching().
void removeVars(int n)
Increments the counter for the total number of removed variables by n.
void conElimAge(int age)
Changes the age for the elimination of constraints to age.
StandardPool< Constraint, Variable > * cutPool() const
Returns a pointer to the default pool for the generated cutting planes.
OSISOLVER
This enumeration defines which solvers can be used to solve the LP-relaxations.
void status(STATUS stat)
Sets the status of the Master.
void varElimEps(double eps)
Changes the tolerance for the elimination of variables by the reduced cost criterion to eps.
History * history_
The solution history.
void tailOffPercent(double p)
Sets the minimal change of the dual bound for the tailing off analysis to p.
const ogdf::StopwatchCPU * separationTime() const
Returns a pointer to the timer measuring the cpu time spent in the separation of cutting planes.
StandardPool< Constraint, Variable > * conPool_
The default pool with the constraints of the problem formulation.
double primalBound_
The best known primal bound.
int nSubSelected() const
Returns the number of subproblems which have already been selected from the set of open subproblems.
FixCand * fixCand() const
Returns a pointer to the object storing the variables which are candidates for being fixed.
Sub * rRoot_
The root node of the remaining enumeration tree.
OptSense optSense_
The sense of the objective function.
int nLp_
The number of solved LPs.
CONELIMMODE
This enumeration defines the ways for automatic constraint elimination during the cutting plane phase...
@ NonBinding
Nonbinding constraints are eliminated.
@ NoConElim
No constraints are eliminated.
void writeTreeInterface(const string &info, bool time=true) const
Writes the string info to the stream associated with the Tree Interface.
FixCand * fixCand_
The variables which are candidates for being fixed.
int minDormantRounds_
The minimal number of rounds, i.e., number of subproblem optimizations, a subproblem is dormant,...
void conElimMode(CONELIMMODE mode)
Changes the constraint elimination mode to mode.
void _initializeParameters()
Reads the parameter-file .abacus.
int maxConBuffered() const
Returns the size of the buffer for generated constraints in the cutting plane algorithm.
void skipFactor(int f)
Sets the frequency for constraint and variable generation to f.
void conElimEps(double eps)
Changes the tolerance for the elimination of constraints by the slack criterion to eps.
void _initializeLpParameters()
bool showAverageCutDistance_
If true then the average distance of the added cutting planes is output every iteration of the cuttin...
ogdf::StopwatchCPU lpTime_
The timer for the cpu time spent in the LP-interface.
bool eliminateFixedSet_
If true, then nonbasic fixed and set variables are eliminated.
void fixSetByRedCost(bool on)
Turns fixing and setting variables by reduced cost on or off.
double tailOffPercent() const
Returns the minimal change of the dual bound for the tailing off analysis in percent.
int conElimAge_
The number of iterations an elimination criterion must be satisfied until a constraint can be removed...
double conElimEps() const
Returns the zero tolerance for the elimination of constraints by the slack criterion.
StandardPool< Variable, Constraint > * varPool_
The default pool with the variables of the problem formulation.
LpMasterOsi * lpMasterOsi_
bool objInteger_
true, if all objective function values of feasible solutions are assumed to be integer.
void rootDualBound(double x)
Updates the final dual bound of the root node.
ogdf::StopwatchWallClock totalCowTime_
The timer for the total elapsed time.
double requiredGuarantee_
The guarantee in percent which should be reached when the optimization stops.
int64_t maxCowTime() const
Returns the maximal wall-clock time (in seconds) which can be used by the optimization.
int pricingFreq_
The number of solved LPs between two additional pricing steps.
int tailOffNLp_
The number of LP-iterations for the tailing off analysis.
LpMasterOsi * lpMasterOsi() const
virtual int equalSubCompare(const Sub *s1, const Sub *s2) const
Is called from the function bestFirstSearch() and from the function depthFirstSearch() if the subprob...
string problemName_
The name of the optimized problem.
int diveAndBestFirstSearch(const Sub *s1, const Sub *s2) const
Performs depth-first search until a feasible solution is found, then the search process is continued ...
OpenSub * openSub() const
Returns a pointer to the set of open subproblems.
int maxVarBuffered() const
Returns the size of the buffer for the variables generated in the column generation algorithm.
VBCMODE VbcLog_
Ouput for the Tree Interface is generated depending on the value of this variable.
void treeInterfaceNodeBounds(int id, double lb, double ub)
Updates the node information in the node with number id by writing the lower bound lb and the upper b...
const Master & operator=(const Master &rhs)
int breadthFirstSearch(const Sub *s1, const Sub *s2) const
Implements the breadth first search enumeration strategy, i.e., the subproblem with minimum level is ...
void printLP(bool on)
Turns the output of the linear program in every iteration on or off.
PRIMALBOUNDMODE pbMode() const
Returns the mode of the primal bound initialization.
double upperBound() const
Returns the value of the global upper bound.
bool check() const
Can be used to control the correctness of the optimization if the value of the optimum solution has b...
bool guaranteed() const
Can be used to check if the guarantee requirements are fulfilled.
const OptSense * optSense() const
Returns a pointer to the object holding the optimization sense of the problem.
void showAverageCutDistance(bool on)
Turns the output of the average distance of the added cuts from the fractional solution on or off.
void treeInterfacePaintNode(int id, int color) const
Assigns the color to the subproblem sub in the Tree Interface.
std::ostream * treeStream_
A pointer to the log stream for the VBC-Tool.
const ogdf::StopwatchCPU * improveTime() const
Returns a pointer to the timer measuring the cpu time spent in the heuristics for the computation of ...
void vbcLog(VBCMODE mode)
Changes the mode of output for the Vbc-Tool to mode.
int nSub_
The number of generated subproblems.
void maxIterations(int max)
Changes the default value for the maximal number of iterations of the optimization of a subproblem.
int maxVarAdd_
The maximal number of added variables per iteration of the column generation algorithm.
double dualBound() const
Returns the value of the dual bound.
int conElimAge() const
Returns the age for the elimination of constraints.
void pbMode(PRIMALBOUNDMODE mode)
Sets the mode of the primal bound initialization to mode.
virtual void initializeOptimization()
The default implementation of initializeOptimization() does nothing.
bool solveApprox() const
True, if an approximative solver should be used.
VBCMODE vbcLog() const
Returns the mode of output for the Vbc-Tool.
int nLp() const
Returns the number of optimized linear programs (only LP-relaxations).
bool solveApprox_
If true, then an approximative solver is used to solve linear programs.
void countLp()
Increments the counter for linear programs and should be called in each optimization call of the LP-r...
int64_t maxCowTime_
The maximal available wall-clock time.
int maxLevel_
The maximal level in enumeration tree.
void newSub(int level)
Registers a new subproblem which is on level level in enumeration tree.
int pricingFreq() const
Returns the number of linear programs being solved between two additional pricing steps.
int highestLevel() const
Returns the highest level in the tree which has been reached during the implicit enumeration.
void eliminateFixedSet(bool turnOn)
Turns the elimination of fixed and set variables on or off.
int nSubSelected_
The number of subproblems already selected from the list of open subproblems.
ogdf::StopwatchCPU separationTime_
The timer for the cpu time spent in the separation.
STATUS status() const
Returns the status of the Master.
STATUS optimize()
Performs the optimization by branch-and-bound.
int nNewRoot_
The number of changes of the root of the remaining branch-and-bound tree.
int maxConAdd_
The maximal number of added constraints per iteration of the cutting plane algorithm.
PRIMALBOUNDMODE
This enumeration provides various methods for the initialization of the primal bound.
@ Optimum
The primal bound is initialized with the value of the optimum solution.
int tailOffNLp() const
Returns the number of linear programs considered in the tailing off analysis.
ENUMSTRAT
The enumeration defining the different enumeration strategies for the branch and bound algorithm.
@ DepthFirst
Depth-first search, i.e., select the subproblem with maximal level in the enumeration tree.
@ BreadthFirst
Breadth-first search, i.e., select the subproblem with minimal level in the enumeration tree.
const ogdf::StopwatchCPU * branchingTime() const
Returns a pointer to the timer measuring the cpu time spent in finding and selecting the branching ru...
int depthFirstSearch(const Sub *s1, const Sub *s2) const
Implements the depth first search enumeration strategy, i.e., the subproblem with maximum level is se...
void initializeOptSense(OptSense::SENSE sense)
Can be used to initialize the sense of the optimization in derived classes, if this has not been alre...
VBCMODE
This enumeration defines what kind of output can be generated for the VBCTOOL.
@ NoVbc
No output for the tree interface.
@ File
Output for the tree interface is written to a file.
bool pricing_
If true, then variables are generated in the optimization.
void tailOffNLp(int n)
Sets the number of linear programs considered in the tailing off analysis to n.
ogdf::StopwatchCPU totalTime_
The timer for the total cpu time for the optimization.
int nBranchingVariableCandidates() const
Returns the number of variables that should be tested for the selection of the branching variable.
int64_t maxCpuTime_
The maximal available cpu time.
int skipFactor_
The frequency constraints or variables are generated depending on the skipping mode.
bool printLP_
If true, then the linear program is output every iteration.
string maxCowTimeAsString() const
Returns the maximal wall-clock time (as string hh:mm:ss) which can be used by the optimization.
double varElimEps() const
Returns the zero tolerance for the elimination of variables by the reduced cost criterion.
string optimumFileName_
The name of a file storing a list of optimum solutions of problem instances.
void maxCowTime(const string &t)
Sets the maximally allowed wall-clock time for the optimization to t.
StandardPool< Variable, Constraint > * varPool() const
Returns a pointer to the default pool storing the variables.
BRANCHINGSTRAT branchingStrategy() const
Returns the branching strategy.
double conElimEps_
The tolerance for the elimination of constraints by the mode NonBinding/.
ogdf::StopwatchCPU pricingTime_
The timer for the cpu time spent in pricing.
virtual int enumerationStrategy(const Sub *s1, const Sub *s2)
Analyzes the enumeration strategy set in the parameter file .abacus and calls the corresponding compa...
bool objInteger() const
If true then we assume that all feasible solutions have integral objective function values.
void objInteger(bool b)
Sets the assumption that the objective function values of all feasible solutions are integer.
int nRemVars_
The total number of removed variables.
void treeInterfaceLowerBound(double lb) const
Passes the new lower bound lb to the Tree Interface.
void printGuarantee() const
Writes the guarantee nicely formated on the output stream associated with this object.
int skipFactor() const
Returns the frequency of subproblems in which constraints or variables should be generated.
OSISOLVER defaultLpSolver_
The default LP-Solver.
void maxCpuTime(int64_t seconds)
Sets the maximally allowed cpu time to seconds.
virtual void initializePools(ArrayBuffer< Constraint * > &constraints, ArrayBuffer< Constraint * > &cuts, ArrayBuffer< Variable * > &variables, int varPoolSize, int cutPoolSize, bool dynamicCutPool=false)
Is overloaded such that also a first set of cutting planes can be inserted into the cutting plane poo...
int maxConAdd() const
Returns the maximal number of constraints which should be added in every iteration of the cutting pla...
bool showAverageCutDistance() const
void addCons(int n)
Increments the counter for the total number of added constraints by n.
void printParameters() const
Writes all parameters of the class Master together with their values to the global output stream.
void _outputLpStatistics() const
Prints the LP solver specific statistics.
const ogdf::StopwatchWallClock * totalCowTime() const
Returns a pointer to the timer measuring the total wall clock time.
int varElimAge_
The number of iterations an elimination criterion must be satisfied until a variable can be removed.
int nAddVars_
The total number of added variables.
void treeInterfaceUpperBound(double ub) const
Passes the new upper bound ub to the Tree Interface.
void maxVarBuffered(int max)
Changes the maximal number of variables that are buffered in an iteration of the subproblem optimizat...
int nSub() const
returns the number of generated subproblems.
bool eliminateFixedSet() const
virtual void initializeParameters()
Is only a dummy.
bool cutting_
If true, then constraints are generated in the optimization.
void maxCpuTime(const string &t)
Sets the maximally allowed cpu time for the optimization to t.
int dbThreshold() const
Returns the number of optimizations of a subproblem until sons are created.
VARELIMMODE varElimMode_
The way variables are automatically eliminated in the column generation algorithm.
void newRootReOptimize(bool on)
Turns the reoptimization of new root nodes of the remaining branch and bound tree on or off.
double rootDualBound_
The best known dual bound at the end of the optimization of the root node.
OSISOLVER defaultLpSolver() const
returns the Lp Solver.
string maxCpuTimeAsString() const
Returns the maximal cpu time (as string hh:mm:ss) which can be used by the optimization.
OpenSub * openSub_
The set of open subproblems.
int nAddCons_
The total number of added constraints.
int dbThreshold_
The number of optimizations of an Sub until branching is performed.
virtual void output() const
Does nothing but can be redefined in derived classes for output before the timing statistics.
SKIPPINGMODE skippingMode() const
Returns the skipping strategy.
SKIPPINGMODE skippingMode_
Either constraints are generated only every skipFactor_ subproblem (SkipByNode) only every skipFactor...
void requiredGuarantee(double g)
Changes the guarantee specification tp g.
const string & problemName() const
Returns the name of the instance being optimized (as specified in the constructor of this class).
virtual Sub * firstSub()=0
Should return a pointer to the first subproblem of the optimization, i.e., the root node of the enume...
int nFixed_
The total number of fixed variables.
bool fixSetByRedCost_
If true, then variables are fixed and set by reduced cost criteria.
void skippingMode(SKIPPINGMODE mode)
Sets the skipping strategy to mode.
virtual void terminateOptimization()
The default implementation of terminateOptimization() does nothing.
SKIPPINGMODE
The way nodes are skipped for the generation of cuts.
void _printLpParameters() const
Prints the LP solver specific parameters.
Sub * root() const
Can be used to access the root node of the branch-and-bound tree.
Maintains open subproblems.
SENSE
The enumeration defining the sense of optimization.
bool max() const
Returns true if it is maximization problem,, false otherwise.
An array that keeps track of the number of inserted elements; also usable as an efficient stack.
Implements a stopwatch measuring CPU time.
Implements a stopwatch measuring wall-clock time.
#define OGDF_EXPORT
Specifies that a function or class is exported by the OGDF DLL.
static MultilevelBuilder * getDoubleFactoredZeroAdjustedMerger()