# HG changeset patch # User Peter Kovacs # Date 1363447241 -3600 # Node ID ee9bac10f58e04dfc86f266cae4a1ad968cd8d20 # Parent 1bafdbd2fc464a095fd0db4494bf42b0344ade84 Debug checking for capacity bounds in min cost flow algorithms (#454) diff -r 1bafdbd2fc46 -r ee9bac10f58e lemon/capacity_scaling.h --- a/lemon/capacity_scaling.h Sat Mar 20 11:03:12 2010 +0100 +++ b/lemon/capacity_scaling.h Sat Mar 16 16:20:41 2013 +0100 @@ -737,6 +737,11 @@ } if (_sum_supply > 0) return INFEASIBLE; + // Check lower and upper bounds + LEMON_DEBUG(checkBoundMaps(), + "Upper bounds must be greater or equal to the lower bounds"); + + // Initialize vectors for (int i = 0; i != _root; ++i) { _pi[i] = 0; @@ -830,6 +835,15 @@ return OPTIMAL; } + + // Check if the upper bound is greater or equal to the lower bound + // on each arc. + bool checkBoundMaps() { + for (int j = 0; j != _res_arc_num; ++j) { + if (_upper[j] < _lower[j]) return false; + } + return true; + } ProblemType start() { // Execute the algorithm diff -r 1bafdbd2fc46 -r ee9bac10f58e lemon/cost_scaling.h --- a/lemon/cost_scaling.h Sat Mar 20 11:03:12 2010 +0100 +++ b/lemon/cost_scaling.h Sat Mar 16 16:20:41 2013 +0100 @@ -761,6 +761,10 @@ } if (_sum_supply > 0) return INFEASIBLE; + // Check lower and upper bounds + LEMON_DEBUG(checkBoundMaps(), + "Upper bounds must be greater or equal to the lower bounds"); + // Initialize vectors for (int i = 0; i != _res_node_num; ++i) { @@ -897,6 +901,15 @@ return OPTIMAL; } + + // Check if the upper bound is greater or equal to the lower bound + // on each arc. + bool checkBoundMaps() { + for (int j = 0; j != _res_arc_num; ++j) { + if (_upper[j] < _lower[j]) return false; + } + return true; + } // Execute the algorithm and transform the results void start(Method method) { diff -r 1bafdbd2fc46 -r ee9bac10f58e lemon/cycle_canceling.h --- a/lemon/cycle_canceling.h Sat Mar 20 11:03:12 2010 +0100 +++ b/lemon/cycle_canceling.h Sat Mar 16 16:20:41 2013 +0100 @@ -670,6 +670,10 @@ } if (_sum_supply > 0) return INFEASIBLE; + // Check lower and upper bounds + LEMON_DEBUG(checkBoundMaps(), + "Upper bounds must be greater or equal to the lower bounds"); + // Initialize vectors for (int i = 0; i != _res_node_num; ++i) { @@ -779,6 +783,15 @@ return OPTIMAL; } + + // Check if the upper bound is greater or equal to the lower bound + // on each arc. + bool checkBoundMaps() { + for (int j = 0; j != _res_arc_num; ++j) { + if (_upper[j] < _lower[j]) return false; + } + return true; + } // Build a StaticDigraph structure containing the current // residual network diff -r 1bafdbd2fc46 -r ee9bac10f58e lemon/network_simplex.h --- a/lemon/network_simplex.h Sat Mar 20 11:03:12 2010 +0100 +++ b/lemon/network_simplex.h Sat Mar 16 16:20:41 2013 +0100 @@ -1067,6 +1067,10 @@ if ( !((_stype == GEQ && _sum_supply <= 0) || (_stype == LEQ && _sum_supply >= 0)) ) return false; + // Check lower and upper bounds + LEMON_DEBUG(checkBoundMaps(), + "Upper bounds must be greater or equal to the lower bounds"); + // Remove non-zero lower bounds if (_have_lower) { for (int i = 0; i != _arc_num; ++i) { @@ -1230,6 +1234,15 @@ return true; } + + // Check if the upper bound is greater or equal to the lower bound + // on each arc. + bool checkBoundMaps() { + for (int j = 0; j != _arc_num; ++j) { + if (_upper[j] < _lower[j]) return false; + } + return true; + } // Find the join node void findJoinNode() {