Linear Programming
DPV Chapter 7, Part 1
Jim Royer March 20, 2019
Uncredited diagrams are from DPV or homemade. DPV Chapter 7, Part 1 Linear Programming 1 / 1
Linear Programming DPV Chapter 7, Part 1 Jim Royer March 20, 2019 - - PowerPoint PPT Presentation
Linear Programming DPV Chapter 7, Part 1 Jim Royer March 20, 2019 Uncredited diagrams are from DPV or homemade. DPV Chapter 7, Part 1 Linear Programming 1 / 1 Linear Programming: Introduction, 1 Ingredients of Linear Programming a set
Uncredited diagrams are from DPV or homemade. DPV Chapter 7, Part 1 Linear Programming 1 / 1
DPV Chapter 7, Part 1 Linear Programming 2 / 1
DPV Chapter 7, Part 1 Linear Programming 3 / 1
Figure 7.1 (a) The feasible region for a linear program. (b) Contour lines of the objective function: x1 + 6x2 = c for different values of the profit c. (a)
100 200 300 400 100 200 300 400
x2 x1
(b)
100 200 300 400 100 200 300 400
c = 1500 c = 1200 c = 600 x2 x1 Optimum point Profit = $1900 DPV Chapter 7, Part 1 Linear Programming 4 / 1
DPV Chapter 7, Part 1 Linear Programming 5 / 1
p ← the origin while p is not a local max do p ← the neighbor at which the
return p
100 300 200 100 200
DPV Chapter 7, Part 1 Linear Programming 6 / 1
DPV Chapter 7, Part 1 Linear Programming 7 / 1
x1 x3 x2
Optimum
DPV Chapter 7, Part 1 Linear Programming 8 / 1
DPV Chapter 7, Part 1 Linear Programming 9 / 1
a c b
12 10 6 13 11 8 user
A
user
B
user
C
DPV Chapter 7, Part 1 Linear Programming 10 / 1
max 3xAB + 3x
AB + 2xBC + 2x BC + 4xAC + 4x AC
xAB + x
AB + xBC + x BC ≤ 10
[edge (b, B)] xAB + x
AB + xAC + x AC ≤ 12
[edge (a, A)] xBC + x
BC + xAC + x AC ≤ 8
[edge (c, C)] xAB + x
BC + x AC ≤ 6
[edge (a, b)] x
AB + xBC + x AC ≤ 13
[edge (b, c)] x
AB + x BC + xAC ≤ 11
[edge (a, c)] xAB + x
AB ≥ 2
xBC + x
BC ≥ 2
xAC + x
AC ≥ 2
xAB, x
AB, xBC, x BC, xAC, x AC ≥ 0 a c b
12 10 6 13 11 8 user
A
user
B
user
C
Solution via Simplex: xAB = 0.0 x′
AB = 7.0
xBC = 1.5 x′
BC = 1.5
xAC = 0.5 x′
AC = 4.5
UV = the long path allocation for U-V
DPV Chapter 7, Part 1 Linear Programming 11 / 1
DPV Chapter 7, Part 1 Linear Programming 12 / 1
DPV Chapter 7, Part 1 Linear Programming 13 / 1
DPV Chapter 7, Part 1 Linear Programming 14 / 1
(a) s a b c d e t
3 3 4 10 1 2 5 5 2 1 1
(b) s a b c d e t
5 2 1 2 1 4 5 2 1
DPV Chapter 7, Part 1 Linear Programming 15 / 1
(w,u)∈E
(u,z)∈E
(s,u)∈E
DPV Chapter 7, Part 1 Linear Programming 16 / 1
Start with zero flow. Repeat Choose an appropriate path from s to t Increase the flow along the path’s edges as much as possible until there is no path that improves the flow (a) Initial network. (b) First path chosen. (c) Second path chosen. (d) Final flow. (e) Alternative first path. (f) Alternative second path. The b → a edge cancels flow.
(a) s b a t
1 1 1 1 1
(b) s a t (c) s b t (d) s b a t
1 1 1 1
(e) s b a t
1 1 1
(f) s b a t
1 1 1 DPV Chapter 7, Part 1 Linear Programming 17 / 1
Start with zero flow. Repeat Choose an appropriate path from s to t Increase the flow along the path’s edges as much as possible until there is no path that improves the flow
DPV Chapter 7, Part 1 Linear Programming 18 / 1
Start with zero flow. Repeat Choose an appropriate path from s to t Increase the flow along the path’s edges as much as possible until there is no path that improves the flow
Gf ← G // Initially, capacity = unused flow Repeat forever Use BFS to find a path in Gf along which we can increase flow if there is no such path then quit if there is such a path then revise f and Gf
DPV Chapter 7, Part 1 Linear Programming 19 / 1
Gf ← G // Initially, capacity = unused flow Repeat forever Use BFS to find a path in Gf along which we can increase flow if there is such a path then revise f and Gf else quit
DPV Chapter 7, Part 1 Linear Programming 20 / 1
s a b c d e t
3 3 4 10 1 2 1 5 1 2 5
DPV Chapter 7, Part 1 Linear Programming 21 / 1
L R t s
e e
DPV Chapter 7, Part 1 Linear Programming 22 / 1
Gf ← G Repeat forever Use BFS to find a path in Gf along which we can increase flow if there is no such path then quit if there is such a path then revise f and Gf
DPV Chapter 7, Part 1 Linear Programming 23 / 1
(a) A graph G = (V, E) is bipartite when V can be partitioned into two nonempty sets L and R and each edge in E has one endpoint in L and the other in R. (b) Given a bipartite graph G, a bipartite matching is a set
L and R. (E.g., {(Alice,pie), (Bob,tart), (Carol,cake), (Dan,cookie)})
Alice cake pie cookie tart Bob Carol Dan DPV Chapter 7, Part 1 Linear Programming 24 / 1
(a) A graph G = (V, E) is bipartite when V can be partitioned into two nonempty sets L and R and each edge in E has one endpoint in L and the other in R. (b) Given a bipartite graph G, a bipartite matching is a set
L and R. (E.g., {(Alice,pie), (Bob,tart), (Carol,cake), (Dan,cookie)})
Alice cake pie cookie tart Bob Carol Dan
We can turn the problem of finding a bipartite matching into a network flow problem by: ◮ Adding a source and target verts s and t. ◮ Adding edges from s to each u ∈ L. ◮ Adding edges from each v ∈ R to t. ◮ Setting the capacity of each edge 1.
Alice cake pie cookie tart Bob Carol Dan t s DPV Chapter 7, Part 1 Linear Programming 24 / 1
bipartite matching → network flow ◮ Add a source and target verts s and t. ◮ Add edges from s to each u ∈ L. ◮ Add edges from each v ∈ R to t. ◮ Set the capacity of each edge 1.
We do not want fractional flows. (E.g., Dan wants a whole cookie!)
If all edge capacities are integers, then our algorithm finds an integral optimal flow.
In general it is hard to find solutions to LP problems if you demand all variables have integer values. (Set up for Chapter 8.)
Alice cake pie cookie tart Bob Carol Dan t s
DPV Chapter 7, Part 1 Linear Programming 25 / 1
bipartite matching → network flow ◮ Add a source and target verts s and t. ◮ Add edges from s to each u ∈ L. ◮ Add edges from each v ∈ R to t. ◮ Set the capacity of each edge 1.
We do not want fractional flows. (E.g., Dan wants a whole cookie!)
If all edge capacities are integers, then our algorithm finds an integral optimal flow.
In general it is hard to find solutions to LP problems if you demand all variables have integer values. (Set up for Chapter 8.)
Alice cake pie cookie tart Bob Carol Dan t s
DPV Chapter 7, Part 1 Linear Programming 25 / 1