Title: Finding Minimum-Cost Circulations by Canceling Negative Cycles
1Finding Minimum-Cost Circulations by Canceling
Negative Cycles
ANDREW V. GOLDBERG ROBERT E. TARJAN
- Advanced Algorithms Seminar
- Instructor Prof. Haim Kaplan
- Presentation Moshik Guttmann
2Definitions
- A circulation network is a symmetric graph
G(V,E) with a real value capacity u(v,w)
function and a cost c(v,w) function for each arc
s.t. - c(v,w) -c(w,v)
- (cost anti-symmetry constraint)
- A circulation is a function s.t.
for each - f(w,v) u(w,v) (capacity constraint)
- f(w,v) f(v,w) (flow anti-symmetry constraint)
- (conservation
constraints). - The cost of a circulation is
- The minimum-cost circulation problem is that of
finding a circulation of minimum cost
3Definitions
- For a circulation f and an arc (v, w) the
residual capacity of (v, w) is - uf(v,w) u(v, w)-f(v, w).
- An arc (v, w) is a residual arc if
- uf(v,w) gt 0.
- We denote by Ef the set of residual arcs.
- A residual cycle is a simple cycle of residual
arcs. The capacity of a residual cycle is the
minimum of the residual capacities of its arcs. - For a price function the reduced cost
of (v,w) - cp(v, w) c(v, w) p(v) - p(w)
4Algorithm outline(origin)
- Basic negative cycle canceling algorithm
- KLEIN, 67 A primal method for minimal cost
flows with applications to the assignment and
transportation problems - Use the Ford-Fulkerson maximal flow routine (or
any other) to find a flow f of value v. - Form the residual network Gf
- Test for the existence of a negative directed
cycle C in Gf - While Gf contains a negative cost cycle C do
- push along C.
5Algorithm outline
- The cycle-canceling algorithm can run for an
exponential number of iterations even if the
capacities and costs are integers, and it need
not even terminate if the capacities are
irrational. - FORD, JR., L. R., AND FULKERSOND, . R. Flows in
Networks..
6Algorithm outline
- A natural question
- Is there a rule for selecting cycles to cancel
that results in a number of iterations bounded by
a polynomial in n and m? - Answer
- Selection rule -
- always cancel a residual cycle whose average arc
cost is as small as possible (minimum-mean cycle) - A minimum mean cycle can be found in O(nm) time
using an algorithm of Karp 19 or in 0(vnm
log(nC)) time using an algorithm of Orlin and
Ahuja 26. C max abs cost
7Algorithms review
Strongly Polynomial Bound Weakly Polynomial Bound Reference Algorithmic Description
O(n2m3 log n) O(n2m2 log(nC) Goldberg and Tarjan 1988 Augment flow along a negative cycle with a minimum mean cost
O(nm2 log2n) O(nm log n log(nC)) Goldberg and Tarjan 1988 Augment flow along a cycle composed entirely of negative reduced cost arcs
Not available O(mn3log(mCU)) Barahona and Tardos 1989 Augment flows in negative cycles with maximum improvement
Not available O(nm2 log(nC)) Wallacher and Zimmerman 1991 Augment flow along a negative cycle with minimum ratio.
O(m2log n(mn log n)) O(mlogU (m nlog n)) Sokkalingam, Ahuja and Orlin 1996 Augment flow in a negative cycle with sufficiently large residual capacity
We call a network algorithm strongly polynomial
if it satisfies the following two conditions 1)
The number of arithmetic operations is
polynomially bounded in the number of nodes n,
and the number of arcs m. 2) The only arithmetic
operations in the algorithm are comparisons,
additions and subtraction.
8Algorithm theory
- Theorem 2.1 Busacker and Saaty
- A circulation is minimum-cost if and only if
there are no negative residual cycles. - Proof (gt)
- If there are negative cycles in Gf we can obtain
a cheaper circulation by increasing flow on
them. - Proof (lt)
- If the circulation f is not optimal, we show
there exists a negative cycle in Gf - Let f be an optimal circulation.We will look at
the decomposition of the circulation f-f into
cycles. - Since it is of negative cost and feasible in Gf,
it contains a negative cycle!
9Theorem 2.1 - example
10Algorithm theory
- Observe that the cost of a residual cycle is the
same whether the original arc costs or the
reduced arc costs with respect to some price
function are used. Furthermore, the flow
conservation constraints (3) imply that the cost
of any circulation is unaffected by replacing
original costs by reduced costs. - Theorem 3.1 10.
- A circulation f is minimum-cost iff there is a
price function p s.t.
11Algorithm theory
- A circulation f is e-optimal with respect to a
price function p if (we relax the optimality
constraint) - Observe that a circulation is e-optimal w.r.t. p
iff for every residual arc.
12Algorithm theory
- Theorem 3.2
- If all costs are integers and then an
- e-optimal solution is optimal 5
- Proof
- Consider a simple cycle in Gf.
- The e-optimality of f implies that the reduced
cost of the cycle is at least . - The reduced cost of the cycle equals the original
cost which is non-negative (all costs are
integers). - Since there are no negative cost cycles, f is
minimum cost circulation.
13Algorithm definitions
- The connection between e-optimality and minimum
cycle means - For a circulation f
- e(f) the minimum e such that f is e-optimal.
- µ(f) the mean cost of a minimum-mean residual
cycle
14Algorithm theory
- Theorem 3.3 16.
- Suppose f is a nonoptimal circulation. Then e(f)
-µ(f). - Proof (gt)
- Consider any cycle G in Gf Let the length of G
be l. - For any e, define c(e) by c(e)(v,w)c(v, w) e
for (v, w) ? Ef - Since f is e(f)-optimal, we have
- 0 c(e)(G)c(G) le , i.e. c(G) / l -e(f).
- Since this is true for any cycle G, µ(f) -e(f),
i.e., e(f) -µ(f).
15Algorithm Theorem 3.3 16. Cont
- Proof (lt)
- Conversely, let G be the minimum-mean cost
residual cycle then the mean cost of G is equal
to µ(f). - Since f is not optimal, there is a negative-cost
residual cycle, and therefore µ(f) lt 0. - Fix a price function p and an e such that e gt
-µ(f). - Since the cost of G is equal to the sum of the
reduced costs of the arcs on G, for the minimum
reduced cost arc (v, w) on G we have cp(v,w)
µ(f) (the minimum is at most the average). - Therefore cp(v,w) -e, so f is not e -optimal
with respect to p. - Thus e(f) -µ(f).
16Algorithm definitions
- The admissible graph G(f,p) is
17Algorithm Lemma 3.4
- Lemma 3.4.
- Suppose a circulation f is e-optimal with respect
to a price function p and G(f, p) is acyclic.
Then f is (1-1/n)e-optimal. - Proof.
- Let G be a simple cycle in Gf, and let l be the
length of G. By the e-optimality of f the cost
of every arc on G is at least -e. Since the
admissible graph is acyclic, at least one arc on
G has a nonnegative cost. Therefore, the mean
cost of G is at least - Theorem 3.3 implies that f is (1-1/n)e-optimal.
18Example
Flow
Admissible graph
Residual graph
19Algorithm theory
- Lemma 3.5.
- Canceling a minimum-mean cycle cannot increase
e(f). - Proof
- Let G be the minimum-mean cycle that is canceled.
Before G is canceled, every residual arc
satisfies cp(v,w)-e by e-optimality. - By Theorem 3.3, the choices of e and G imply that
every arc (v,w) on G satisfies cp(v,w)-e before
canceling. - By antisymmetry, every new residual arc created
by canceling G has cost e. (Every such arc is the
reversal of an arc on G.) It follows that after
cancellation of G, every residual arc still
satisfies cp(v,w)-e. - Thus after the cancellation e(f)-e
20Algorithm theory
- Lemma 3.6.
- A sequence of m minimum-mean cycle cancellations
reduces e(f) to at most (1 - 1/n)e, that is, to
at most (1- 1/n) times its original value. - Proof
- Consider a sequence of m minimum-mean cycle
cancellations. As f changes, the admissible graph
G(f,p) changes as well. Initially every arc (v,
w) ? E(f,p) satisfies cp(v,w)-e . Canceling a
cycle all of whose arcs are in E(f,p) adds only
arcs of positive reduced cost to Ef and deletes
at least one arc from E(f, p). - Consider the two cases
21Algorithm theory - lemma 3.6 cont
- Case 1.
- None of the cycles canceled contains an arc of
nonnegative reduced cost. - Then each cancellation reduces the size of E(f,
p), and after m cancellations E(f, p) is empty,
which implies that f is e-optimal. - that is e(f) 0. Thus the lemma is true in this
case.
22Example
Flow
Admissible graph
Residual graph
23Algorithm theory - lemma 3.6 cont
- Case 2.
- Some cycle canceled contains an arc of
nonnegative reduced cost. - Let G be the first such cycle canceled. Every arc
of G has a reduced cost of at least -e, one arc
of G has a nonnegative reduced cost, and the
number of arcs in G is at most n. - Therefore, the mean cost of G is at least
- -(n-1)e/n -(1-1/n)e.
- Thus, just before the cancellation of G,
- e(f) (1-1/n)e by Theorem 3.3.
- Since, by Lemma 3.5, e(f) never increases, the
lemma is true in this case also.
24Algorithm Observation
- Lemmas 3.5 and 3.6 are enough to derive a
polynomial bound on the number of iterations,
assuming that all arc costs are integers.
25Algorithm theory
- Theorem 3.7.
- If all arc costs are integers, then the
minimum-mean cycle-canceling algorithm terminates
after - O(nm log(nC)) iterations.
- Proof.
- Let f be the circulation maintained by the
algorithm. Initially e(f) C. If e(f) lt 1/n,
then e(f) 0 by Theorem 3.1. - Lemmas 3.5 and 3.6 imply that if i is the total
number of iterations, (1 - 1/n)??(i-1/m)?
1/(nC). - That is, ??(i-1/m)? -ln(nC)/ln(1-1/n) n
ln(nC) - since ln(1-1/n) -l/n for n gt 1.
- It follows that i O(nm log (nC)).
26Algorithm theory
- Theorem 3.8 16.
- Let e gt 0, suppose a circulation f is e-optimal
with respect to a price function p, and suppose
that for some arc (v, w), cp(v,w)l 2ne. - Then (v,w) is e-fixed.
- Proof.
- By antisymmetry, it is enough to prove the
theorem for the case cp(v,w) 2ne. Let f be a
circulation such that f(v, w) ? f(v, w). Since
cp(v,w) gt e, the flow through the arc (v, w) must
be as small as the capacity constraints allow,
namely -u(w, v), and therefore f(v, w) ? f(v, w)
implies f(v,w)gtf(v,w). We show that f is not
e-optimal, from which the theorem follows.
27Algorithm definitions
- We say that an arc is e-fixed if and only if the
flow through this arc is the same for all
e-optimal circulations.
28Algorithm theory Theorem 3.8 cont
- Consider
- Note that Ggt is a subgraph of Gf and (v, w) is
an arc of Ggt. - Since f and f are circulations, Ggt must contain
a simple cycle G that passes through (v,w). - Let l be the length of G. Since all arcs of G are
residual arcs, the cost of G is at least - cp(v,w) (l-1)e 2ne (n-1)e gt ne
29Algorithm theory Theorem 3.8 cont
- Now consider a cycle G obtained by reversing the
arcs on G. Note that G is a cycle in - and therefore a cycle in Gf
- by antisymmetry, the cost of G is less than -ne
and thus the mean cost of G is less than -e. - Theorem 3.3 implies that f is not e-optimal.
30Algorithm running time analysis
- Consider an execution of the cycle-canceling
algorithm. - Suppose an edge (v, w) becomes fixed at some
point in the execution. - Since by Lemma 3.5 the error parameter e(f) never
increases, the flow through (v,w) henceforth
remains the same. - When all edges are fixed, the current circulation
is optimal. - To see this, observe that an optimal circulation
is e-optimal for any e 0, and therefore it must
agree with the current circulation on all (fixed)
arcs.
31Algorithm theory
- Theorem 3.9.
- For arbitrary real-valued arc costs, the
minimum-mean cycle-canceling algorithm terminates
after O(nm2 log n) iterations. - Proof.
- Let k m(n?ln n 1?). Divide the iterations
into groups of k consecutive iterations. We
claim that each group of iterations fixes the
flow on a distinct arc (v, w), that is,
iterations after those in the group do not change
f(v, w). The theorem is immediate from the claim.
- To prove the claim, consider any group of
iterations. - Let f be the flow before the first iteration of
the group, f the flow after the last iteration
of the group, e e(f), e e(f).
32Algorithm Theorem 3.9 cont
- Let p be a price function for which f satisfies
the e-optimality constraints. - Let G be the cycle canceled in the first
iteration of the group. - The choice of k implies by Lemmas 3.5 and 3.6
that - e e(1 - l/n)?n(ln n l) e /(2n).
- Since the mean cost of G is - e, some arc on G,
- say (v, w), must have cp(v,w) -e -2ne.
- By Lemma 3.5 and Theorem 3.8, the flow on (v, w)
will not be changed by iterations after those in
the group. But f(v, w) is changed by the first
iteration in the group, which cancels G. Thus
each group fixes the flow on a distinct arc.
33Algorithm theory
- Theorem 3.10.
- The minimum-mean cycle-canceling algorithm runs
in O(n2m3 log n) time on networks with arbitrary
real-valued arc costs, and on networks with
integer arc costs in - O(n3/2m2 minlog2 (nC), vn log (nC), vn m log n)
- Proof.
- Immediate from Theorems 3.7 and 3.9.
34Algorithm improvement
- In this section we describe a variant of the
minimum-mean cycle-canceling algorithm for which
the time per cycle cancellation is O(log n)
instead of O(nm). - This improvement is based on a more flexible
selection of cycles for canceling, explicit
maintenance of a price function to help identify
cycles for canceling, and a sophisticated data
structure to help keep track of arc flows.
35Algorithm cancel-and-tighten - outline
- The cancel-and-tighten algorithm, maintains a
circulation f and a price function p. - Denote by e(f, p) the minimum e such that f
satisfies the e-optimality constraints for p, - e(f,p) max0, -mincp(v, w) uf(v, w) gt 0.
- (v, w) is an admissible arc if cp(v,w)lt0
- A residual cycle is an admissible cycle if all
its arcs are admissible arcs. - Initially f is any circulation and p is the
identically zero price function. - (Thus, e(f, p) C initially.)
36Algorithm cancel-and-tighten - outline
- The algorithm consists of repeating the following
two steps until the circulation f is optimal - Step 1 cancel cycles.
- Repeatedly find and cancel admissible cycles
until the admissible graph is acyclic. - Step 2 tighten prices.
- Modify p so that e(f, p) decreases to at most
- (1-1/n) times its former value.
- Note that, by Lemma 3.4, a suitable price
function can always be found in Step 2
37Algorithm cancel-and-tighten time analysis
- Theorem 4.1.
- Each iteration of Step 1 results in the canceling
of at most m cycles. If all arc costs are
integers, there are - O(n log(nC)) iterations of Steps 1 and 2
- Proof.
- Let E(f,p) be the set of admissible arcs.
- Canceling an admissible cycle reduces the size of
E(f,p) by at least one and cannot increase
e(f,p), since all newly created residual arcs
have positive cost. - Since E(f,p) has maximum size m and minimum size
0, after at most m cycle cancellations Step 1
terminates. - Lemma 3.4 implies that after Step 1, the mean
cost of a residual cycle is at least
-(1-1/n)e(f,p), which implies that p can be
modified to satisfy the requirement in Step 2. - The third part of the theorem follows as in the
proof of Theorem 3.7.
38Algorithm theory
- Theorem 3.7.
- If all arc costs are integers, then the
minimum-mean cycle-canceling algorithm terminates
after - O(nm log(nC)) iterations.
- Proof.
- Let f be the circulation maintained by the
algorithm. Initially e(f) C. If e(f) lt 1/n,
then e(f) 0 by Theorem 3.1. - Lemmas 3.5 and 3.6 imply that if i is the total
number of iterations, (1 - l/n)??(i-1/m)?
1/(nC). - That is, ??(i-1/m)? -ln(nC)/ln(1-1/n) n
ln(nC) - since ln(1-1/n) -1/n for n gt 1.
- It follows that i O(nm log (nC)).
39Algorithm cancel-and-tighten implementation
- Step 1 is the dominant part of the computation.
- A simple implementation runs in O(nm) time (O(n)
per cycle canceled). - A more complicated implementation runs in O(m log
n) per cycle canceled).
40Algorithm cancel-and-tighten implementation
- Performing Step 1 is essentially the same as
converting an arbitrary flow into an acyclic flow
by eliminating cycles of flow.
41Algorithm cancel-and-tighten implementation
- depth-first search to find admissible cycles.
- Each search advances only along admissible arcs.
- Whenever a search retreats from a vertex v, this
vertex is marked as being on no admissible cycles - A search is allowed to visit only unmarked
vertices. - Whenever a search advances to a vertex it has
already visited, an admissible cycle has been
found. - The cycle is canceled and a new search begun.
- A straightforward implementation of this
algorithm has a running time of O(m) iterations
with O(n) per cycle canceled, for a total of
O(nm) time.
42Algorithm cancel-and-tighten implementation
- Algorithms for the latter purpose, such as the
O(m log n)-time algorithm of Sleator and Tarjan
30, can be adapted to the former purpose. - We shall describe the appropriately modified
version of this algorithm.
43Algorithm cancel-and-tighten implementation
- Dynamic tree operations
- make-tree(v) Make vertex v into a one-vertex
dynamic tree. Vertex v must be in no other tree. - find-root(v) Find and return the root of the
tree containing vertex v. - find-value(v) Find and return the value of the
tree arc connecting v to its parent. If v is a
tree root, return infinity. - find-min(v) Find and return the ancestor w of v
such that the tree arc connecting IY to its
parent has minimum value along the path from v to
find-root(v). In case of a tie, choose the vertex
w closest to the tree root. If v is a tree root,
return v. - change-value(v, x) Add real number x to the
value of every arc along the path from v to
find-root(v). - link(v, W, x) Combine the trees containing v and
w by making w the parent of v and giving the new
tree arc joining v and w the value X. This
operation does nothing if v and w are in the same
tree or if v is not a tree root. - cut(v) Break the tree containing v into two
trees by deleting the arc from v to its parent.
This operation does nothing if v is a tree root.
44Algorithm cancel-and-tighten implementation
step 1
- Step 1a initialize.
- For each vertex v,
- unmark v and perform make-tree(v).
- Step 1b finding starting vertex a search.
- If all vertices are marked,
- go to Step 1g.
- Otherwise,
- select an unmarked vertex v and go to Step 1c.
- Step 1c find end of path.
- r find-root(v).
- If there is no admissible arc (r, w) with w
unmarked, - go to Step 1f.
- Otherwise,
- let (v, w) be such an arc and go to Step 1d.
- Step 1d extend path.
- If find-root(w) ? r,
- link(r, w, uf(r,w)) and go to Step 1c.
- Otherwise,
- go to Step 1e.
45Algorithm implementation step 1 cont
- Step 1e cancel cycle.
- Let d minuf(r,w)), find-value(find-min(w)).
- Perform f(r, w) f(r, w) d . If uf(r,w) 0,
mark (r, w) inadmissible. - Perform change-value(w, - d).
- While find-value(find-min(w)) 0, do the
following - z find-min(w)
- f(z, parent(z)) u(z, parent(z))
- cut(z).
- Go to Step 1b.
- Step 1f retract path.
- Mark r.
- For each vertex z such that r parent(z), do the
following - f(z, r) u(z, r) - find-value(z) cut(z).
- Go to Step 1b.
- Step 1g extract flow values of tree arcs.
- For each vertex v,
- if find-root(v) ? v,
- f(v, parent(v)) u(v, parent(v)) -
find-value(v). - stop.
46Algorithm cancel-and-tighten implementation
step 2
- Step 2a compute levels.
- For each vertex v,
- compute a level L(v), defined recursively
- If v has no incoming admissible arcs,
- L(v) 0.
- Otherwise,
- L(v) maxL(u) 1 (u, v) is an admissible
arc. - Step 2b compute new prices.
- For all v ? V,
- p(v) p(v) - (e/n)L(v).
47The end