14
Network Flow Problems: outline I Graphs — undirected and directed I (Minimum Cost) Network Flow Problem formulation I Simplex method for NFP I Full row rank assumption I Basic solutions (trees) I Basic directions, reduced costs, and dual basic solutions I Special cases and extensions of the NFP IOE 610: LP II, Fall 2013 Network Flow Problems Page 219 Undirected graphs I An undirected graph G =(N , E ) consists of a set of nodes N and a set of (undirected) arcs, or edges, E , where e 2 E is an unordered pair {i , j } of distinct nodes I Arc {i , j } is incident to i and j ; they are the endpoints of this arc I Degree of a node — number of arcs incident to it I A walk from i 1 to i t : a finite sequence of nodes i 1 , i 2 ,..., i t such that {i k , i k +1 } 2 E , k =1,..., t - 1. I A walk is a path if it has no repeated nodes. I A walk is a cycle if i 1 = i t and i 1 ,..., i t -1 form a path (t 4) I G is connected if 8i 6= j 2 N , there exists a path from i to j . IOE 610: LP II, Fall 2013 Network Flow Problems Page 220

Network Flow Problems: outline - U-M Personal World …mepelman/teaching/IOE610/Handouts/610... · Network Flow Problems: ... (Minimum Cost) Network Flow Problem formulation I Simplex

  • Upload
    doduong

  • View
    220

  • Download
    0

Embed Size (px)

Citation preview

Network Flow Problems: outline

I Graphs — undirected and directed

I (Minimum Cost) Network Flow Problem formulationI Simplex method for NFP

I Full row rank assumptionI Basic solutions (trees)I Basic directions, reduced costs, and dual basic solutionsI Special cases and extensions of the NFP

IOE 610: LP II, Fall 2013 Network Flow Problems Page 219

Undirected graphs

I An undirected graph G = (N , E) consists of a set of nodes Nand a set of (undirected) arcs, or edges, E , where e 2 E is anunordered pair {i , j} of distinct nodes

I Arc {i , j} is incident to i and j ; they are the endpoints of thisarc

I Degree of a node — number of arcs incident to itI A walk from i1 to it : a finite sequence of nodes i1, i2, . . . , it

such that {ik , ik+1} 2 E , k = 1, . . . , t � 1.I A walk is a path if it has no repeated nodes.I A walk is a cycle if i1 = it and i1, . . . , it�1 form a path (t � 4)

I G is connected if 8i 6= j 2 N , there exists a path from i to j .

IOE 610: LP II, Fall 2013 Network Flow Problems Page 220

Directed graphs

I A directed graph G = (N , A) consists of a set of nodes Nand a set of directed arcs A, where a 2 A is an ordered pair(i , j) of distinct nodes

I For a = (i , j), i is the start and j is the end node; it isoutgoing from i and incoming into j .

I I (i) = {j 2 N : (j , i) 2 A},O(i) = {j 2 N : (i , j) 2 A}

I A walk from i1 to it : a finite sequence of nodes i1, i2, . . . , itand associated sequence of arcs a1, . . . , at such that fork = 1, . . . , t � 1 either ak = (ik , ik+1) (forward arc) orak = (ik+1, ik) (backward arc).

I Path, cycle – similar.I A walk, path or cycle is directed if all arcs are forward.

IOE 610: LP II, Fall 2013 Network Flow Problems Page 221

Networks

A network consists of

I a directed graph G = (N , A)I bi 2 <, i 2 N — supplies at nodes

I if bi < 0, i is a sink and |bi | is the demand,I if bi > 0, i is a source

I uij 2 <+ [ 1, (i , j) 2 A — capacities of arcsI If all uij = 1, G is uncapacitated

I cij 2 <, (i , j) 2 A — cost per unit of flow on arcs

Motivation behind a network flow problem

I Nodes represent locations (suppliers of a product, customers,or simply transshipment locations)

I Arcs (with directions) represent available shipping routes

I We are interested in finding the cheapest way of shipping theproduct from the suppliers to the customers, subject to arccapacity limits, if any.

IOE 610: LP II, Fall 2013 Network Flow Problems Page 222

Formulation of the network flow problem (NFP)

I Variables: fij — amount of “flow” on arc (i , j)I Constraints:

I Nonnegativity:fij � 0, 8(i , j) 2 A

I Capacities, if any:

fij uij , 8(i , j) 2 AI Flow conservation:

bi +X

j2I (i)

fji =X

j2O(i)

fij , 8i 2 N

I Note thatP

i2N bi = 0 is necessary for feasibility.

I Objective: minimizeX

(i ,j)2A

cij fij over all feasible flows.

Assumption 7.1P

i2N bi = 0, and the graph G is connected.

IOE 610: LP II, Fall 2013 Network Flow Problems Page 223

Special cases of the NFP

I The shortest path problem (under certain assumptions)

I The maximum flow problemI The transportation problem

I Only arcs present are arcs from sources to sinks

I The assignment problemI Transportation problems with equal number of sources and

sinks, and supply/demand of 1 at eachI Goal: find minimum cost flow f with fij = 0 or 1 for all (i , j)

(integer program?!)

IOE 610: LP II, Fall 2013 Network Flow Problems Page 224

Uncapacitated NFP

Let n = |N | and m = |A|Node-arc incidence matrix

I A 2 <n⇥m (rows$nodes, columns$arcs)6

I

aik =

8

>

<

>

:

1 if i is the start node of arc k ,

�1 if i is the end node of arc k ,

0 otherwise.

I For any i 2 N , aTi f =P

j2O(i) fij �P

j2I (i) fjiI The (uncapacitated) NFP is an LP in standard form:

min cT f s.t. Af = b, f � 0

I Capacitated NFP:

min cT f s.t. Af = b, 0 f u6Note that the roles of m and n are reversed compared to what we’ve beed

used to!IOE 610: LP II, Fall 2013 Network Flow Problems Page 225

Network flow problems: solution approaches

I The (uncapacitated) NFP:

min cT f s.t. Af = b, f � 0

— an LP in standard formI Capacitated NFP:

min cT f s.t. Af = b, 0 f u

— an LP in standard form with upper bound constraints(recall Exercises 2.3 and 3.25)

I To apply/implement a simplex-type algorithm, need toexamine:

I full row rank assumption on AI Needs work!

I basic solutionsI Trees

I feasible directions and basic directionsI Circulations

IOE 610: LP II, Fall 2013 Network Flow Problems Page 226

Uncapacitated NFP — the full row rank assumption

(NFP) min cT f s.t. Af = b, f � 0,

where

aik =

8

>

<

>

:

1 if i is the start node of arc k ,

�1 if i is the end node of arc k ,

0 otherwise.

Assumption 7.1

(a)P

i2N bi = 0; (b) G is connected.

I Notice: the rows of the incidence matrix A sum to 0TI Let the truncated node-arc incidence matrix A consist of the

first n � 1 rows of A.I b consists of the first n � 1 elements of b

I Under Assumtion 7.1(a),I Af = b, f � 0 has a solution i↵ Af = b, f � 0 doesI A has full row rank under Assuption 7.1(b) — will show

IOE 610: LP II, Fall 2013 Network Flow Problems Page 227

Trees (on undirected graphs)Towards understanding of basic solutions of NFP

Definition: TreeG = (N , E) is called a tree if it is connected and has no cycles.

I If a node of a tree has degree 1, it is called a leaf.

Theorem 7.1(a) Every tree with |N | > 1 has at least one leaf

(b) An undirected graph is a tree , it is connected and has|N | � 1 arcs.

(c) In a tree, there exists a unique path between each pair ofdistinct nodes.

(d) Adding one arc to a tree creates exactly one cycle. (We do notdistinguish between cycles involving the same set of nodes.)

IOE 610: LP II, Fall 2013 Trees Page 228

Proof outline of Theorem 7.1(a) Every tree with |N | > 1 has at least one leaf

I If there are no leaves, thenI Every node has degree at least 2I For each node, can follow one arc in, and another arc outI Repeating this process, we find a cycle — contradiction.

IOE 610: LP II, Fall 2013 Trees Page 229

Proof outline of Theorem 7.1(b) Tree , connected, has |N |� 1 arcs

I Every tree is connected by definitionI Every tree has |N | � 1 arcs:

I Trivial if |N | = 1I If |N | > 1, use induction:

I Suppose, true for all trees with < |N | nodes.I For a tree with |N | nodes, find and remove a leaf node. What

remains is a tree with |N |� 1 nodes and, therefore, |N |� 2arcs...

I Given a connected graph with |N | � 1 arcs,I If there is a cycle, can remove one arc and the graph remains

connectedI Repeat this process until no cycles remain — the remaining

graph is a treeI But a tree must have |N | � 1 arcs — there could not have

been any cycles

IOE 610: LP II, Fall 2013 Trees Page 230

Proof outline of Theorem 7.1(c) In a tree, there exists a unique path between each pair of distinct nodes.(d) Adding one arc to a tree creates exactly one cycle.

(c) If there are two paths between some two nodes in a treeI Join the two paths; delete the arcs that are common to bothI We are left with one or more cycles — contradiction

(d) Let’s add an arc {i , j} to a treeI Resulting graph has |N | arcs — not a tree, so it must have a

cycleI The created cycle consists of {i , j} and the unique path

connecting i and j in the tree, so its a unique cycle.

IOE 610: LP II, Fall 2013 Trees Page 231

Spanning trees (on undirected graphs)

Definition: Spanning Tree on a graph

Given connected G = (N , E), let E1 ✓ E be such thatT = (N , E1) is a tree. Then T is called a spanning tree.

Theorem 7.2Let G = (N , E) be a connected undirected graph and let E0 ⇢ Ehave no cycles. Then E0 can be augmented to E1 � E0 so that(N , E1) is a spanning tree.

Proof outline:I If G is itself a tree, take E1 = E .I Otherwise, G contains at least one cycle.I A cycle cannot consist exclusively of arcs of E0, hence one can

find and remove an arc of G that is contained in a cycle of G ,but not in E0. The resulting graph is still connected.

I Repeat until (what remains of) G is a tree.IOE 610: LP II, Fall 2013 Trees Page 232

Tree solutions of NFP

I Consider an uncapacitated NFP defined on graph G = (N , A)with n = |N | and m = |A|, satisfying Assumption 7.1

Definition 7.1f is a tree solution if it can be constructed by the following:

(a) Pick T ⇢ A of n � 1 arcs that form a tree (ignore arcdirection)

(b) Let fij = 0 8(i , j) 62 T

(c) Use the flow conservation equation Af = b to determinefij , (i , j) 2 T

A tree solution such that f � 0 is a feasible tree solutions.

I To execute (c), follow the tree from the leaves up.

IOE 610: LP II, Fall 2013 Tree solutions Page 233

Structure of flow vectors: Tree solutions and BSs

Theorem 7.3Let T ⇢ A be a spanning tree. Then the system of linearequations Af = b and fij = 0, (i , j) 62 T has a unique solution.

Proof idea:

I Number the nodes so that the numbers increase along anypath to node n

I B — the incidence matrix of the tree is lower triangular with±1’s on the diagonal

Corollary 7.1

If G is connected, the matrix A has full row rank (n � 1).

Proof idea:

I To find n � 1 linearly independent columns, find a spanningtree in G

IOE 610: LP II, Fall 2013 Tree solutions Page 234

Structure of flow vectors: Tree solutions and BSs

Theorem 7.4A flow vector is a basic solution i↵ it is a tree solution.

Proof idea:

I Theorem 7.3 implies that a tree solution is a BSI Suppose we have a BS that is not a tree solution

I Let S = {(i , j) 2 A : fij 6= 0}I If S doesn’t have cycles, can be completed to a tree solution.I Suppose S has cycles; let C ⇢ S be one such cycle.

I Consider f with

fij =

8><

>:

fij (i , j) 62 S or (i , j) 2 S \ Cfij + 1 (i , j) 2 C and is a forward arc in C

fij � 1 (i , j) 2 C and is a backward arc in C

I f 6= f, but satisfies all constraints active at f at equality; thussolution to corresponding equations is not unique

— contradicts the assumption that f is a BS.IOE 610: LP II, Fall 2013 Tree solutions Page 235

Structure of flow vectors: Tree solutions and BSsSummary

I Basic (feasible) flow solutions , (feasible) tree solutions

I Given a basis, i.e., a spanning tree, the values of basicvariables can be computed easily by following the tree’stopology

IOE 610: LP II, Fall 2013 Tree solutions Page 236

Structure of flow vectors: circulations/feasible directions

Definition: CirculationAny flow vector f (feasible or not) such that Af = 0 is a circulation

I Consider a cycle C ; let F ✓ C and B ✓ C be sets of itsforward and backward arcs.

I Circulation associated with cycle C : (note: AhC = 0)

hCij =

8

>

<

>

:

1 if (i , j) 2 F ,

�1 if (i , j) 2 B ,

0 otherwise.

I If ✓ 2 <, the flow vector f + ✓hC is obtained from f bypushing ✓ units of flow along the cycle C .

I The cost of C : cThC =X

(i ,j)2F

cij �X

(i ,j)2B

cij . Pushing ✓ units

of flow along C changes the cost by ✓ · cThCIOE 610: LP II, Fall 2013 Circulations Page 237

Structure of flow vectors: Basic directions, Change of basis

I In (primal) simplex method, given a BFS, we need to pick anon-basic variable to enter, and a variable to leave the basis,to obtain a BFS with a better cost

I Applying simplex method to NFP, given a tree T , we need topick a non-tree arc to add to, and a tree arc to remove fromT , to obtain a tree solution with a better cost.

I Let (i , j) 62 T be the entering arc.I Adding it to T creates a cycle C (convention: (i , j) 2 F ).I To increase fij by ✓ and stay feasible, move to solution

f = f + ✓hC :

fkl =

8

>

<

>

:

fkl + ✓, (k , l) 2 F ,

fkl � ✓, (k , l) 2 B ,

fkl otherwise.

I Hence, ✓ can be as large as ✓? = min(k,l)2B fkl . The variablefkl that attains the minimum exists the basis.

IOE 610: LP II, Fall 2013 Change of basis and reduced costs in NFP Page 238

Structure of flow vectors: Basic directions, Change of basis

I The change in the cost resulting from the change in the basis:

✓? · (cThC ) = ✓? ·

0

@

X

(i ,j)2F

c(ij) �X

(i ,j)2B

c(ij)

1

A

I We can immediately conclude that the reduced costassociated with the variable fkl is

ckl =X

(i ,j)2F

c(ij) �X

(i ,j)2B

c(ij) = cThC .

I It would make sense to have fkl enter the basis if clk < 0.

IOE 610: LP II, Fall 2013 Change of basis and reduced costs in NFP Page 239

The dual of NFP; another way of computing reduced costs

I Recall:cT = cT � pT A, where pT = cTBB

�1

Is there a fast way to compute p and c?

I The dual of NFP is:

maxPn

i=1 pibis.t. pi � pj cij , (i , j) 2 A

p 2 <n, pi ’s are associated with nodes i = 1, . . . , n.I Let us set pn = 0 (variable pn removed when passing to A).I From the definition of A: cij = cij � (pi � pj), 8(i , j) 2 AI At a basic dual solution: cij = cij � (pi � pj) = 0, 8(i , j) 2 TI To compute dual basic solution:

I Set pn = 0 (root of the tree)I Follow the tree arcs from n down, setting the values of pi ’s to

satisfy pi � pj = cij

IOE 610: LP II, Fall 2013 Change of basis and reduced costs in NFP Page 240

The simplex method for the uncapacitated NFP

1. An iterations starts with a tree T and associated BFS (treesolution) f

2. Compute p3. Compute cij = cij � (pi � pj) for (i , j) 62 T . If all cij � 0, stop

— optimal basis found; else, choose some (i , j) with cij < 0 toenter the basis.

4. (i , j) and arcs in T form a unique cycle with (i , j) 2 F . If setof backward arcs B = ;, stop — optimal cost is �1.

5. Let ✓? = min(k,l)2B fkl . Push ✓? units of flow around the cycle;the variable fkl that attains the minimum exists the basis.

I Computational e↵ort: using calculations specific to theNFP, we need O(n) time to compute p, O(m) time tocompute all the reduced costs, O(n) to change the basis.

I If no starting primal feasible tree is availableI Can use Phase I method (artificial arcs connecting all sources

to all sinks)I Use parametric primal-dual method

IOE 610: LP II, Fall 2013 Network Simplex method Page 241

Integrality property of the NFP

Theorem 7.5Consider an uncapacitated NFP and assume that the underlyinggraph is connected.

(a) For every basis matrix B, B�1 has integer entries.

(b) If the supplies bi are integer, then every basic solution hasinteger coordinates

(c) If the costs cij are integer, then every dual basic solution hasinteger coordinates.

Corollary 7.2

Consider an uncapacitated NFP and assume that the optimal costis finite.

(a) If the supplies bi are integer, 9 an integer optimal flow vector

(b) If the costs cij are integer, 9 an integer optimal solution to thedual problem.

IOE 610: LP II, Fall 2013 Integrality property Page 242

Assignment problem

I There are n projects and n people; each person gets oneproject

I Cost of person i performs project j , the cost is cij .

I Formulation:min

P

i ,j cij fijs.t.

P

j fij = 1 8iP

i fij = 1 8jfij 2 {0, 1} 8i , j

I Interpretation as NFP:I N : 2n nodes i = 1, . . . , n and j = 1, . . . , nI A: n2 arcs (i , j) for each i , j

I In formulation above, can replace fij 2 {0, 1} by fij � 0 —solution guaranteed to be integer

I More e�cient specialized algorithms exist as well

IOE 610: LP II, Fall 2013 Special cases and extensions Page 243

Shortest path problem

I Given:I G = (N , A)I cij , (i , j) 2 A — “length” of arc (i , j)I Destination node n

find the “shortest” directed path from each node in the graphto n

I Note: shortest directed path is not the same as a shortestdirected walk if the graph has negative-cost directed cycles!

I If arcs corresponding to shortest paths to n are drawn, theyform an “in-tree,” i.e., a spanning tree in which all paths to nare directed

I “Principle of optimality”: if the first step of a shortest pathfrom i to n is node j , the rest of the path must be a shortestpath from j to n

IOE 610: LP II, Fall 2013 Special cases and extensions Page 244

NFP model of the shortest path

I NFP formulation: bi = 1 for i = 1, . . . , n � 1, bn = �(n � 1).

Theorem 7.17Consider the shortest path problem in a directed graph with nnodes, and the associated NFP. Assume there is a path from anynode to n, and node n has no outgoing arcs.

(a) If there exists a negative length cycle, the optimal cost of theNFP is �1

(b) Suppose all cycles have nonnegative length. If a feasible treesolution is optimal, then the corresponding tree is a tree ofshortest paths.

(c) Suppose all cycles have nonnegative length. If we fix pn = 0,the dual problem has a unique solution p?, where p?i is theshortest path length from i to n

IOE 610: LP II, Fall 2013 Special cases and extensions Page 245

Extension: Multicommodity flow problem

I Data:I A directed graph G = (N , A) (matrix A)I uij 2 <+ [ +1, (i , j) 2 AI Set K of products (commodities) to be shippedI bki 2 <, i 2 N , k 2 K — supply of commodity k at node iI ckij 2 <, (i , j) 2 A, k 2 K — unit cost of shipping commodity

k on arc (i , j)I Formulation: f kij — flow of commodity k on arc (i , j)

(MCFP) minX

k2K

X

(i ,j)2A

ckij fkij

s.t. Afk = bk k 2 KX

k2Kf kij uij (i , j) 2 A

f kij � 0 (i , j) 2 A, k 2 K

I Case uij = 1 8(i , j) equivalent to |K | separate NFPsI Capacitated case more complex; no integrality property

IOE 610: LP II, Fall 2013 Special cases and extensions Page 246