320 likes | 466 Views
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.
E N D
IEOR 4004 Final Review part I. April 28, 2014
Mathematical programming • Help decision-maker(s) make decisions (whatand howmuchto produce, whichpath is fastest, howto 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
Model selection • trade-off betweenand accuracy (predictive power) model simplicity (being able to solve it) Predictivepower (quality of prediction) Low High Complex Model Simple 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)
Transportationproblem 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 satisfyingthe demand of customers.
Transportationtableau cost cij of delivering from ith factory to jth customer amount transported supply ai of ith factory shadow factory “price” demand bj of jth customer shadow customer’s “price” shadow prices are relative to some baseline
Transportationproblem • Overproduction: If produced more then needed () Dummy customer at zero delivery cost • Shortage: If required more than produced () Dummyproducer at market delivery cost(what it would cost to deliver it from a third party) a1 b1 a2 b2 Balanced transportation problem a3 b3 a4 b4
TransportationSimplex • 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 2 3 3 6 0 6 0 1 2 1 0 z= 37 3 0 0 2 0 0 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
TransportationSimplex • 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 0 2 3 3 0 6 -5 1 2 6 7 4 0 z= 37 ui =0 and vj must sum up to cij = 4 vj = 4
TransportationSimplex • 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 > 0 6 2 3 3 > > > 4 7 6 0 6 ≤ ≤ -5 -1 -5 1 2 6 7 4 0 z= 37 calculate ui + vj
TransportationSimplex • 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 > 0 6 1 4 2 3-Δ 3 2+Δ 3 > > > 4 7 6 0 4 6-Δ 6 2 +Δ ≤ ≤ -5 -1 -5 3 1 1+Δ 2 2-Δ 6 7 4 0 z= 37 z= 29 Largest feasibleΔ = 2
s, g, c, d, i, e is a path of length 6+8+5+3+9 = 31 Shortest path Problem 9 5 b c d 10 8 8 6 10 4 6 e f 5 s 8 3 7 9 6 9 i g h 8 9 • NetworkG = (V,E) where V is the set of nodesand E the set of edges • each edge (i,j) can have cost/weight/lengthcij • pathis 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 10 8 8 6 10 4 6 e f 5 s 8 3 7 9 6 9 i g h 8 9 • We calculate distance from s to allvertices (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 • startby setting d(s)=0 and d(x)=∞ for each x≠s; then iteratively • picksmallestd(x) and for each (x,y) in E, updated(y)=min(d(y),d(x)+cxy)
Minimum spanning tree (Prim) 9 5 b c d 10 8 8 6 10 4 6 e f 5 s 8 3 7 9 6 9 i g h 8 9 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 10 8 8 6 10 4 6 e f 5 s 8 3 7 9 6 9 i g h 8 9 Order edges bycost start with empty forest (no nodes, no edges) add the cheapest edge that does not create a cycle repeat as long as possible
Maximum flow capacity not cost! 4 3 b c d 4 2 2 3 3 1 1 t f s 2 2 1 2 4 3 4 i g h 2 3 • flowacross an edge (i,j) = amount xij of goods transported from i to j • non-negative and at most the capacityuij • what flows into a node flows out(except for source s and sink t) • (conservation offlow) Ford-Fulkerson How to find a maximumpossible flow?
Maximum flow (Ford-Fulkerson) startwith a zeroflow 4 0/4 2/4 3 0/3 2/3 b c d 4 0/4 2 0/2 2 3 0/2 0/3 2/2 2/3 3 0/3 1 0/1 1 0/1 t f s 2 0/2 2 0/2 1 0/1 2 0/2 4 0/4 2/4 3 0/3 2/3 4 0/4 i g h 2 3 can increase up to Δ=2 units 0/2 0/3 represents remaining capacity residual network b c d t f s • edges: • if not saturated • if positive flow(put reverse edge) can improveiff we find a path from s to t i g h
Maximum flow (Ford-Fulkerson) startwith a zeroflow 2/4 3/3 2/3 b c d 0/4 0/2 2/2 2/3 0/3 0/1 0/1 t f s 0/2 1/2 0/2 0/1 1/1 0/2 3/4 2/4 2/3 1/4 0/4 i g h can increase up to Δ=1 units 0/2 0/3 represents remaining capacity residual network b c d t f s • edges: • if not saturated • if positive flow(put reverse edge) can improveiff we find a path from s to t i g h
Maximum flow (Ford-Fulkerson) startwith a zeroflow 2/4 3/3 b c d 0/4 0/2 2/2 2/3 0/3 0/1 0/1 t f s 0/2 1/2 1/1 0/2 4/4 3/4 2/3 2/4 1/4 i g h can increase up to Δ=1 units 1/2 0/2 1/3 0/3 represents remaining capacity residual network b c d t f s • edges: • if not saturated • if positive flow(put reverse edge) can improveiff we find a path from s to t i g h
Maximum flow (Ford-Fulkerson) startwith a zeroflow 2/4 3/3 b c d 0/4 0/2 2/2 3/3 2/3 0/3 -Δ +Δ 1/1 0/1 0/1 t f s 0/2 1/2 +Δ 0/1 1/1 +Δ 0/2 4/4 3/4 3/4 2/3 2/4 +Δ +Δ can increase up to Δ=1 units i g h 2/2 1/2 0/2 2/3 1/3 0/3 represents remaining capacity residual network b c d t f s • edges: • if not saturated • if positive flow(put reverse edge) can improveiff we find a path from s to t i g h
t cannot be reached from s minimumcut (of capacity 2+3=5) Maximum flow (Ford-Fulkerson) startwith a zeroflow 2/4 3/3 b c d 0/4 0/2 2/2 3/3 0/3 1/1 0/1 t f s 0/2 1/2 0/1 0/2 4/4 2/3 3/4 1/3 i g h 2/2 0/2 2/3 0/3 represents remaining capacity residual network b c d nodes reachable from s t f s • edges: • if not saturated • if positive flow(put reverse edge) can improveiff we find a path from s to t i g h
Minimum-cost flow (Network Simplex) $9 2/4 3/3 b c d net supply bs=+4 $8 $5 0/4 $10 0/2 2/2 3/3 $10 $8 0/3 $6 1/1 $6 0/1 t f s $5 0/2 1/2 $4 $7 $3 0/1 $9 $8 net supply bt=–4 0/2 3/4 2/3 2/3 $8 $9 $9 $6 i g h 1/2 1/3 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 Is this minimum possible cost (among all flows meeting the supplies/demands bis)? 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) Network Simplex algorithm what if you get a cycle in step 1.?
Minimum-cost flow (Network Simplex) $0 – (-$5) – $8= -$3 $9 2/4 (-$13) 3/3 -$5 b -$6 c -$14 d (-$3) $8 $5 (-$36) 0/4 $10 0/2 2/2 3/3 (-$6) $10 ($14) $8 0/3 $6 (-$24) 1/1 ($14) $6 0/1 t f -$32 -$14 $0 s $5 0/2 1/2 $4 $7 $3 (-$4) 0/1 $9 $8 (-$5) 0/2 3/4 2/3 2/3 (-$6) $8 $9 $9 $6 i -$23 -$6 g -$15 h 1/2 1/3 0 – $6 = -$6 Steps: shadow prices: set ys= $0, then yu – yv= cuv for edge (u,v) reduced costsyu – yv – cuv (e.g. $32 at t and $0 at s) 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 betterreduced 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) • pivot on edge (u,v) if either • no flow on edge (u,v) and positivereduced cost • edge (u,v) saturatedand negativereduced cost
Minimum-cost flow (Network Simplex) choose this edge to enter $9 2/4 (-$13) 3/3 (3-Δ)/3 -$5 b -$6 c -$14 d (-$3) $8 $5 (-$36) 0/4 $10 0/2 2/2 3/3 (3-Δ)/3 (-$6) $10 ($14) $8 0/3 $6 (-$24) 1/1 ($14) $6 0/1 t f -$32 -$14 $0 s $5 0/2 1/2 $4 (1-Δ)/2 $7 $3 (-$4) 0/1 $9 $8 (-$5) 0/2 3/4 2/3 (2-Δ)/3 2/3 (-$6) $8 $9 $9 $6 i -$23 -$6 g -$15 h 1/2 1/3 (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 costsyu – yv – cuv • pivot on edge (u,v) if either • no flow on edge (u,v) and positivereduced cost • edge (u,v) saturatedand negativereduced cost
Minimum-cost flow (Network Simplex) choose this edge to enter $9 2/4 (-$13) 2/3 (3-Δ)/3 -$5 b -$6 c -$14 d (-$3) $8 $5 (-$36) 0/4 $10 0/2 2/2 2/3 (3-Δ)/3 (-$6) $10 ($14) $8 0/3 $6 (-$24) 1/1 ($14) $6 0/1 t f -$32 -$14 $0 s $5 0/2 0/2 $4 (1-Δ)/2 $7 $3 (-$4) 0/1 $9 $8 (-$5) 0/2 3/4 1/3 (2-Δ)/3 2/3 (-$6) $8 $9 $9 $6 i -$23 -$6 g -$15 h 2/3 2/2 (1+Δ)/3 (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 costsyu – 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 positivereduced cost • edge (u,v) saturatedand negativereduced cost
Network problemsas Minimum-cost flow 5 9 b c Shortest path d 8 8 10 6 10 4 6 e 5 f s 8 3 7 9 6 9 i g h 9 8 all edges infinity capacity Minimum-costflow $5 $9 b c d $10 $8 $8 $6 $10 $4 net demand be = 1 $6 e f s net supply bs = 1 $5 $8 $3 $7 $9 $6 $9 i g h $9 $8
Network problemsas Minimum-cost flow 3 4 b Maximum flow c d 2 4 3 2 3 1 1 f t s 2 2 1 2 4 3 4 i g h 2 3 all edges cost $0 except (t,s) has cost -$1 and infinity capacity Minimum-costflow 3 4 b c d 2 4 3 2 3 1 1 f t s 2 2 1 2 4 ∞ 3 4 i g h 2 3 -$1
Network problemsas Minimum-cost flow Transportation problem Minimum-costflow net supply (-b1) net supply (a1) a1 b1 (-b2) (a2) a2 b2 (-b3) (a3) a3 b3 (-b4) (a4) a4 b4 all edges infinity capacity (edge costs remain the same)
Network problemsas Minimum-cost flow Minimum-costflow with one source and one sink Minimum-cost flow G nodes with positive net supply (100) (-400) 400 100 (1100) (-1100) (200) (-200) 200 200 s t 200 500 (-200) (500) 300 net supply of t = the sumof the (negative) net supplies 300 net supply of s = the sumof the (positive) net supplies (-300) (300) nodes with negative net supply new edges have $0 cost all nodes here now have zero net supply