[Lemon-commits] Alpar Juttner: Merge bugfix #478
Lemon HG
hg at lemon.cs.elte.hu
Thu Oct 24 10:12:24 CEST 2013
details: http://lemon.cs.elte.hu/hg/lemon/rev/a78e5b779b69
changeset: 1298:a78e5b779b69
user: Alpar Juttner <alpar [at] cs.elte.hu>
date: Thu Oct 17 15:08:41 2013 +0200
description:
Merge bugfix #478
diffstat:
lemon/capacity_scaling.h | 19 +++++++++----------
lemon/cost_scaling.h | 21 ++++++++++-----------
lemon/cycle_canceling.h | 21 ++++++++++-----------
lemon/network_simplex.h | 12 ++++++------
4 files changed, 35 insertions(+), 38 deletions(-)
diffs (285 lines):
diff --git a/lemon/capacity_scaling.h b/lemon/capacity_scaling.h
--- a/lemon/capacity_scaling.h
+++ b/lemon/capacity_scaling.h
@@ -163,7 +163,7 @@
int _root;
// Parameters of the problem
- bool _have_lower;
+ bool _has_lower;
Value _sum_supply;
// Data structures for storing the digraph
@@ -356,10 +356,9 @@
/// \return <tt>(*this)</tt>
template <typename LowerMap>
CapacityScaling& lowerMap(const LowerMap& map) {
- _have_lower = true;
+ _has_lower = true;
for (ArcIt a(_graph); a != INVALID; ++a) {
_lower[_arc_idf[a]] = map[a];
- _lower[_arc_idb[a]] = map[a];
}
return *this;
}
@@ -543,7 +542,7 @@
_upper[j] = INF;
_cost[j] = _forward[j] ? 1 : -1;
}
- _have_lower = false;
+ _has_lower = false;
return *this;
}
@@ -754,7 +753,7 @@
// Remove non-zero lower bounds
const Value MAX = std::numeric_limits<Value>::max();
int last_out;
- if (_have_lower) {
+ if (_has_lower) {
for (int i = 0; i != _root; ++i) {
last_out = _first_out[i+1];
for (int j = _first_out[i]; j != last_out; ++j) {
@@ -839,11 +838,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,10 +856,10 @@
pt = startWithoutScaling();
// Handle non-zero lower bounds
- if (_have_lower) {
+ if (_has_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
@@ -256,7 +256,7 @@
int _root;
// Parameters of the problem
- bool _have_lower;
+ bool _has_lower;
Value _sum_supply;
int _sup_node_num;
@@ -372,10 +372,9 @@
/// \return <tt>(*this)</tt>
template <typename LowerMap>
CostScaling& lowerMap(const LowerMap& map) {
- _have_lower = true;
+ _has_lower = true;
for (ArcIt a(_graph); a != INVALID; ++a) {
_lower[_arc_idf[a]] = map[a];
- _lower[_arc_idb[a]] = map[a];
}
return *this;
}
@@ -568,7 +567,7 @@
_scost[j] = 0;
_scost[_reverse[j]] = 0;
}
- _have_lower = false;
+ _has_lower = false;
return *this;
}
@@ -780,7 +779,7 @@
// Remove infinite upper bounds and check negative arcs
const Value MAX = std::numeric_limits<Value>::max();
int last_out;
- if (_have_lower) {
+ if (_has_lower) {
for (int i = 0; i != _root; ++i) {
last_out = _first_out[i+1];
for (int j = _first_out[i]; j != last_out; ++j) {
@@ -837,7 +836,7 @@
for (NodeIt n(_graph); n != INVALID; ++n) {
sup[n] = _supply[_node_id[n]];
}
- if (_have_lower) {
+ if (_has_lower) {
for (ArcIt a(_graph); a != INVALID; ++a) {
int j = _arc_idf[a];
Value c = _lower[j];
@@ -907,11 +906,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;
}
@@ -991,10 +990,10 @@
}
// Handle non-zero lower bounds
- if (_have_lower) {
+ if (_has_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
@@ -195,7 +195,7 @@
int _root;
// Parameters of the problem
- bool _have_lower;
+ bool _has_lower;
Value _sum_supply;
// Data structures for storing the digraph
@@ -278,10 +278,9 @@
/// \return <tt>(*this)</tt>
template <typename LowerMap>
CycleCanceling& lowerMap(const LowerMap& map) {
- _have_lower = true;
+ _has_lower = true;
for (ArcIt a(_graph); a != INVALID; ++a) {
_lower[_arc_idf[a]] = map[a];
- _lower[_arc_idb[a]] = map[a];
}
return *this;
}
@@ -471,7 +470,7 @@
_cost[j] = 0;
_cost[_reverse[j]] = 0;
}
- _have_lower = false;
+ _has_lower = false;
return *this;
}
@@ -684,7 +683,7 @@
// Remove infinite upper bounds and check negative arcs
const Value MAX = std::numeric_limits<Value>::max();
int last_out;
- if (_have_lower) {
+ if (_has_lower) {
for (int i = 0; i != _root; ++i) {
last_out = _first_out[i+1];
for (int j = _first_out[i]; j != last_out; ++j) {
@@ -727,7 +726,7 @@
for (NodeIt n(_graph); n != INVALID; ++n) {
sup[n] = _supply[_node_id[n]];
}
- if (_have_lower) {
+ if (_has_lower) {
for (ArcIt a(_graph); a != INVALID; ++a) {
int j = _arc_idf[a];
Value c = _lower[j];
@@ -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;
}
@@ -835,10 +834,10 @@
}
// Handle non-zero lower bounds
- if (_have_lower) {
+ if (_has_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
@@ -198,7 +198,7 @@
int _search_arc_num;
// Parameters of the problem
- bool _have_lower;
+ bool _has_lower;
SupplyType _stype;
Value _sum_supply;
@@ -682,7 +682,7 @@
/// \return <tt>(*this)</tt>
template <typename LowerMap>
NetworkSimplex& lowerMap(const LowerMap& map) {
- _have_lower = true;
+ _has_lower = true;
for (ArcIt a(_graph); a != INVALID; ++a) {
_lower[_arc_id[a]] = map[a];
}
@@ -879,7 +879,7 @@
_upper[i] = INF;
_cost[i] = 1;
}
- _have_lower = false;
+ _has_lower = false;
_stype = GEQ;
return *this;
}
@@ -1072,7 +1072,7 @@
"Upper bounds must be greater or equal to the lower bounds");
// Remove non-zero lower bounds
- if (_have_lower) {
+ if (_has_lower) {
for (int i = 0; i != _arc_num; ++i) {
Value c = _lower[i];
if (c >= 0) {
@@ -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) {
@@ -1612,7 +1612,7 @@
}
// Transform the solution and the supply map to the original form
- if (_have_lower) {
+ if (_has_lower) {
for (int i = 0; i != _arc_num; ++i) {
Value c = _lower[i];
if (c != 0) {
More information about the Lemon-commits
mailing list