[Lemon-commits] Peter Kovacs: Debug checking for capacity bounds...

Lemon HG hg at lemon.cs.elte.hu
Tue Jul 30 15:45:59 CEST 2013


details:   http://lemon.cs.elte.hu/hg/lemon/rev/ee9bac10f58e
changeset: 1240:ee9bac10f58e
user:      Peter Kovacs <kpeter [at] inf.elte.hu>
date:      Sat Mar 16 16:20:41 2013 +0100
description:
	Debug checking for capacity bounds in min cost flow algorithms
	(#454)

diffstat:

 lemon/capacity_scaling.h |  14 ++++++++++++++
 lemon/cost_scaling.h     |  13 +++++++++++++
 lemon/cycle_canceling.h  |  13 +++++++++++++
 lemon/network_simplex.h  |  13 +++++++++++++
 4 files changed, 53 insertions(+), 0 deletions(-)

diffs (121 lines):

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() {


More information about the Lemon-commits mailing list