Linear Programming Computational Geometry, WS 2007/08 Lecture 7 Prof. Dr. Thomas Ottmann Algorithmen & Datenstrukturen, Institut für Informatik Fakultät für Angewandte Wissenschaften Albert-Ludwigs-Universität Freiburg
Computational Geometry, WS 2007/08 Prof. Dr. Thomas Ottmann2 Overview Problem formulation and example. Incremental, deterministic algorithm. Randomized algorithm. Unbounded linear programs. Linear programming in higher dimensions.
Computational Geometry, WS 2007/08 Prof. Dr. Thomas Ottmann3 Problem Description Maximize c 1 x 1 + c 2 x c d x d Subject to the conditions: a 1,1 x a 1,d x d b 1 a 2,1 x a 2,d x d b 2 ::: a n,1 x a n,d x d b n Linear program of dimension d: c = (c 1,c 2,...,c d ) h i = {(x 1,...,x d ) ; a i,1 x a i,d x d b i } l i = hyperplane that bounds h i ( straight lines, if d=2 ) H = {h 1,..., h n }
Computational Geometry, WS 2007/08 Prof. Dr. Thomas Ottmann4 Example Production of two goods A and B using four raw materials Value of A: 6 CU, value of B: 3 CU Rm1Rm2Rm3Rm4 Prod A Prod B Reserve Maximize profit: f c (x) = 6x A + 3x B under the conditions: x A = 0, x B x A, x B = 0 2x A + 4x B 5 2x A + 1x B 2 6x A + 2x B 4 2x A + 2x B 3 x A, x B 0
Computational Geometry, WS 2007/08 Prof. Dr. Thomas Ottmann5 Chart IiIi (x A, x B ) 1(0, 5/4)(5/2, 0) 2(0, 2)(1, 0) 3(0, 2)(2/3, 0) 4(0, 3/2)(3/2, 0) 2 3/2 5/4 1 1/2 2/313/225/2 xBxB xAxA
Computational Geometry, WS 2007/08 Prof. Dr. Thomas Ottmann6 Chart
Computational Geometry, WS 2007/08 Prof. Dr. Thomas Ottmann7 Structure of Feasible Region 1. Bounded 2. Unbounded 3. Empty C C C
Computational Geometry, WS 2007/08 Prof. Dr. Thomas Ottmann8 Result Four possibilities for the solution of a linear program 1.A vertex of the feasible region is the only solution. 2.One edge of the feasible region contains all solutions. 3.There are no solutions. 4.The feasible region is unbounded toward the direction of optimization. In case 2: Choose the lexicographically minimum solution corner
Computational Geometry, WS 2007/08 Prof. Dr. Thomas Ottmann9 Bounded Linear Programs Assumption : Algorithm UnboundedLP(H, c) yields either a)a ray in H, which is unbounded towards c, or b)two half planes h 1 and h 2, so that h 1 h 2 is bounded towards c, or c)the answer, that LP(H, c) has no solution, because the feasible region is empty.
Computational Geometry, WS 2007/08 Prof. Dr. Thomas Ottmann10 Incremental Algorithm Let C 2 = h 1 h 2 Remaining half planes: h 3,..., h n C i = C i-1 h i = h 1 ... h i Compute-optimal-vertex (H, c) v 2 := l 1 l 2 ; C 2 := h 1 h 2 for i := 3 to n do C i := C i-1 h i vi := optimal vertex of C i C 2 C 3 C 4... C n = C C i = C =
Computational Geometry, WS 2007/08 Prof. Dr. Thomas Ottmann11 Optimal Vertex Lemma 1: Let 2 < i n, then we have : 1.If v i-1 h i, then v i = v i-1. 2.If v i-1 h i, then either C i = or v i l i, where l i is the line bounding h i.
Computational Geometry, WS 2007/08 Prof. Dr. Thomas Ottmann12 Optimal Vertex h1h1 h2h2 h3h3 h4h4 v 3 = v 4 c h1h1 h2h2 h3h3 h4h4 h5h5 c v4v4 v5v5
Computational Geometry, WS 2007/08 Prof. Dr. Thomas Ottmann13 Next Optimal Vertex f c (x) = c 1 x 1 + c 2 x 2 v i-1 C i-1
Computational Geometry, WS 2007/08 Prof. Dr. Thomas Ottmann14 Algorithm: 2D-LP Input:A 2-dimensional Linear Program (H, c ) Output: Either one optimal vertex or or a ray along which (H, c ) is unbounded. if UnboundedLP(H, c ) reports (H, c ) is unbounded or infeasible then return UnboundedLP(H, c ) else report h 1 := h; h 2 := h´ ; v 2 := l 1 l 2 let h 3,...,h n be the remaining half-planes of H for i:= 3 to n do if v i-1 h i then v i := v i-1 else S i-1 := H i-1 * l i v i := 1-dim-LP(S i-1, c ) if v i not exists then return return v n Running time: O(n²)
Computational Geometry, WS 2007/08 Prof. Dr. Thomas Ottmann15 Algorithm 1D-LP
Computational Geometry, WS 2007/08 Prof. Dr. Thomas Ottmann16 Algorithm: 1D-LP Find the point x on l i that maximizes f c (x), subject to the constraints x h j, for 1 j i –1 Observation: l i h j is a ray Let s i-1 := { h 1 l i,..., h i-1 l i } Algorithm 1D-LP{s i-1, c } p 1 = s 1 for j := 2 to i-1 do p j = p j-1 s j if p i-1 then return the optimal vertex of p i-1 else return Time: O(i)
Computational Geometry, WS 2007/08 Prof. Dr. Thomas Ottmann17 Addition of Halfplanes in Different Orders vivi Good Bad
Computational Geometry, WS 2007/08 Prof. Dr. Thomas Ottmann18 Optimal Vertex h1h1 h2h2 h3h3 h4h4 v 3 = v 4 c h1h1 h2h2 h3h3 h4h4 h5h5 c v4v4 v5v5
Computational Geometry, WS 2007/08 Prof. Dr. Thomas Ottmann19 Randomized Algorithm: 2D-LP Input:A 2-dimensional Linear Program (H, c ) Output: Either one optimal vertex or or a ray along which (H, c ) is unbounded. if UnboundedLP(H, c ) reports (H, c ) is unbounded or infeasible then return UnboundedLP(H, c ) else report h 1 := h; h 2 := h´ ; v 2 := l 1 l 2 let h 3,...,h n be the remaining half-planes of H compute a random permutation h 3,..., h n for i:= 3 to n do if v i-1 h i then v i := v i-1 else S i-1 := H i-1 * l i v i := 1-dim-LP(S i-1, c ) if v i not exists then return return v n
Computational Geometry, WS 2007/08 Prof. Dr. Thomas Ottmann20 Randomization Theorem: The 2-dimensional linear programming problem with n constraints can be solved in O(n) randomized expected time using worst-case linear storage.
Computational Geometry, WS 2007/08 Prof. Dr. Thomas Ottmann21 Random Variable X i E[x i ] is the probability that v i-1 h i X i = 1, if v i-1 h i, and X i = 0, otherwise
Computational Geometry, WS 2007/08 Prof. Dr. Thomas Ottmann22 Unbounded Linear Programs i min, an index with i min = min j, 1 j n i := The smaller angle that i makes with c i : The outward normal of h i hihi ii ii c
Computational Geometry, WS 2007/08 Prof. Dr. Thomas Ottmann23 Unbounded Linear Programs H min := { h j H | j = i min } H par := { h j H | j = - i min } H par { H min { h i* c
Computational Geometry, WS 2007/08 Prof. Dr. Thomas Ottmann24 Lemma Let H = {h 1,h 2,...,h n } be a set of half-planes. Assuming that (H min H par ) is not empty. 1.If l i* h j is unbounded in the direction c for every half-plane h j in the set H \ (H min H par ), then (H, c ) is unbounded along a ray contained in l i*. 2.If l i* h j* is bounded in the direction c for some h j* in H \ (H min H par ), then the linear program ({h i*, h j* }, c ) is bounded.
Computational Geometry, WS 2007/08 Prof. Dr. Thomas Ottmann25 Algorithm: Unbounded-LP Input:A 2-Dimensional Linear Program (H, c ) Output: Either a pair of halfplanes bounding the LP or or a ray along which (H, c) is unbounded. 1.For each half plane h i H compute j 2.Let h i be half plane with i = min j, 1 j n 3.H min := { h j H | j = min } 4.H par := { h j H | j = - min } 5.Ĥ = H \ (H min H par ), compute intersection in H min H par 6.If the intersection is empty then report (H, c ) is infeasible else Let h i H min be the half-plane whose line bounds the intersection if there is half plane h j* Ĥ such that l i* h j* bounded in c then report ({h i*, h j* }, c ) is bounded else report is bounded along l i* ( Ĥ )
Computational Geometry, WS 2007/08 Prof. Dr. Thomas Ottmann26 Higher Dimensions Let h 1,...,h d H be the d certificate half-spaces that UnboundedLP returns. C i := h 1 h 2 ... h i Lemma: Let d < i n, and let C i be defined as above. 1. If v i-1 h i, then v i = v i-1 2. If v i-1 h i, then either C i = or v i g i, where g i is the hyperplane that bounds h i.
Computational Geometry, WS 2007/08 Prof. Dr. Thomas Ottmann27 Algorithm: Randomized-LP Input : A linear program (H, c ). Output : Either one optimal vertex or or a ray along which (H, c ) is unbounded. if UnboundedLP(H, c ) reports (H, c ) is unbounded then Report a ray along which (H, c ) unbounded. else Let h 1,...,h d H be the certificate halfplanes returned by UnboundedLP, and let v d be their vertex of intersection Compute a random permutation h d+1,...,h n for i = d+1 to n do if v i-1 h i then v i = v i-1 else S i-1 := H i-1 * bd(h i ) v i := d-1-dim-LP(S i-1, c ) if v i not exists then return return v n
Computational Geometry, WS 2007/08 Prof. Dr. Thomas Ottmann28 Theorem The d-dimensional linear programming problem with n constraints can be solved in O(d!n) expected time using linear storage.