[Lemon-commits] Peter Kovacs: Fix debug checking + simplify lowe...

Lemon HG hg at lemon.cs.elte.hu
Thu Oct 24 10:12:23 CEST 2013


details:   http://lemon.cs.elte.hu/hg/lemon/rev/330264b171cf
changeset: 1296:330264b171cf
user:      Peter Kovacs <kpeter [at] inf.elte.hu>
date:      Thu Oct 17 09:29:37 2013 +0200
description:
	Fix debug checking + simplify lower bound handling (#478)

diffstat:

 lemon/capacity_scaling.h |  9 ++++-----
 lemon/cost_scaling.h     |  9 ++++-----
 lemon/cycle_canceling.h  |  9 ++++-----
 lemon/network_simplex.h  |  2 +-
 4 files changed, 13 insertions(+), 16 deletions(-)

diffs (117 lines):

diff --git a/lemon/capacity_scaling.h b/lemon/capacity_scaling.h
--- a/lemon/capacity_scaling.h
+++ b/lemon/capacity_scaling.h
@@ -356,7 +356,6 @@
       _have_lower = true;
       for (ArcIt a(_graph); a != INVALID; ++a) {
         _lower[_arc_idf[a]] = map[a];
-        _lower[_arc_idb[a]] = map[a];
       }
       return *this;
     }
@@ -836,11 +835,11 @@
       return OPTIMAL;
     }
     
-    // Check if the upper bound is greater or equal to the lower bound
-    // on each arc.
+    // Check if the upper bound is greater than or equal to the lower bound
+    // on each forward arc.
     bool checkBoundMaps() {
       for (int j = 0; j != _res_arc_num; ++j) {
-        if (_upper[j] < _lower[j]) return false;
+        if (_forward[j] && _upper[j] < _lower[j]) return false;
       }
       return true;
     }
@@ -857,7 +856,7 @@
       if (_have_lower) {
         int limit = _first_out[_root];
         for (int j = 0; j != limit; ++j) {
-          if (!_forward[j]) _res_cap[j] += _lower[j];
+          if (_forward[j]) _res_cap[_reverse[j]] += _lower[j];
         }
       }
 
diff --git a/lemon/cost_scaling.h b/lemon/cost_scaling.h
--- a/lemon/cost_scaling.h
+++ b/lemon/cost_scaling.h
@@ -370,7 +370,6 @@
       _have_lower = true;
       for (ArcIt a(_graph); a != INVALID; ++a) {
         _lower[_arc_idf[a]] = map[a];
-        _lower[_arc_idb[a]] = map[a];
       }
       return *this;
     }
@@ -902,11 +901,11 @@
       return OPTIMAL;
     }
     
-    // Check if the upper bound is greater or equal to the lower bound
-    // on each arc.
+    // Check if the upper bound is greater than or equal to the lower bound
+    // on each forward arc.
     bool checkBoundMaps() {
       for (int j = 0; j != _res_arc_num; ++j) {
-        if (_upper[j] < _lower[j]) return false;
+        if (_forward[j] && _upper[j] < _lower[j]) return false;
       }
       return true;
     }
@@ -989,7 +988,7 @@
       if (_have_lower) {
         int limit = _first_out[_root];
         for (int j = 0; j != limit; ++j) {
-          if (!_forward[j]) _res_cap[j] += _lower[j];
+          if (_forward[j]) _res_cap[_reverse[j]] += _lower[j];
         }
       }
     }
diff --git a/lemon/cycle_canceling.h b/lemon/cycle_canceling.h
--- a/lemon/cycle_canceling.h
+++ b/lemon/cycle_canceling.h
@@ -281,7 +281,6 @@
       _have_lower = true;
       for (ArcIt a(_graph); a != INVALID; ++a) {
         _lower[_arc_idf[a]] = map[a];
-        _lower[_arc_idb[a]] = map[a];
       }
       return *this;
     }
@@ -784,11 +783,11 @@
       return OPTIMAL;
     }
     
-    // Check if the upper bound is greater or equal to the lower bound
-    // on each arc.
+    // Check if the upper bound is greater than or equal to the lower bound
+    // on each forward arc.
     bool checkBoundMaps() {
       for (int j = 0; j != _res_arc_num; ++j) {
-        if (_upper[j] < _lower[j]) return false;
+        if (_forward[j] && _upper[j] < _lower[j]) return false;
       }
       return true;
     }
@@ -838,7 +837,7 @@
       if (_have_lower) {
         int limit = _first_out[_root];
         for (int j = 0; j != limit; ++j) {
-          if (!_forward[j]) _res_cap[j] += _lower[j];
+          if (_forward[j]) _res_cap[_reverse[j]] += _lower[j];
         }
       }
     }
diff --git a/lemon/network_simplex.h b/lemon/network_simplex.h
--- a/lemon/network_simplex.h
+++ b/lemon/network_simplex.h
@@ -1235,7 +1235,7 @@
       return true;
     }
     
-    // Check if the upper bound is greater or equal to the lower bound
+    // Check if the upper bound is greater than or equal to the lower bound
     // on each arc.
     bool checkBoundMaps() {
       for (int j = 0; j != _arc_num; ++j) {


More information about the Lemon-commits mailing list