76 #ifdef OGDF_STP_EXACT_LOGGING 113 m_configFile = configfile;
115 #ifdef OGDF_STP_EXACT_LOGGING 119 m_outputLevel = outputLevel;
125 m_maxFlowModuleOption.reset(module);
130 m_addDegreeConstraints = b;
135 m_addIndegreeEdgeConstraints = b;
140 m_addGSEC2Constraints = b;
145 m_addFlowBalanceConstraints = b;
150 m_maxNrAddedCuttingPlanes = b;
155 m_shuffleTerminals = b;
160 m_backCutComputation = b;
165 m_nestedCutComputation = b;
170 m_separationStrategy = b;
175 m_saturationStrategy = b;
180 m_minCardinalityCuts = b;
184 m_primalHeuristic = b;
191 m_callPrimalHeuristic = b;
196 m_poolSizeInitFactor = b;
200 : m_configFile(nullptr)
202 #ifdef OGDF_STP_EXACT_LOGGING
206 , m_addDegreeConstraints(true)
207 , m_addIndegreeEdgeConstraints(true)
208 , m_addGSEC2Constraints(true)
209 , m_addFlowBalanceConstraints(true)
210 , m_maxNrAddedCuttingPlanes(500)
211 , m_shuffleTerminals(true)
212 , m_backCutComputation(true)
213 , m_nestedCutComputation(true)
214 , m_separationStrategy(1)
215 , m_saturationStrategy(1)
216 , m_minCardinalityCuts(true)
217 , m_callPrimalHeuristic(1)
218 , m_primalHeuristic(nullptr)
219 , m_poolSizeInitFactor(5)
246 bool relaxed =
false);
251 delete[] m_bestSolution;
252 delete[] m_terminals;
256 delete m_pWeightedGraphPH;
263 m_configfile = filename;
265 #ifdef OGDF_STP_EXACT_LOGGING 266 void setOutputLevel(
Level outputLevel)
269 this->globalLogLevel(Level::Default);
270 this->localLogMode(LogMode::Log);
271 if (outputLevel >= Level::Minor
272 && outputLevel <= Level::Force) {
273 this->localLogLevel((
Level)outputLevel);
274 this->globalMinimumLogLevel((
Level)outputLevel);
280 m_maxFlowModule = module;
286 return m_maxFlowModule;
376 return new Sub(
this);
382 return ((m_isSolutionEdge[m_mapToBidirectedGraph1[e]])
383 || (m_isSolutionEdge[m_mapToBidirectedGraph2[e]]));
390 int nNodes()
const {
return m_pGraph->numberOfNodes();}
392 int nEdges()
const {
return m_pGraph->numberOfEdges();}
451 void updateBestSolution(
double *values);
453 void updateBestSolutionByEdges(
const List<edge> &sol);
485 if (m_poolSizeMax < m_pCutPool->size())
486 m_poolSizeMax = m_pCutPool->size();
530 virtual void initializeOptimization()
override;
532 virtual void terminateOptimization()
override;
534 virtual void initializeParameters()
override;
705 #ifdef OGDF_STP_EXACT_LOGGING 706 void printCurrentSolution(
bool onlyNonZeros =
true);
712 virtual bool feasible()
override;
717 if (m_alreadySeparated == -1) {
718 m_alreadySeparated = mySeparate();
720 return m_alreadySeparated;
728 #ifdef OGDF_STP_EXACT_LOGGING 729 void printMainInfosInFeasible(
bool header =
false)
const;
734 #ifdef OGDF_STP_EXACT_LOGGING 771 return new Sub(master_,
this, rule);
791 :
abacus::
Variable(master, nullptr , false, false, coeff, lb, ub, vartype)
800 int id()
const {
return m_id;}
839 if ((e != m_e1) && (e != m_e2))
868 , m_coeffOut(coeffOut)
877 if (e->
target() == m_node) {
880 if (e->
source() == m_node) {
915 , m_coeffEdge(coeffEdge)
925 if ((e->
source() == m_edge->source()) && (e->
target() == m_edge->target()))
928 if (e->
target() != m_edge->source())
931 if (e->
source() == m_edge->target())
959 #ifdef OGDF_STP_EXACT_LOGGING 960 cout <<
"Creating new DirectedCutConstraint: " << std::endl;
967 #ifdef OGDF_STP_EXACT_LOGGING 970 cout <<
" marked node " << n << std::endl;
979 m_hashKey += n->index();
983 #ifdef OGDF_STP_EXACT_LOGGING 984 cout <<
" front cut edges:" << std::endl;
987 cout <<
" " << e << std::endl;
990 cout <<
" back cut edges:" << std::endl;
993 cout <<
" " << e << std::endl;
1007 return ((m_marked[e->
source()]) && (!m_marked[e->
target()]));
1014 unsigned hashKey()
const override {
return m_hashKey; };
1016 bool equal(
const ConVar *cv)
const override;
1018 const char *
name()
const override {
return m_name; }
1041 template<
typename T>
1048 :
abacus::
Master(
"MinSteinerTreeDirectedCut::Master", true, false,
abacus::OptSense::Min, eps)
1049 , m_maxFlowModule(nullptr)
1050 , m_configfile(nullptr)
1051 , m_relaxed(relaxed)
1052 , m_relaxedSolValue(-1)
1055 , m_pCutPool(nullptr)
1073 #ifdef OGDF_STP_EXACT_LOGGING 1075 <<
"Master::Master(): default LP solver: " 1089 #ifdef OGDF_STP_EXACT_LOGGING 1098 nodeMapping[nOrig] = n;
1103 #ifdef OGDF_STP_EXACT_LOGGING 1110 #ifdef OGDF_STP_EXACT_LOGGING 1132 nodeMapping[eOrig->
target()]);
1145 #ifdef OGDF_STP_EXACT_LOGGING 1146 lout(
Level::Minor) <<
" " << eOrig <<
"[" << e1 <<
", " << e2 <<
"]" << flush;
1149 #ifdef OGDF_STP_EXACT_LOGGING 1165 #ifdef OGDF_STP_EXACT_LOGGING 1202 template<
typename T>
1207 bool objectiveInteger =
false;
1212 #ifdef OGDF_STP_EXACT_LOGGING 1214 <<
"Master::initializeParameters(): Error reading parameters." 1215 <<
"Using default values." << endl;
1218 #ifdef OGDF_STP_EXACT_LOGGING 1221 setOutputLevel(static_cast<Level>(outputLevel));
1242 #ifdef OGDF_STP_EXACT_LOGGING 1244 <<
"Master::initializeParameters(): parameters:"<< endl
1264 <<
"\tObjective integer " << this->
objInteger() << endl
1270 template<
typename T>
1274 #ifdef OGDF_STP_EXACT_LOGGING 1276 <<
"Master::initializeOptimization(): Instance properties:" << endl
1280 <<
"\tRoot node : " <<
m_root << endl
1302 #ifdef OGDF_STP_EXACT_LOGGING 1303 lout(
Level::Minor) <<
"\tadding variable x_" << i <<
", edge " << e << endl;
1310 #ifdef OGDF_STP_EXACT_LOGGING 1311 lout(
Level::Minor) <<
"\tmuting variable x_" << i <<
", edge " << e << endl;
1314 variables.push(eVar);
1339 basicConstraints.
push(newCon);
1341 marked[
m_twin[e]] =
true;
1343 #ifdef OGDF_STP_EXACT_LOGGING 1344 lout(
Level::Minor) <<
"\tadding constraint " << i++ <<
" GSEC2: edge " << e << endl;
1372 basicConstraints.
push(newCon);
1374 #ifdef OGDF_STP_EXACT_LOGGING 1375 lout(
Level::Minor) <<
"\tadding constraint " << i++ <<
" Degree: node " << n << endl;
1385 basicConstraints.
push(newCon);
1387 #ifdef OGDF_STP_EXACT_LOGGING 1388 lout(
Level::Minor) <<
"\tadding constraint " << i++ <<
" Indegree: edge " << e << endl;
1399 basicConstraints.
push(newCon);
1401 #ifdef OGDF_STP_EXACT_LOGGING 1402 lout(
Level::Minor) <<
"\tadding constraint " << i++ <<
" Flow-Balance: node " << n << endl;
1420 #ifdef OGDF_STP_EXACT_LOGGING 1426 template<
typename T>
1438 #ifdef OGDF_STP_EXACT_LOGGING 1450 <<
"Finished optimization. Statistics:" << endl
1451 <<
"Solution " << endl
1453 <<
" rounded sol. value " << ((int)this->
primalBound()) << endl
1454 <<
" nr edges " << nOnesInSol << endl
1458 <<
"Nr subproblems " << this->
nSub() << endl
1459 <<
"Nr solved LPs " << this->
nLp() << endl
1460 <<
"nr solved LPs in root " <<
m_nIterRoot << endl
1466 <<
"Objective integer " << (this->
objInteger()?
"true":
"false") << endl
1470 <<
"Total time " << *this->
totalTime() << endl
1472 <<
"LP time " << *this->
lpTime() << endl
1483 int nDuplicates, nCollisions;
1486 <<
"Cutpool duplications " << nDuplicates << endl
1487 <<
"Cutpool collisions " << nCollisions << endl
1493 template<
typename T>
1497 double eps = this->
eps();
1498 double oneMinusEps = 1.0 -
eps;
1500 if (values[i] > oneMinusEps)
1503 if (values[i] < eps)
1510 template<
typename T>
1523 template<
typename T>
1526 , m_alreadySeparated(-1)
1540 template<
typename T>
1542 :
abacus::
Sub(master, father, branchRule)
1546 #ifdef OGDF_STP_EXACT_LOGGING 1548 << std::setw(7) << this->
id()
1549 << std::setw(7) << this->
nIter_ 1550 <<
" new subproblem, parent=" << father->
id() << endl;
1562 #ifdef OGDF_STP_EXACT_LOGGING 1563 template<
typename T>
1571 << std::setw(7) <<
"id" 1572 << std::setw(7) <<
"iter" 1573 << std::setw(10) <<
"lp value" 1574 << std::setw(10) <<
"gl. LB" 1575 << std::setw(10) <<
"gl. UB" 1576 << std::setw(10) <<
"nSub" 1577 << std::setw(10) <<
"nOpenSub" 1582 << std::setw(7) << this->
id()
1583 << std::setw(7) << this->
nIter_ 1585 if (this->
id() == 1)
1598 <<
"\tcurrent LP:" << endl;
1605 template<
typename T>
1610 double oneMinusEps = 1.0 - eps;
1612 #ifdef OGDF_STP_EXACT_LOGGING 1614 this->printMainInfosInFeasible(
true);
1617 this->printMainInfosInFeasible(
false);
1630 if (this->
id() == 1) {
1639 if ((
xVal_[i] > eps) && (
xVal_[i] < oneMinusEps)) {
1647 #ifdef OGDF_STP_EXACT_LOGGING 1649 <<
"\tsolution is fractional -> Branching." << endl;
1657 #ifdef OGDF_STP_EXACT_LOGGING 1659 << std::setw(7) << this->
id()
1660 << std::setw(7) << this->
nIter_ 1661 <<
" found better integer solution with value " <<
lp_->
value();
1664 printCurrentSolution();
1676 #ifdef OGDF_STP_EXACT_LOGGING 1677 template<
typename T>
1683 double oneMinusEps = 1.0 - eps;
1684 for (
int i = 0; i <
nVar(); i++) {
1686 if (!onlyNonZeros) {
1692 if ((
xVal_[i] > oneMinusEps) && (
xVal_[i] < 1+eps)) {
1706 template<
typename T>
1710 #ifdef OGDF_STP_EXACT_LOGGING 1712 <<
"Sub::mySeparate(): id=" 1713 << this->
id() <<
", iter=" << this->
nIter_ << endl;
1717 double cardEps = eps / 100;
1718 double oneMinusEps = 1 - eps;
1725 node *terminal =
new node[nTerminals];
1727 for (
int i = 0; i < nTerminals; i++) {
1728 terminal[i] = masterTerminals[i];
1735 for (
int i = 0; i < nTerminals-1; i++) {
1738 terminal[i] = terminal[j];
1743 #ifdef OGDF_STP_EXACT_LOGGING 1746 <<
"Sub::mySeparate(): considered terminal ordering: ";
1747 for (
int i = 0; i < nTerminals; i++)
1754 capacities.
init(g, 0);
1758 capacities[e] += cardEps;
1761 #ifdef OGDF_STP_EXACT_LOGGING 1763 <<
"Sub::mySeparate(): current capacities (>0) for mincut computation:" << endl;
1765 if (capacities[e] >= 2*cardEps) {
1777 double cutValue = 2.0;
1779 double cutValueBack = 0.0;
1781 int nOtherNodes = 0;
1783 double uBound = 1 + nEdgesU*cardEps;
1791 int cardinalityCut, cardinalityBackcut;
1792 cardinalityCut = cardinalityBackcut = 0;
1803 #ifdef OGDF_STP_EXACT_LOGGING 1805 <<
"Sub::mySeparate(): computing minimum cut between root " << r <<
" and " << t << flush;
1821 cutValue = mf->
computeFlow(capacities, r, t, flow);
1822 #ifdef OGDF_STP_EXACT_LOGGING 1826 <<
" " << flowEdge <<
" : " 1827 << flow[flowEdge] <<
" / " << capacities[flowEdge] << endl;
1833 minSTCut.
call(g, capacities, flow, r, t);
1838 #ifdef OGDF_STP_EXACT_LOGGING 1846 cutValue -= cardEps;
1849 cutValueBack += capacities[e] - cardEps;
1855 cutValueBack += capacities[e];
1861 cardinalityCut = cardinalityBackcut = 0;
1866 cardinalityBackcut++;
1870 #ifdef OGDF_STP_EXACT_LOGGING 1872 <<
", actual cutvalue=" << cutValue;
1875 <<
", actual cutValueBack=" << cutValueBack;
1880 if (cutValue < oneMinusEps) {
1886 newConstraints.
push(newCut);
1888 #ifdef OGDF_STP_EXACT_LOGGING 1890 <<
"Sub::mySeparate(): found violated cut:" << endl;
1896 && (cutValueBack <= oneMinusEps)) {
1901 newConstraints.
push(newBackCut);
1903 #ifdef OGDF_STP_EXACT_LOGGING 1905 <<
"Sub::mySeparate(): found violated cut (backcut):" << endl;
1916 capacities[e] = 1.0/(double)cardinalityCut + eps;
1918 capacities[e] = 1.0 + eps;
1925 && (nOtherNodes > 0)
1926 && (cutValueBack <= oneMinusEps)
1929 capacities[e] = 1.0/(double)cardinalityBackcut + eps;
1931 capacities[e] = 1.0 + eps;
1948 if ((cutValue > oneMinusEps) || (r == t)) {
1951 while (!modified.
empty()) {
1955 capacities[e] += cardEps;
1966 if (cutsFound > 0) {
1972 if (nAdded != cutsFound) {
1977 #ifdef OGDF_STP_EXACT_LOGGING 1979 <<
"Sub::mySeparate(): id=" 1980 << this->
id() <<
", iter=" << this->
nIter_ 1981 <<
" separated " << cutsFound <<
" directed cuts" << endl;
1988 template<
typename T>
1994 #ifdef OGDF_STP_EXACT_LOGGING 1996 <<
"Sub::myImprove(): id=" 1997 << this->
id() <<
", iter=" << this->
nIter_ << endl;
2003 #ifdef OGDF_STP_EXACT_LOGGING 2006 <<
"Sub::myImprove(): current solution:" << endl;
2010 <<
", edge " << e << endl;
2017 double currWeight, twinWeight;
2022 if (twinWeight < currWeight)
2023 currWeight = twinWeight;
2029 #ifdef OGDF_STP_EXACT_LOGGING 2032 <<
"Sub::myImprove(): edge weights:" << endl;
2046 #ifdef OGDF_STP_EXACT_LOGGING 2048 double tmpHeuristicSolutionValue =
2051 primalHeuristic->call(
2055 heuristicSolutionWg);
2062 *heuristicSolutionWg);
2064 #ifdef OGDF_STP_EXACT_LOGGING 2066 <<
"Sub::myImprove(): primal heuristic algorithm returned solution with " 2067 <<
"value " << tmpHeuristicSolutionValue <<
", isSteinerTree=" << isSteinerTree << endl;
2070 if (isSteinerTree) {
2072 double heuristicSolutionValue = 0.0;
2076 for (
edge e : heuristicSolutionWg->
edges) {
2080 #ifdef OGDF_STP_EXACT_LOGGING 2086 #ifdef OGDF_STP_EXACT_LOGGING 2088 <<
"Sub::myImprove(): found integer solution with value " 2089 << heuristicSolutionValue << endl;
2092 #ifdef OGDF_STP_EXACT_LOGGING 2094 << std::setw(7) << this->
id()
2095 << std::setw(7) << this->
nIter_ 2096 <<
" primal heuristic founds better integer solution with value " << heuristicSolutionValue << endl;
2102 #ifdef OGDF_STP_EXACT_LOGGING 2105 <<
"Sub::myImprove(): id=" 2106 << this->
id() <<
", iter=" << this->
nIter_ 2107 <<
": computed solution is no Steiner tree!" << endl;
2111 delete heuristicSolutionWg;
2116 #ifdef OGDF_STP_EXACT_LOGGING 2117 template<
typename T>
2125 for (
int i = 0; i <
nVar(); i++) {
2127 val = constraint->
coeff(var);
2128 if ((val > eps) || (val < -eps)) {
2130 if ((val > 1-eps) && (val < 1+eps)) {
2140 if ((val < -1+eps) && (val > -1-eps)) {
2158 <<
" " << *(constraint->
sense()) <<
" " 2159 << constraint->
rhs() << endl;
2165 template<
typename T>
2169 if (m_hashKey != cv->hashKey()) {
2175 for (
node n : m_pGraph->nodes) {
2176 if (m_marked[n] != dirCut->
marked(n)) {
2184 template<
typename T>
2189 if (this->cutedge(edgeVar->
theEdge())) {
2196 template<
typename T>
2203 #ifdef OGDF_STP_EXACT_LOGGING 2204 stpMaster->setOutputLevel(m_outputLevel);
2234 const node vO = e->source();
2235 node vC = finalSteinerTree->
copy(vO);
2237 vC = finalSteinerTree->
newNode(vO);
2239 const node wO = e->target();
2240 node wC = finalSteinerTree->
copy(wO);
2242 wC = finalSteinerTree->
newNode(wO);
2244 T edgeCost = G.
weight(e);
2245 finalSteinerTree->
newEdge(e, edgeCost);
EdgeArray< edge > m_mapToOrigGraph
the undirected edge in the original graph for each arc in m_pGraph
static const char * ENUMSTRAT_[]
Literal values for the enumerators of the corresponding enumeration type.
node target() const
Returns the target node of the edge.
const ogdf::StopwatchCPU * lpSolverTime() const
Return a pointer to the timer measuring the cpu time required by the LP solver.
CSense * sense()
Returns a pointer to the sense of the constraint.
bool marked(node n) const
returns status of node n
const ogdf::StopwatchWallClock * totalCowTime() const
Returns a pointer to the timer measuring the total wall clock time.
double primalBound() const
Returns the value of the primal bound.
node theNode() const
the associated node
node m_root
the virtual root of our graph. This node is a terminal.
void useIndegreeEdgeConstraints(bool b)
Switch usage of indegree edge constraints (indeg(v) >= outgoing edge(v,x) for all x) on or off...
bool betterPrimal(double x) const
Can be used to check if a value is better than the best know primal bound.
const char * name() const override
return the name of the cut; required method for nonduplpool
void setPoolSizeInitFactor(int b)
Set factor for the initial size of the cutting pool.
void setSeparationStrategy(int b)
Set separation strategy for nested cuts.
void useNestedCuts(bool b)
Switch computation of nested cuts on or off.
const EdgeWeightedGraph< T > & m_wG
the original weighted graph
bool m_addDegreeConstraints
virtual Sub * generateSon(abacus::BranchRule *rule) override
generates a b&b node
void useNestedCuts(bool b)
Switch computation of nested cuts on or off.
DegreeEdgeConstraint(abacus::Master *master, edge e, double coeffIn, double coeffEdge, abacus::CSense::SENSE sense, double rhs)
EdgeArray< edge > m_edgesWgToGPH
edge mapping m_pWeightedGraphPH -> m_pGraph
bool isTerminal(node n) const
true if n is a terminal
void setEpsilonTest(EpsilonTest *et)
Assigns a new epsilon test.
int nEdges() const
returns the number of edges
bool m_minCardinalityCuts
void useEpsilonTest(const double &eps)
Change the used EpsilonTest from StandardEpsilonTest to a user given EpsilonTest. ...
node m_node
the associated node
void setConfigFile(const char *configfile)
Set a configuration file to use. The contents of the configuration file can override all other used o...
const EdgeArray< int > & edgeIDs() const
lp variable ids of edges
edge m_e2
twin of m_e1, i.e., if m_e1 = (u,v) it holds m_e2 = (v,u)
const NodeArray< bool > isTerminal() const
boolean array of terminal status
bool isBackCutEdge(const edge e) const
Returns whether this edge is entering the back cut.
EdgeArray< double > m_capacities
edge costs
void updateBestSolutionByEdges(const List< edge > &sol)
updates best found solution by list of edges
The master of the optimization.
node copy(node v) const
Returns the node in the graph copy corresponding to v.
double eps() const
Returns the zero tolerance.
This class implements the Directed Cut Integer Linear Program for the Steiner tree problem...
int m_poolSizeMax
maximal size of the pool
Class for directed cuts (i.e., separated Steiner cuts)
bool frontCutIsComplementOfBackCut() const
Returns whether the front cut is the complement of the backcut.
bool m_addFlowBalanceConstraints
parameter: add flow balance constraints for Steiner nodes n: outdeg(n) >= indeg(n) ...
node newNode(node vOrig)
Creates a new node in the graph copy with original node vOrig.
node rootNode() const
the designated root node (special terminal)
void init()
Reinitializes the array. Associates the array with no graph.
bool active(node n) const
returns true iff the node n is separated by this cut
int m_maxNrAddedCuttingPlanes
iterator pushBack(const E &x)
Adds element x at the end of the list.
bool m_backCutComputation
Data type for general directed graphs (adjacency list representation).
int m_factor
factor for edge coefficients in the constraint
void useBackCuts(bool b)
Switch computation of back-cuts on or off.
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.
MinSteinerTreeModule< double > * m_primalHeuristic
int maxPoolSize() const
the maximum pool size during the algorithm
virtual double rhs() const
Returns the right hand side of the constraint.
void incNrCutsTotal(int val)
increases the number of separated directed cuts
EdgeArray< EdgeVariable * > m_edgeToVar
edge -> lp variable
const char * m_name
name of the cut; required method for nonduplpool
static bool isSteinerTree(const EdgeWeightedGraph< T > &G, const List< node > &terminals, const NodeArray< bool > &isTerminal, const EdgeWeightedGraphCopy< T > &steinerTree)
Checks in O(n) time if a given tree is acually a Steiner Tree.
int nSub() const
returns the number of generated subproblems.
void init()
Reinitializes the array. Associates the array with no graph.
void setMaxFlowModule(MaxFlowModule< double > *module)
Set the maximum flow module to be used for separation.
edge getEdge(int i) const
id -> edge
void setMaxNumberAddedCuttingPlanes(int b)
Set maximum number of added cutting planes per iteration.
BRANCHINGSTRAT branchingStrategy() const
Returns the branching strategy.
int saturationStrategy() const
strategy for saturating edges during separation; Only relevant for nested cuts
bool m_nestedCutComputation
parameter: compute nested cuts yes/no i.e., saturate all cut edges and recompute the mincut ...
int randomNumber(int low, int high)
Returns random integer between low and high (including).
void useFlowBalanceConstraints(bool b)
Switch usage of flow balance constraints on or off.
bool computeBackCuts() const
parameter: back cut computation
This class serves as an interface for various methods to compute minimum or approximations of minimum...
virtual void init(const Graph &graph, EdgeArray< T > *flow=nullptr)
Initialize the problem with a graph and optional flow array. If no flow array is given, a new ("internal") array will be created. If a flow array is given, the algorithm uses this "external" array.
int degree() const
Returns the degree of the node (indegree + outdegree).
edge newEdge(node u, node v, T weight)
edge twin(edge e) const
the twin edge, i.e. twin[(u,v)] = (v,u)
void useIndegreeEdgeConstraints(bool b)
Switch usage of indegree edge constraints (indeg(v) >= outgoing edge(v,x) for all x) on or off...
iterator begin()
Returns an iterator to the first element of the list.
bool m_addIndegreeEdgeConstraints
add constraints concerning the indegree of a node w.r.t. one outgoing edge: indeg(v) >= outgoing edge...
int findParameter(const char *name, unsigned nFeasible, const int *feasible) const
Searches for parameter name in the parameter table.
void useGSEC2Constraints(bool b)
Switch usage of constraints x_uv + x_vu <= 1 on or off.
edge m_edge
the associated edge
void setWeight(const edge e, T weight)
DirectedCutConstraint(abacus::Master *master, const Graph &g, const MinSTCutMaxFlow< double > *minSTCut, MinSTCutMaxFlow< double >::cutType _cutType)
Min-st-cut algorithm, that calculates the cut via maxflow.
const NodeArray< bool > & isTerminalPH() const
terminal yes/no (in m_pWeightedGraphPH)
static const char * OSISOLVER_[]
Array for the literal values for possible Osi solvers.
unsigned int m_hashKey
hashkey of the cut; required method for nonduplpool
void useTerminalShuffle(bool b)
Switch terminal shuffling before separation on or off.
OSISOLVER defaultLpSolver() const
returns the Lp Solver.
void push(E e)
Puts a new element in the buffer.
void setSaturationStrategy(int b)
Set saturation strategy for nested cuts.
int getParameter(const char *name, int ¶m) const
Searches for parameter name in the parameter table and returns its value in param.
StopwatchWallClock m_timerMinSTCut
timer for minimum st-cut computations. Measures updates + algorithm
bool shuffleTerminals() const
shuffle ordering of terminals before each separation routine
bool isSolutionEdge(edge e) const
returns true iff original edge is contained in optimum solution
bool minCardinalityCuts() const
parameter: compute minimum cardinality cuts
A variable having value 0 or 1.
DegreeConstraint(abacus::Master *master, node n, double coeffIn, double coeffOut, abacus::CSense::SENSE sense, double rhs)
Implementation of the 2(1-1/l)-approximation algorithm for the minimum Steiner tree problem by Matsuy...
double solutionValue() const
solution value after solving the problem, i.e., returns final primal bound
Master problem of Steiner tree branch&cut algorithm.
void useDegreeConstraints(bool b)
Switch usage of degree constraints (like indeg <= 1) on or off.
void stop()
Stops the stopwatch and adds the difference between the current time and the starting time to the tot...
An array that keeps track of the number of inserted elements; also usable as an efficient stack...
Extends the GraphCopy concept to weighted graphs.
int64_t centiSeconds() const
Returns the currently elapsed time in 1/100-seconds.
int m_nrCutsTotal
total number of separated directed cuts
Variable for directed edges.
int m_maxNrAddedCuttingPlanes
parameter: maximum nr of cutting planes per iteration
double uBound(int i) const
Can be used to access the upper of an active variable of the subproblem.
const Graph * m_pGraph
the graph
Representation of levels in hierarchies.
void setSaturationStrategy(int b)
Set saturation strategy for nested cuts.
void useMinCardinalityCuts(bool b)
Switch usage of the cardinality heuristic (minimum-cardinality cuts) on or off.
int poolSizeInit() const
initial pool size
node source() const
source node
T computeFlow(EdgeArray< T > &cap, node &s, node &t, EdgeArray< T > &flow)
Only a shortcut for computeValue and computeFlowAfterValue.
cutType
The three types of cuts.
edge edgeWgToGPH(edge e) const
edge mapping m_pWeightedGraphPH -> m_pGraph
bool cutedge(edge e) const
returns true iff the edge is contained in the cut
const node * terminals() const
terminals in an array
double m_coeffOut
coefficient of outgoing edges
EdgeArray< bool > m_isSolutionEdge
const char * m_configfile
problem dependent config file
int m_maxPoolSize
statistic number of cuts in pool
node * m_terminals
terminal index -> terminal node
node rootNodePH() const
root node (in m_pWeightedGraphPH)
void useBackCuts(bool b)
Switch computation of back-cuts on or off.
virtual int separate() override
calls mySeparate() if mySeparate wasn't called in another procedure
bool objInteger() const
If true then we assume that all feasible solutions have integral objective function values...
int mySeparate()
separation procedure
edge m_e1
base edge and twin of m_e2, i.e., if m_e1 = (u,v) it holds m_e2 = (v,u)
double * m_bestSolution
best found solution
virtual T computeSteinerTree(const EdgeWeightedGraph< T > &G, const List< node > &terminals, const NodeArray< bool > &isTerminal, EdgeWeightedGraphCopy< T > *&finalSteinerTree) override
OpenSub * openSub() const
Returns a pointer to the set of open subproblems.
EdgeArray< edge > m_mapToBidirectedGraph1
the first directed arc in m_pGraph for an original edge
int number() const
Returns the current number of open subproblems contained in this set.
int nodeID(node n) const
npde -> id of lp variable
void setPrimalHeuristicCallStrategy(int b)
Set primal heuristic call strategy.
T weight(const edge e) const
Level localLogLevel() const
gives the local log-level
bool m_relaxed
parameter: indicates whether we solve the relaxed problem (LP) or the ILP
void setMaxNumberAddedCuttingPlanes(int b)
Set maximum number of added cutting planes per iteration.
int m_alreadySeparated
nr of already separated cuts, default is -1
int nEdgesU() const
returns number of undirected edges, i.e., nEdges()/2
EdgeVariable * getVar(edge e) const
returns the variable assigned to edge e
std::ostream & lout(Level l=Level::Default) const
stream for logging-output (local)
NodeArray< int > m_nodeIDs
node -> id
bool m_addGSEC2Constraints
parameter: add GSEC2 constraints yes/no, i.e. x_uv + x_vu <= 1
void setPrimalHeuristicCallStrategy(int b)
Set primal heuristic call strategy.
virtual ~Sub()
The destructor only deletes the sons of the node.
Forms the virtual base class for all possible constraints given in pool format.
void setRelaxedSolValue(double val)
solution value of the root
bool isInFrontCut(const node v) const
Returns whether this node is part of the front cut.
edge newEdge(node v, node w, T weight)
STATUS optimize()
Performs the optimization by branch-and-bound.
void createEmpty(const Graph &wG)
double lowerBound() const
Returns the value of the global lower bound.
double * bestSolution() const
the best found solution
int id() const
Returns the identity number of the subproblem.
bool m_backCutComputation
parameter: compute back cuts yes/no i.e., outgoing edges of the root-set
internal::GraphObjectContainer< EdgeElement > edges
The container containing all edge objects.
std::unique_ptr< MaxFlowModule< double > > m_maxFlowModuleOption
int m_separationStrategy
parameter: separation strategy, only important if nested cuts are computed
int numberOfEdges() const
Returns the number of edges in the graph.
double dualBound() const
Returns the value of the dual bound.
int level() const
Returns the level of the subproblem in the branch-and-bound tree.
bool m_minCardinalityCuts
parameter: compute minimum cardinality cuts
StopwatchWallClock m_separationTimer
timer for separation
NodeArray< bool > m_isTerminalPH
is terminal yes/no (in m_pWeightedGraphPH)
bool relaxed() const
solve relaxed LP or ILP
void setPrimalHeuristic(MinSteinerTreeModule< double > *b)
Set the module option for the primal heuristic (use MinSteinerTreeModule<double> types). Default: MinSteinerTreeModuleTakahashi.
int m_poolSizeInit
size of initial pool
void useTerminalShuffle(bool b)
Switch terminal shuffling before separation on or off.
Constraint for relating the indegree and one outgoing edge of a node.
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.
List< node > m_terminalsList
list of terminals
abacus::NonDuplPool< abacus::Constraint, abacus::Variable > * cutPool()
the non-duplicate cutpool for the separated Steiner cuts
void myImprove()
primal heuristic procedure
EdgeArray< edge > m_edgesGToWgPH
edge mapping m_pGraph -> m_pWeightedGraphPH
bool computeNestedCuts() const
parameter: nested cut computation
void start(bool reset=false)
Starts the stopwatch.
edge firstEdge() const
Returns the first edge in the list of all edges.
virtual bool feasible() override
checks if the current solution is feasible, i.e., calls mySeparate()
Contains logging functionality.
double m_coeffEdge
coefficient of the edge
std::unique_ptr< MinSteinerTreeModule< double > > m_primalHeuristic
Algorithm used for the primal heuristic.
double m_coeffIn
coefficient of ingoing edges
int m_maxNrCuttingPlanes
maximum nr of cutting planes to be added
void setMaxFlowModule(MaxFlowModule< double > *module)
Set the maximum flow module to be used for separation.
EdgeVariable(abacus::Master *master, int id, edge e, double coeff, double lb=0.0, double ub=1.0, abacus::VarType::TYPE vartype=abacus::VarType::Binary)
bool feasibleFound() const
We use this function, e.g., to adapt the enumeration strategy in the DiveAndBest-Strategy.
double capacities(edge e) const
costs for edge e
EdgeArray< edge > m_mapToBidirectedGraph2
the second directed arc in m_pGraph for an original edge
Doubly linked lists (maintaining the length of the list).
int m_poolSizeInitFactor
parameter: factor for the initial size of the cutting pool
node terminal(int i) const
get terminal with index i
double m_coeffIn
coefficient of ingoing edges
edge newEdge(node v, node w)
Creates a new edge (v,w) and returns it.
virtual double value() const override
Returns the objective function value of the linear program.
int nrCutsTotal() const
total number of separated directed cuts
NodeArray< node > m_nodesGToWgPH
node mapping m_pGraph -> m_pWeightedGraphPH
bool m_minCardinalityCuts
int m_nMarkedNodes
number of marked nodes
Exception thrown when an algorithm realizes an internal bug that prevents it from continuing...
MaxFlowModule< double > * getMaxFlowModule()
Get the maximum flow module used by separation algorithm.
bool m_addGSEC2Constraints
node target() const
target node
StopwatchWallClock * timerMinSTCut()
timer for minimum st-cut computations. Measures updates + algorithm
const EdgeArray< double > & capacities() const
edge costs
EdgeArray< int > m_edgeIDs
edge -> id
int id() const
id of the edge (variable)
std::unique_ptr< MinSteinerTreeModule< double > > & getPrimalHeuristic()
the primal heuristic module
virtual void initializeParameters() override
read/set parameters from file
Class for the representation of edges.
E popFrontRet()
Removes the first element from the list and returns it.
Declaration of class EdgeWeightedGraph.
int nMarkedNodes() const
the number of marked nodes
void useFlowBalanceConstraints(bool b)
Switch usage of flow balance constraints on or off.
void statistics(int &nDuplications, int &nCollisions) const
Returns some statistic information in nDuplicates and nCollisions.
Abstract base class for all branching rules.
double * xVal_
The last LP-solution.
const List< node > & terminalListPH() const
list of terminals (in m_pWeightedGraphPH)
EdgeConstraint(abacus::Master *master, edge e1, edge e2, int factor=1.0, abacus::CSense::SENSE sense=abacus::CSense::Less, double rhs=1.0)
Class for the representation of nodes.
int separationStrategy() const
strategy for separating directed Steiner cuts; Only relevant for nested cuts
Implements a stopwatch measuring wall-clock time.
int callPrimalHeuristicStrategy() const
strategy for calling primal heuristic (PH)
Encapsulates a pointer to a list element.
const ogdf::StopwatchCPU * totalTime() const
returns a pointer to the timer measuring the total cpu time for the optimization. ...
void setPoolSizeInitFactor(int b)
Set factor for the initial size of the cutting pool.
const ogdf::StopwatchCPU * lpTime() const
Returns a pointer to the timer measuring the cpu time spent in members of the LP-interface.
List< node > m_terminalListPH
list of terminal nodes (in m_pWeightedGraphPH)
NodeArray< bool > m_isTerminal
node is terminal yes/no
virtual ~Master()
destructor
double m_relaxedSolValue
statistics: solution value of the relaxed master problem
void useMinCardinalityCuts(bool b)
Switch usage of the cardinality heuristic (minimum-cardinality cuts) on or off.
Forms the virtual base class for all possible variables given in pool format.
bool callPrimalHeuristic() const
parameter: call primal heuristic yes/no
Graph * m_pGraph
the bidirected graph
virtual void initializeOptimization() override
insert variables and base constraints
bool isFrontCutEdge(const edge e) const
Returns whether this edge is leaving the front cut.
bool equal(const ConVar *cv) const override
tests if cuts are equal; required method for nonduplpool
const Graph & original() const
Returns a reference to the original graph.
int nVar() const
Returns the number of active variables.
bool m_addIndegreeEdgeConstraints
bool m_addDegreeConstraints
parameter: add constraints concerning the indegree of a node, like: indeg <= 1 for all vertices ...
double coeff(const abacus::Variable *v) const override
Returns the coefficient of the variable v in the constraint.
NodeArray< bool > m_marked
defines if a vertex is on the left side of the cut (false) or not
const char * m_configFile
node getNode(int i) const
id -> node
This class implements the minimum Steiner tree 2-approximation algorithm by Takahashi and Matsuyama w...
void useDegreeConstraints(bool b)
Switch usage of degree constraints (like indeg <= 1) on or off.
double upperBound() const
Returns the value of the global upper bound.
BranchRule * branchRule() const
Returns a pointer to the branching rule of the subproblem.
double coefficient() const
objective function coefficient
int nTerminals() const
number of terminals
void incNrCutsTotal()
increases the number of separated directed cuts by 1
OSISOLVER
This enumeration defines which solvers can be used to solve the LP-relaxations.
int m_nTerminals
nr of terminals
Sub(abacus::Master *master)
Constructor for the root problem of the b&b tree.
int nNodes() const
number of nodes of the graph
virtual void terminateOptimization() override
store solution in EdgeArray
EdgeVariable * getVarTwin(edge e) const
returns the variable assigned to the twin of edge e
int maxNrAddedCuttingPlanes() const
maximum nr of cutting planes
Includes declaration of graph class.
STATUS status() const
Returns the status of the Master.
Constraint for nodes, e.g., in/outdegree stuff.
bool is_lout(Level level=Level::Default) const
returns true if such an lout command will result in text being printed
bool m_addFlowBalanceConstraints
Centralized global and local logging facility working on streams like cout.
Level
supported log-levels from lowest to highest importance
EdgeWeightedGraph< double > & weightedGraphPH()
Subproblem of Steiner tree algorithm.
TYPE
The enumeration with the different variable types.
double coeff(const abacus::Variable *v) const override
coefficient of variable in constraint
StopwatchWallClock m_primalHeuristicTimer
timer for primal heuristics
edge edgeGToWgPH(edge e) const
edge mapping m_pGraph -> m_pWeightedGraphPH
node m_rootPH
root node in m_pWeightedGraphPH
void setSeparationStrategy(int b)
Set separation strategy for nested cuts.
StopwatchWallClock * primalHeuristicTimer()
timer for primal heuristics
const List< node > & terminalsList() const
list of terminals
int size() const
Returns the number of elements in the list.
node * nodes() const
nodes of the graph
int nLp() const
Returns the number of optimized linear programs (only LP-relaxations).
StopwatchWallClock * separationTimer()
timer for separation
void readParameters(const string &fileName)
Opens the parameter file fileName, reads all parameters, and inserts them in the parameter table...
static const char * STATUS_[]
Literal values for the enumerators of the corresponding enumeration type.
const EdgeArray< edge > & twins() const
Constraint * constraint(int i) const
Returns a pointer to the i-th active constraint.
virtual bool call(const Graph &graph, const EdgeArray< TCost > &weight, node s, node t, List< edge > &edgeList, edge e_st) override
The actual algorithm call.
node source() const
Returns the source node of the edge.
Master(const EdgeWeightedGraph< T > &wG, const List< node > &terminals, const NodeArray< bool > &isTerminal, double eps, bool relaxed=false)
Constructor of the master problem.
int m_nIterRoot
statistics: nr of iterations in the root node of the b&b tree
bool isInBackCut(const node v) const
Returns whether this node is part of the back cut.
virtual double coeff(const Variable *v) const =0
Returns the coefficient of the variable v in the constraint.
void setPrimalHeuristic(MinSteinerTreeModule< double > *pMinSteinerTreeModule)
Set the module option for the primal heuristic.
Master * master_
A pointer to the corresponding master of the optimization.
abacus::NonDuplPool< abacus::Constraint, abacus::Variable > * m_pCutPool
the non-duplicate cut pool for the directed Steiner cuts
The namespace for all OGDF objects.
bool m_nestedCutComputation
double coeff(const abacus::Variable *v) const override
coefficient of variable in constraint
MaxFlowModule< double > * m_maxFlowModule
bool m_shuffleTerminals
parameter: shuffle the list of terminals right before separation
static const char * BRANCHINGSTRAT_[]
Literal values for the enumerators of the corresponding enumeration type.
EdgeArray< edge > m_twin
the twin edges (u,v) <-> (v,u)
edge theEdge() const
the associated edge
virtual abacus::Sub * firstSub() override
generates the first subproblem
int numberOfNodes() const
Returns the number of nodes in the graph.
Variable * variable(int i) const
Returns a pointer to the i-th active variable.
node newNode()
Creates a new node and returns it.
ENUMSTRAT enumerationStrategy() const
Returns the enumeration strategy.
LpSub * lp_
A pointer to the corresponding linear program.
internal::GraphObjectContainer< NodeElement > nodes
The container containing all node objects.
void updateBestSolution(double *values)
updates best found solution
const Sub * father() const
Returns a pointer to the father of the subproblem in the branch-and-bound tree.
void setConfigFile(const char *filename)
Set the config file to use that overrides all other settings.
void setNIterRoot(int val)
nr of iterations in the root node
int nIter_
The number of iterations in the cutting plane phase.
int m_callPrimalHeuristic
int m_callPrimalHeuristic
Strategy for primal heuristic (PH) calls.
edge theEdge() const
the associated edge
unsigned hashKey() const override
retuns an hashkey for the cut; required method for nonduplpool
int m_nEdgesU
number of undirected edges
int edgeID(edge e) const
edge -> id of lp variable
bool empty() const
Returns true iff the list is empty.
bool valid() const
Returns true iff the iterator points to an element.
Computes a max flow via Preflow-Push (global relabeling and gap relabeling heuristic).
const NodeArray< int > & nodeIDs() const
lp variable ids of nodes
void checkSetMaxPoolSize()
checks if current pool size is maximum and sets it if necessary
static std::ostream & ilout(Level l=Level::Default)
void setEpsilon(double eps)
Set the epsilon for the LP.
MinSteinerTreeDirectedCut()
const Graph & graph() const
the directed graph, i.e., the bidirection of the input graph
virtual double coeff(const abacus::Variable *v) const override
coefficient of variable in constraint
Master * master()
Returns the master of the optimization.
void useGSEC2Constraints(bool b)
Switch usage of constraints x_uv + x_vu <= 1 on or off.
#define OGDF_ASSERT(expr)
Assert condition expr. See doc/build.md for more information.
Master * m_pMaster
the master problem of the b&c algorithm
EdgeWeightedGraph< double > * m_pWeightedGraphPH
edge weighted bidirected graph; used and modified for primal heuristics
int m_callPrimalHeuristic
parameter: primal heuristic (PH) call strategy
Declaration of min-st-cut algorithms parameterized by max-flow alorithm.
int m_saturationStrategy
parameter: saturation strategy, only important if nested cuts are computed
Constraint for edges, e.g., subtour elimination constraints of size 2 ((G)SEC2)