# IEOR 4004 Final Review part I.

## Presentation on theme: "IEOR 4004 Final Review part I."— Presentation transcript:

IEOR 4004 Final Review part I.
April 28, 2014

Mathematical programming
Help decision-maker(s) make decisions (what and how much to produce, which path is fastest, how to allocate limited resources most efficiently) Problem description decisions goal (objective) constraints Mathematical model decision variables (and variable domains) objective function constraint equations

Mathematical programming
Problem simplification Model formulation Model Algorithm selection Numerical calculation Problem Solution Interpretation Sensitivity analysis

(quality of prediction)
Model selection trade-off between and accuracy (predictive power) model simplicity (being able to solve it) Predictive power (quality of prediction) Low High Simple Model Complex Hard (if not impossible) to compute a solution (lifetime of the universe) Easy to compute a solution (seconds) Solving Linear programming Network models Integer programming Dynamic programming

Today’s agenda Transportation Problem Shortest path Spanning tree
Maximum Flow (Ford Fulkerson) Minimum-cost Flow (Network Simplex)

Transportation problem
Production capacity Requirement for goods a1 b1 a2 b2 Factories Customers i-th factory delivers to j-th customer at cost cij ... ai bj ... 𝑖 𝑎 𝑖 ≥ 𝑗 𝑏 𝑗 necessary condition an bm Minimum cost of transportation satisfying the demand of customers.

Transportation tableau
amount transported cost cij of delivering from ith factory to jth customer supply ai of ith factory 7 x11 3 x12 4 x13 u1 8 x21 2 x22 x23 u2 6 x31 1 x32 5 x33 u3 v1 v2 v3 shadow factory “price” shadow customer’s “price” demand bj of jth customer shadow prices are relative to some baseline

Transportation problem
Overproduction: If produced more then needed ( 𝑖 𝑎 𝑖 > 𝑗 𝑏 𝑗 ) Dummy customer at zero delivery cost Shortage: If required more than produced ( 𝑖 𝑎 𝑖 < 𝑗 𝑏 𝑗 ) Dummy producer at market delivery cost (what it would cost to deliver it from a third party) a1 b1 7 x11 3 x12 4 x13 u1 8 x21 2 x22 x23 u2 6 x31 1 x32 5 x33 u3 v1 v2 v3 7 x11 3 x12 4 x13 x14 u1 8 x21 2 x22 x23 x24 u2 6 x31 1 x32 5 x33 x34 u3 9 x41 x42 11 x43 x44 u4 v1 v2 v3 v4 7 x11 3 x12 4 x13 x14 u1 8 x21 2 x22 x23 x24 u2 6 x31 1 x32 5 x33 x34 u3 v1 v2 v3 v4 a2 b2 Balanced transportation problem 𝑖 𝑎 𝑖 = 𝑗 𝑏 𝑗 a3 b3 a4 b4

Transportation Simplex
Applying the Simplex method to the problem Basic solution min-cost method Pivoting shadow prices set u1 = 0, then ui + vj=cij reduced cost pivot if ui + vj > cij Finding a loop 7 x11 3 x12 4 x13 x14 u1 8 x21 2 x22 x23 x24 u2 6 x31 1 x32 5 x33 x34 u3 v1 v2 v3 v4 3 3 2 6 6 1 2 1 z = 37 3 2 cost = 3×7 + 3×4 + 2×0 + 1×2 + 2×1 + 6×0 = 37 must mark exactly m + n – 1 = 6 cells take the smaller of the two

Transportation Simplex
Applying the Simplex method to the problem Basic solution min-cost method Pivoting shadow prices set u1 = 0, then ui + vj=cij reduced cost pivot if ui + vj > cij Finding a loop 7 x11 3 x12 4 x13 x14 u1 8 x21 2 x22 x23 x24 u2 6 x31 1 x32 5 x33 x34 u3 v1 v2 v3 v4 3 3 2 6 -5 1 2 7 6 4 z = 37 ui =0 and vj must sum up to cij = 4 vj = 4

Transportation Simplex
Applying the Simplex method to the problem Basic solution min-cost method Pivoting shadow prices set u1 = 0, then ui + vj=cij reduced cost pivot if ui + vj > cij Finding a loop 7 x11 3 x12 4 x13 x14 u1 8 x21 2 x22 x23 x24 u2 6 x31 1 x32 5 x33 x34 u3 v1 v2 v3 v4 6 > 3 3 2 7 > > 6 4 > 6 -1 -5 -5 1 2 7 6 4 z = 37 calculate ui + vj

Transportation Simplex
Applying the Simplex method to the problem Basic solution min-cost method Pivoting shadow prices set u1 = 0, then ui + vj=cij reduced cost pivot if ui + vj > cij Finding a loop New basis 7 x11 3 x12 4 x13 x14 u1 8 x21 2 x22 x23 x24 u2 6 x31 1 x32 5 x33 x34 u3 v1 v2 v3 v4 6 > 3 1 3-Δ 3 4 2+Δ 2 > > 7 6 4 > 2 4 6-Δ 6 -1 -5 -5 1 3 1+Δ 2 2-Δ 7 6 4 z = 29 z = 37 Largest feasible Δ = 2

v1,v2,...,vt where (vi,vi+1) in E for i=1,2,...,t-1
s, g, c, d, i, e is a path of length = 31 Shortest path Problem 9 5 b c d 8 8 10 6 10 4 6 s 5 f e 8 3 7 6 9 9 g h i 9 8 Network G = (V,E) where V is the set of nodes and E the set of edges each edge (i,j) can have cost/weight/length cij path is a sequence of nodes connected by edges v1,v2,...,vt where (vi,vi+1) in E for i=1,2,...,t-1 length of a path is sum of lengths of its edges length of a shortest path from s to e?

Shortest path Problem (Dijkstra)
9 5 b c d 8 10 6 8 10 4 6 s 5 f e 8 3 7 6 9 9 g h i 9 8 s b c d e f g h i 0* 8 6* 8* 14 6 15 14* 19 15* 19* 23 27 22* 31 27* 22 31* We calculate distance from s to all vertices (not just e) keep distance estimate d(x) for each node x d(x) is an upper bound on the length of a shortest path from s to x start by setting d(s)=0 and d(x)=∞ for each x≠s; then iteratively pick smallest d(x) and for each (x,y) in E, update d(y)=min(d(y),d(x)+cxy)

Minimum spanning tree (Prim)
9 5 b c d 8 10 6 8 10 4 s 5 6 f e 8 3 7 6 9 9 g h i 9 8 Collection of edges touching all vertices but with no cycles Tree growing start with s (or any other node) attach a cheapest edge sticking out of the tree already built repeat as long as possible

Minimum spanning tree (Kruskal)
9 5 b c d 8 10 6 8 10 4 s 5 6 f e 8 3 7 6 9 9 g h i 9 8 Order edges by cost start with empty forest (no nodes, no edges) add the cheapest edge that does not create a cycle repeat as long as possible 3 4 5 6 7 8 9 10 di ef bg, cd gs, cf, ch fh df, hi, cg, bs fi, ei, bc, gh de, cs

Maximum flow capacity not cost! b c d s f t g h i
4 3 b c d 2 4 2 3 3 1 s 1 f t 2 2 1 2 4 4 3 g h i 3 2 flow across an edge (i,j) = amount xij of goods transported from i to j non-negative and at most the capacity uij what flows into a node flows out (except for source s and sink t) (conservation of flow) How to find a maximum possible flow? Ford-Fulkerson

Maximum flow (Ford-Fulkerson)
start with a zero flow 4 0/4 2/4 3 0/3 2/3 b c d 2 4 2 0/2 0/4 2/2 0/2 0/3 3 2/3 0/3 3 1 0/1 s 0/1 1 f t 2 0/2 2 0/2 1 0/1 2 0/2 4 2/4 0/4 4 0/4 0/3 3 2/3 g h i can increase up to Δ=2 units 3 0/3 2 0/2 represents remaining capacity residual network b c d s f t edges: if not saturated if positive flow (put reverse edge) can improve iff we find a path from s to t g h i

Maximum flow (Ford-Fulkerson)
start with a zero flow 2/4 3/3 2/3 b c d 0/2 0/4 2/2 2/3 0/3 0/1 s 0/1 f t 0/2 0/2 1/2 0/1 1/1 0/2 3/4 2/4 1/4 0/4 2/3 g h i can increase up to Δ=1 units 0/3 0/2 represents remaining capacity residual network b c d s f t edges: if not saturated if positive flow (put reverse edge) can improve iff we find a path from s to t g h i

Maximum flow (Ford-Fulkerson)
start with a zero flow 2/4 3/3 b c d 0/2 0/4 2/2 2/3 0/3 0/1 s 0/1 f t 0/2 1/2 1/1 0/2 4/4 3/4 2/4 1/4 2/3 g h i can increase up to Δ=1 units 0/3 1/3 1/2 0/2 represents remaining capacity residual network b c d s f t edges: if not saturated if positive flow (put reverse edge) can improve iff we find a path from s to t g h i

Maximum flow (Ford-Fulkerson)
start with a zero flow 2/4 3/3 b c d 0/2 0/4 2/2 3/3 2/3 0/3 1/1 0/1 s 0/1 f t 0/2 1/2 0/1 1/1 0/2 4/4 3/4 3/4 2/4 2/3 g h i can increase up to Δ=1 units 2/3 1/3 0/3 2/2 1/2 0/2 represents remaining capacity residual network b c d s f t edges: if not saturated if positive flow (put reverse edge) can improve iff we find a path from s to t g h i

Maximum flow (Ford-Fulkerson)
t cannot be reached from s minimum cut (of capacity 2+3=5) Maximum flow (Ford-Fulkerson) start with a zero flow 2/4 3/3 b c d 0/2 0/4 2/2 3/3 0/3 1/1 s 0/1 f t 0/2 1/2 0/1 0/2 4/4 3/4 1/3 2/3 g h i 0/3 2/3 0/2 2/2 represents remaining capacity residual network b c d nodes reachable from s s f t edges: if not saturated if positive flow (put reverse edge) can improve iff we find a path from s to t g h i

Minimum-cost flow (Network Simplex)
2/4 \$9 3/3 b c net supply bs = +4 d \$8 \$5 \$10 0/2 0/4 2/2 3/3 \$10 0/3 \$8 \$6 \$6 1/1 s 0/1 f t \$5 0/2 1/2 \$4 \$7 \$3 \$8 \$9 0/1 net supply bt = –4 0/2 2/3 3/4 2/3 \$9 \$8 \$9 \$6 g h i 1/3 1/2 total cost: 2×\$6+2×\$8+2×\$9+1×\$8+1×\$9+3×\$5+3×\$8+1×\$8+2×\$9+1×\$4+3×\$9 = \$159 Start by constructing a basis: Include all edges with nonzero flow but not saturated add any additional edges until a spanning tree obtained (all nodes touching at least one edge, no cycles) Is this minimum possible cost (among all flows meeting the supplies/demands bis)? Network Simplex algorithm what if you get a cycle in step 1.?

Minimum-cost flow (Network Simplex)
\$0 – (-\$5) – \$8= -\$3 2/4 \$9 3/3 (-\$13) (-\$3) b -\$5 -\$14 c -\$6 d \$8 \$5 \$10 0/2 0/4 (-\$36) 2/2 3/3 (-\$6) \$10 0/3 \$8 (\$14) \$6 (-\$24) \$6 (\$14) 1/1 \$0 s 0/1 -\$14 f t -\$32 \$5 0/2 1/2 \$4 (-\$4) \$7 \$3 0/1 \$8 \$9 (-\$5) 0/2 2/3 2/3 3/4 (-\$6) \$9 \$8 \$9 \$6 -\$6 g h -\$15 i -\$23 1/3 1/2 0 – \$6 = -\$6 Steps: shadow prices: set ys = \$0, then yu – yv = cuv for edge (u,v) reduced costs yu – yv – cuv Economic interpretation: (-yu) is the price in node u the cost of transportation using green edges matches these prices; perhaps using an edge outside the green network we can do better reduced costs (e.g. take nodes d and i with prices \$6 and \$23; transporting along (d,i) costs only \$3... it pays to buy at d (at \$6), sell at i (at \$23) and even pay the transportation (\$3) (e.g. \$32 at t and \$0 at s) pivot on edge (u,v) if either no flow on edge (u,v) and positive reduced cost edge (u,v) saturated and negative reduced cost

Minimum-cost flow (Network Simplex)
choose this edge to enter 2/4 \$9 (3-Δ)/3 3/3 (-\$13) (-\$3) b -\$5 -\$14 c d -\$6 \$8 \$5 \$10 0/2 0/4 (-\$36) 2/2 3/3 (3-Δ)/3 (-\$6) \$10 0/3 \$8 (\$14) \$6 (-\$24) \$6 (\$14) 1/1 \$0 s 0/1 -\$14 f t -\$32 \$5 0/2 1/2 (1-Δ)/2 \$4 (-\$4) \$7 \$3 0/1 \$8 \$9 (-\$5) 0/2 3/4 2/3 (2-Δ)/3 2/3 (-\$6) \$9 \$8 \$9 \$6 -\$6 g h -\$15 -\$23 i 1/3 1/2 (1+Δ)/3 (1+Δ)/2 we choose this edge to leave largest feasible Δ=1 Steps: shadow prices: set ys = \$0, then yu – yv = cuv for edge (u,v) reduced costs yu – yv – cuv pivot on edge (u,v) if either no flow on edge (u,v) and positive reduced cost edge (u,v) saturated and negative reduced cost

Minimum-cost flow (Network Simplex)
choose this edge to enter 2/4 \$9 (3-Δ)/3 2/3 (-\$13) (-\$3) b -\$5 -\$14 c d -\$6 \$8 \$5 (-\$36) \$10 0/2 0/4 2/2 2/3 (3-Δ)/3 (-\$6) \$10 0/3 \$8 (\$14) \$6 (-\$24) \$6 (\$14) 1/1 s \$0 0/1 -\$14 f t -\$32 \$5 0/2 0/2 (1-Δ)/2 \$4 (-\$4) \$7 \$3 0/1 \$8 \$9 (-\$5) 0/2 1/3 3/4 2/3 (2-Δ)/3 (-\$6) \$9 \$8 \$9 \$6 -\$6 g h -\$15 i -\$23 (1+Δ)/3 2/3 2/2 (1+Δ)/2 total cost: 2×\$6+2×\$8+2×\$9+0×\$8+2×\$9+2×\$5+2×\$8+2×\$8+1×\$9+1×\$4+3×\$9 = \$146 we choose this edge to leave largest feasible Δ=1 New basis Steps: shadow prices: set ys = \$0, then yu – yv = cuv for edge (u,v) reduced costs yu – yv – cuv What if Δ can be arbitrarily large? What does it mean for the network? pivot on edge (u,v) if either no flow on edge (u,v) and positive reduced cost edge (u,v) saturated and negative reduced cost

Network problems as Minimum-cost flow
9 5 Shortest path b c d 8 6 8 10 10 4 s 5 6 f e 8 3 6 7 9 9 g h i 9 8 all edges infinity capacity Minimum-cost flow \$9 \$5 b c d \$8 \$10 \$6 \$8 \$10 \$4 net demand be = 1 net supply bs = 1 s \$6 f e \$5 \$8 \$3 \$7 \$6 \$9 \$9 g h i \$9 \$8

Network problems as Minimum-cost flow
4 3 Maximum flow b c d 2 2 3 4 3 1 s 1 f t 2 2 1 2 4 3 4 g h i 3 2 all edges cost \$0 except (t,s) has cost -\$1 and infinity capacity Minimum-cost flow 4 3 b c d 2 2 3 4 3 1 s 1 f t 2 2 1 2 4 3 4 g h i 3 2 -\$1

Network problems as Minimum-cost flow
Transportation problem Minimum-cost flow net supply (a1) net supply (-b1) a1 b1 (a2) (-b2) a2 b2 a3 b3 (a3) (-b3) a4 (a4) (-b4) b4 all edges infinity capacity (edge costs remain the same)

Network problems as Minimum-cost flow
with one source and one sink Minimum-cost flow nodes with positive net supply G (100) (-400) 400 (1100) 100 (-1100) (200) 200 (-200) s 200 t 500 200 (500) (-200) 300 300 net supply of t = the sum of the (negative) net supplies net supply of s = the sum of the (positive) net supplies (-300) (300) nodes with negative net supply new edges have \$0 cost all nodes here now have zero net supply