IEOR 4004 Final Review part I.
description
Transcript of IEOR 4004 Final Review part I.
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
Model
Solution
Problemsimplification
Modelformulation
Algorithmselection
Numericalcalculation
InterpretationSensitivity analysis
Model selection
• trade-off betweenand
Simple ComplexModel
Predictive power(quality of prediction) HighLow
Easyto computea solution(seconds)
Hard(if not impossible)
to compute a solution(lifetime of
the universe)
SolvingLinear programming
Network models Integer programmingDynamic programming
accuracy (predictive power)model simplicity (being able to solve it)
Today’s agenda
• Transportation Problem• Shortest path• Spanning tree• Maximum Flow (Ford Fulkerson)• Minimum-cost Flow (Network Simplex)
Transportation problem
Factories Customers
Requirementfor goods
Productioncapacity
... ...
Minimum cost of transportation satisfying the demand of customers.
ai bj
i-th factory
delivers to j-th customer at cost cij
necessary condition
a1
a2
an bm
b1
b2
Transportation tableau
7x11
3x12
4x13
u1
84
x21
2x22
2x23
u2
62
x31
1x32
5x33
u3
3v1
4v2
2v3
3
cost cij of delivering from ith factory to jth customer
supply ai of ith factory
demand bj of jth customershadow customer’s “price”
shadowfactory “price”
shadow prices are relative to some baseline
amounttransported
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
a2 b2
b3a3
a4 b4
7x11
3x12
4x13
u1
84
x21
2x22
2x23
u2
62
x31
1x32
5x33
u3
3v1
4v2
2v3
3
7x11
3x12
4x13
0x14
u1
84
x21
2x22
2x23
0x24
u2
62
x31
1x32
5x33
0x34
u3
3v1
4v2
2v3
3v4
8
7x11
3x12
4x13
0x14
u1
84
x21
2x22
2x23
0x24
u2
62
x31
1x32
5x33
0x34
u3
39
x41
8x42
11x43
0x44
u4
0v1
4v2
2v3
3v4
8
Balanced transportation problem
7x11
3x12
4x13
0x14
u1
8
4x21
2x22
2x23
0x24
u2
6
2x31
1x32
5x33
0x34
u3
3
v1
4v2
2v3
3v4
8
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 costpivot if ui + vj > cij
• Finding a loop
0
20
6
take the smaller of the two
2 6
0
10
3
1 2
0
3 3
0
0
must mark exactly m + n – 1 = 6 cells
cost = 3×7 + 3×4 + 2×0 + 1×2 + 2×1 + 6×0 = 37
z = 37
7x11
3x12
4x13
0x14
u1
8
4x21
2x22
2x23
0x24
u2
6
2x31
1x32
5x33
0x34
u3
3
v1
4v2
2v3
3v4
8
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 costpivot if ui + vj > cij
• Finding a loop
6
2
1 2
3 3
z = 37
0
4
ui =0 and vj must sum up to cij = 4 vj = 4
7 0
-5
6
0
7x11
3x12
4x13
0x14
u1
8
4x21
2x22
2x23
0x24
u2
6
2x31
1x32
5x33
0x34
u3
3
v1
4v2
2v3
3v4
8
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 costpivot if ui + vj > cij
• Finding a loop
6
2
1 2
3 3
z = 37
0
47 0
-5
6
0
-1
calculate ui + vj
-5
7 6 4
6
> >
>
>
≤ ≤
7x11
3x12
4x13
0x14
u1
8
4x21
2x22
2x23
0x24
u2
6
2x31
1x32
5x33
0x34
u3
3
v1
4v2
2v3
3v4
8
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 costpivot if ui + vj > cij
• Finding a loop• New basis
6
22+Δ
11+Δ 22-Δ
33-Δ 3
z = 37
0
47 0
-5
6
0
-1 -5
7 6 4
6
> >
>
>
≤ ≤
+Δ 6-Δ
Largest feasible Δ = 2
2 4
41
3
z = 29
Shortest path Problem
93
4
1086
6
9
7
59
10
85
6
8
9
8
s
b
g
c
h i
f
d
e
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 edgesv1,v2,...,vt where (vi,vi+1) in E for i=1,2,...,t-1
• length of a path is sum of lengths of its edgeslength of a shortest path from s to e?
s, g, c, d, i, e is a path of length 6+8+5+3+9 = 31
Shortest path Problem (Dijkstra)
93
4
1086
6
9
7
59
10
85
6
8
9
8
s
b
g
c
h i
f
d
e
s b c d e f g h i0* ∞ ∞ ∞ ∞ ∞ ∞ ∞ ∞0 8 ∞ ∞ ∞ ∞ 6* ∞ ∞0 8* 14 ∞ ∞ ∞ 6 15 ∞0 8 14* ∞ ∞ ∞ 6 15 ∞0 8 14 19 ∞ ∞ 6 15* ∞0 8 14 19* ∞ ∞ 6 15 230 8 14 19 ∞ 27 6 15 22*0 8 14 19 31 27* 6 15 220 8 14 19 31* 27 6 15 22
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 xstart by setting d(s)=0 and d(x)=∞ for each x≠s; then iterativelypick smallest d(x) and for each (x,y) in E, update d(y)=min(d(y),d(x)+cxy)
Minimum spanning tree (Prim)
93
4
1086
6
9
7
59
10
85
6
8
9
8
Collection of edges touching all vertices but with no cycles
Tree growing1. start with s (or any other node)2. attach a cheapest edge sticking out of the tree already built3. repeat as long as possible
s
b
g
c
h i
f
d
e
Minimum spanning tree (Kruskal)
93
4
1086
6
9
7
59
10
85
6
8
9
8
Order edges by cost
1. start with empty forest (no nodes, no edges)2. add the cheapest edge that does not create a cycle3. 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
s
b
g
c
i
d
e
h
f
Maximum flow
4
1
3
3
34
2
4
2
3
2
s
b
g
c
h i
f
d
t1
42
1
2
3
2
capacitynot cost!
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
0/44
Maximum flow (Ford-Fulkerson)
0/4
0/1
0/3
0/3
0/30/4
0/2
0/2
0/3
0/2
s
b
g
c
h i
f
d
t0/1
0/40/2
0/1
0/2
0/3
0/2
start with azero flow
4
1
3
3
34
2
2
3
2
1
42
1
2
3
2
s
b
g
c
h i
f
d
t
residualnetwork
edges:• if not saturated• if positive flow
(put reverse edge)
representsremaining
capacity
can improve iffwe find a path
from s to t
can increaseup to Δ=2 units
2/4 2/3
2/3
2/3 2/4
2/2
0/41/4
Maximum flow (Ford-Fulkerson)
2/4
0/1
2/3
0/3
2/32/4
0/2
2/2
2/3
0/2
s
b
g
c
h i
f
d
t0/1
0/40/2
0/1
0/2
0/3
0/2
start with azero flow
s
b
g
c
h i
f
d
t
residualnetwork
edges:• if not saturated• if positive flow
(put reverse edge)
representsremaining
capacity
can improve iffwe find a path
from s to t
can increaseup to Δ=1 units
3/41/1
3/3
1/2
1/42/4
Maximum flow (Ford-Fulkerson)
3/4
0/1
2/3
0/3
3/32/4
1/2
2/2
2/3
0/2
s
b
g
c
h i
f
d
t1/1
0/40/2
0/1
0/2
0/3
0/2
start with azero flow
s
b
g
c
h i
f
d
t
residualnetwork
edges:• if not saturated• if positive flow
(put reverse edge)
representsremaining
capacity
can improve iffwe find a path
from s to t
can increaseup to Δ=1 units
4/4
1/3 1/2
Maximum flow (Ford-Fulkerson)
3/4
0/1
2/3
0/3
3/32/4
1/2
2/2
2/3
0/2
s
b
g
c
h i
f
d
t1/1
0/40/2
0/1
0/2
0/3
0/2
start with azero flow
s
b
g
c
h i
f
d
t
residualnetwork
edges:• if not saturated• if positive flow
(put reverse edge)
representsremaining
capacity
can improve iffwe find a path
from s to t
4/4
1/3
2/4
1/2
-Δ+Δ
+Δ
+Δ+Δ
+Δ
can increaseup to Δ=1 units
1/1
3/3
0/1
2/3 2/2
3/4
Maximum flow (Ford-Fulkerson)
4/4
1/1
3/3
0/3
3/32/4
1/2
1/3
2/2
2/3
0/2
s
b
g
c
h i
f
d
t0/1
0/40/2
0/1
0/2
0/3
0/2
start with azero flow
s
b
g
c
h i
f
d
t
residualnetwork
edges:• if not saturated• if positive flow
(put reverse edge)
representsremaining
capacity
can improve iffwe find a path
from s to t
2/3
3/4
2/2
nodes reachable from s
t cannot be reached from s minimum cut (of capacity 2+3=5)
Minimum-cost flow (Network Simplex)
3/4
1/1
3/3
1/3
3/32/4
1/2
2/3
2/2
2/3
1/2
s
b
g
c
h i
f
d
t
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
$9
$3 $4
$10$8$6$6
$9
$7
$5$9
$10
$8$5
$6
$8
$9
$8
Start by constructing a basis:1. Include all edges with nonzero flow but not saturated2. 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)?
netsupplybs = +4
netsupplybt = –4
Network Simplex algorithmwhat if you get a cycle in step 1.?
0/1
0/40/2
0/1
0/2
0/3
0/2
Minimum-cost flow (Network Simplex)
3/40/1
1/1
0/43/30/2
0/1
1/3
0/2
3/32/4
0/3
1/20/2
2/3
2/2
2/3
1/2
s
b
g
c
h i
f
d
t
$9
$3 $4
$10$8$6$6
$9
$7
$5$9
$10
$8$5
$6
$8
$9
$8
Steps:1. shadow prices: set ys = $0, then yu – yv = cuv for edge (u,v)2. reduced costs yu – yv – cuv
$0
-$6
-$14-$5
-$15 -$23
-$14
-$6
-$32
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)
0 – $6 = -$6
$0 – (-$5) – $8= -$3
(-$5)(-$4)
(-$24)
(-$3)(-$13)
(-$6)
(-$6)
($14)
(-$36)
($14)
3. 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
(e.g. $32 at t and $0 at s)
Minimum-cost flow (Network Simplex)
3/40/1
1/1
0/43/30/2 (3-Δ)/3
0/1
1/3
0/2
3/32/4
0/3
1/20/2
2/3
2/2
2/3
1/2
s
b
g
c
h i
f
d
t
$9
$3 $4
$10$8$6$6
$9
$7
$5$9
$10
$8$5
$6
$8
$9
$8
Steps:1. shadow prices: set ys = $0, then yu – yv = cuv for edge (u,v)2. reduced costs yu – yv – cuv
$0
-$6
-$14-$5
-$15 -$23
-$14
-$6
-$32
(-$5)(-$4)
(-$24)
(-$3)(-$13)
(-$6)
(-$6)
($14)
(-$36)
($14)
3. 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
choosethis edgeto enter(3-Δ)/3
(2-Δ)/3
(1+Δ)/2(1+Δ)/3
(1-Δ)/2
largest feasible Δ=1we choose thisedge to leave
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
Minimum-cost flow (Network Simplex)
3/40/1
1/1
0/42/30/2
0/1
2/3
0/2
2/32/4
0/3
0/20/2
2/3
2/2
1/3
2/2
s
b
g
c
h i
f
d
t
$9
$3 $4
$10$8$6$6
$9
$7
$5$9
$10
$8$5
$6
$8
$9
$8
Steps:1. shadow prices: set ys = $0, then yu – yv = cuv for edge (u,v)2. reduced costs yu – yv – cuv
$0
-$6
-$14-$5
-$15 -$23
-$14
-$6
-$32
(-$5)(-$4)
(-$24)
(-$3)(-$13)
(-$6)
($14)
(-$36)
($14)
3. 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
choosethis edgeto enter
largest feasible Δ=1we choose thisedge to leave
(3-Δ)/3
(3-Δ)/3
(2-Δ)/3
(1+Δ)/3
(1-Δ)/2
(1+Δ)/2
(-$6)
New basis
What if Δ can be arbitrarily large?What does it mean for the network?
Network problemsas Minimum-cost flow
93
41086
6
97
59
1085
6
8
98
s
b
g
c
h i
f
d
e
Shortest path
$9$3
$4$10$8$6
$6
$9$7
$5$9
$10$8$5
$6
$8
$9$8
s
b
g
c
h i
f
d
e
Minimum-cost flow
netsupplybs = 1
netdemandbe = 1
all edges infinity
capacity
Network problemsas Minimum-cost flow
4
13
3
34
24
2
32
s
b
g
c
h i
f
d
t1
42
12
32
4
13
3
34
24
2
32
s
b
g
c
h i
f
d
t1
42
12
32
Maximum flow
Minimum-cost flow
∞
all edges cost $0except (t,s) has cost -$1
and infinity capacity
-$1
Network problemsas Minimum-cost flow
Transportation problem Minimum-cost flow
all edges infinity capacity(edge costs remain the same)
b1
b2
b3
b4
(a2)
net supply(a1)
(a3)
(a4)
(-b2)
net supply(-b1)
(-b3)
(-b4)
a1
a2
a3
a4
Network problemsas Minimum-cost flow
Minimum-cost flow Minimum-cost flowwith one source
and one sinknodes with
positivenet supply
nodes withnegative
net supply
net supply of s= the sum ofthe (positive)net supplies
net supply of t= the sum of
the (negative)net supplies
new edges have $0 costall nodes here now
have zero net supply
G
(200)
(500)
(300)
(100) (-400)
(-200)
(-200)
(-300)
s t
(1100) 100
200
500
300
400
200
200
300
(-1100)