Linear Programming in 2D
Transcript of Linear Programming in 2D
Linear Programming in 2D
1 Linear Programminggeometric problem formulationproblem specification
2 Incremental 2D Linear Programmingadding constraints one by onealgorithm for 2D bounded LP
MCS 481 Lecture 10Computational Geometry
Jan Verschelde, 8 February 2019
Computational Geometry (MCS 481) Linear Programming in 2D L-10 8 February 2019 1 / 21
Linear Programming in 2D
1 Linear Programminggeometric problem formulationproblem specification
2 Incremental 2D Linear Programmingadding constraints one by onealgorithm for 2D bounded LP
Computational Geometry (MCS 481) Linear Programming in 2D L-10 8 February 2019 2 / 21
linear programming in d variables
In standard form, a linear programming problem is given by1 an objective function in d variables, and2 a finite number n of contraints.
Maximize c1x1 + c2x2 + . . .+ cdxdsubject to
a1,1x1 + a1,2x2 + · · ·+ a1,dxd ≤ b1a2,1x1 + a2,2x2 + · · ·+ a2,dxd ≤ b2
...an,1x1 + an,2x2 + · · ·+ an,dxd ≤ bn
If we want only one solution to a problem, then writing the problemas a linear programming problem can get that one solution faster.
Computational Geometry (MCS 481) Linear Programming in 2D L-10 8 February 2019 3 / 21
geometric interpretation
Maximize 2x1 + x2 subject to −x2 ≤ 0, x2 ≤ 2,−x1 − x2 ≤ −1, −x1 + x2 ≤ 1, x1 − x2 ≤ 2, x1 + x2 ≤ 4.
(−1,−1)
(−1,+1)
(0,−1)
(0,+1)
(+1,+1)
(+1,−1)
1 x1
x2
1
(+2,+1)
P
Points on the same red line have the same value of 2x1 + x2.
Computational Geometry (MCS 481) Linear Programming in 2D L-10 8 February 2019 4 / 21
geometric interpretation of half planes
Maximize 2x1 + x2 subject to −x2 ≤ 0, x2 ≤ 2,−x1 − x2 ≤ −1, −x1 + x2 ≤ 1, x1 − x2 ≤ 2, x1 + x2 ≤ 4.
(−1,−1)
(−1,+1)
(0,−1)
(0,+1)
(+1,+1)
(+1,−1)
1 x1
x2
1
(+2,+1)
P
For all half planes a1x1 + a2x2 ≤ b, with b = max(x1,x2)∈P
a1x1 + a2x2.
Computational Geometry (MCS 481) Linear Programming in 2D L-10 8 February 2019 5 / 21
Linear Programming in 2D
1 Linear Programminggeometric problem formulationproblem specification
2 Incremental 2D Linear Programmingadding constraints one by onealgorithm for 2D bounded LP
Computational Geometry (MCS 481) Linear Programming in 2D L-10 8 February 2019 6 / 21
problem specification
On input are1 the coefficients (c1, c2, . . . , cd) of the objective function, and2 a tuple H of n half planes H = (h1,h2, . . . ,hn), given by
I outward pointing normal vectors (ai,1,ai,2, . . . ,ai,d ), andI corresponding bounds bi , for i = 1,2, . . . ,n.
Let P =n⋂
i=1
hi , the polyhedron defined by all half planes.
The output is the point (x1, x2, . . . , xn) ∈ P at whichthe objective function c1x1 + c2x2 + · · ·+ cdxd is maximized.
Questions:1 Does this problem always have a solution?2 Is the solution unique?
Computational Geometry (MCS 481) Linear Programming in 2D L-10 8 February 2019 7 / 21
four cases
Answering the questions1 Does this problem always have a solution?2 Is the solution unique?
leads to the following case analysis:1 The solution is unique.2 The problem is infeasible if P = ∅.3 The problem is unbounded if the optimal value is∞.4 The solution is not unique if the coefficient vector of the objective
is parallel to one of the outward pointing normal vectors of P.
Exercise 1: If the coefficient vector of the objective is parallel to one ofthe outer normals of P, then the solution is not unique. Does theopposite direction hold as well? Can you prove the if and only if?Otherwise make a drawing why such a proof is not possible.
Computational Geometry (MCS 481) Linear Programming in 2D L-10 8 February 2019 8 / 21
making problems bounded with unique solution
To make the problem bounded, we can impose restrictions as follows.
Let M be some large enough number.
For a given objective (c1, c2, . . . , cd), add the constraints:
mi =
{xi ≤ M, if ci > 0,−xi ≤ M, if ci ≤ 0,
for i = 1,2, . . . ,d .
Then m1 ∩m2 ∩ · · · ∩md is an orthogonal wedge.
In case the solution is not unique,then we choose the lexicographically smallest solution as the solution.
Any feasible program has thus a unique bounded solution,which is a vertex of P, called the optimal vertex.
Computational Geometry (MCS 481) Linear Programming in 2D L-10 8 February 2019 9 / 21
Linear Programming in 2D
1 Linear Programminggeometric problem formulationproblem specification
2 Incremental 2D Linear Programmingadding constraints one by onealgorithm for 2D bounded LP
Computational Geometry (MCS 481) Linear Programming in 2D L-10 8 February 2019 10 / 21
adding constraints one by one
Let H = (h1,h2, . . . ,hn) be the tuple of half planes,with the added constraints m1 and m2.
Consider Pi as the region defined by1 m1 and m2, the added constraints, and2 the first i half planes of the tuple H.
Formally, for i = 0,1, . . . ,n:
Pi = m1 ∩m2 ∩ h1 ∩ h2 ∩ · · · ∩ hi .
The regions are getting smaller as we add more constraints:
P0 ⊇ P1 ⊇ P2 ⊇ · · · ⊇ Pn = P.
Computational Geometry (MCS 481) Linear Programming in 2D L-10 8 February 2019 11 / 21
updating the optimal vertex
For i = 0,1, . . . ,n: the region Pi =i⋂
j=1
hi ∩m1 ∩m2,
has the optimal vertex vi with coordinates (xi,1, xi,2):c1xi,1 + c2xi,2 = max
(x1,x2)∈Pi
c1x1 + c2x2.
Lemma (update the optimal vertex)Consider adding hi to Pi−1 with current optimal vertex vi−1.
1 If vi−1 ∈ hi , then vi = vi−1.2 If vi−1 6∈ hi , then either Pi = ∅ or vi ∈ `, the line bounding hi .
Computational Geometry (MCS 481) Linear Programming in 2D L-10 8 February 2019 12 / 21
two cases illustrated
We start with four half planes and the optimal vertex v4.1 Adding h5 does not change the optimal vertex, v5 = v4.2 Adding h6 changes the optimal vertex, v6 6= v5.
v4
(c1, c2)
P4
h5
v5
(c1, c2)
P5
h5
h6
v6
(c1, c2)
P6
Observe that v6 lies on the line of the half plane h6.
Computational Geometry (MCS 481) Linear Programming in 2D L-10 8 February 2019 13 / 21
proof of the first case
1 If vi−1 ∈ hi , then vi = vi−1.
v4
(c1, c2)
P4
h5
v5
(c1, c2)
P5
If vi−1 ∈ hi , then vi−1 is the optimal vertex over Pi , as Pi ⊆ Pi−1,the maximum cannot increase over a smaller set, so vi = vi−1.
Computational Geometry (MCS 481) Linear Programming in 2D L-10 8 February 2019 14 / 21
proof of the second case
2 If vi−1 6∈ hi , then either Pi = ∅ or vi ∈ `, the line bounding hi .
h5
v5
(c1, c2)
P5
h5
h6
v6
(c1, c2)
P6
If Pi = ∅, then we are done. Assume Pi 6= ∅.
Assume v6 6∈ `, we will derive a contradiction.
Computational Geometry (MCS 481) Linear Programming in 2D L-10 8 February 2019 15 / 21
looking for a contradiction
Assume v6 6∈ `, we will derive a contradiction.Consider the line segment (vi−1, vi).
v5
h5
h6
v6
P6
(vi−1, vi) ∈ Pi−1, as Pi ⊆ Pi−1
As the objective is linear,moving from vi to vi−1 increasesthe objective monotonically.
Consider q ∈ (vi−1, vi) ∩ `.q exists because vi−1 6∈ hi
and vi ∈ Pi .As the objective is monotoneincreasing from vi to vi−1,its value at q is higher than at vi .
Computational Geometry (MCS 481) Linear Programming in 2D L-10 8 February 2019 16 / 21
Linear Programming in 2D
1 Linear Programminggeometric problem formulationproblem specification
2 Incremental 2D Linear Programmingadding constraints one by onealgorithm for 2D bounded LP
Computational Geometry (MCS 481) Linear Programming in 2D L-10 8 February 2019 17 / 21
linear programming in one dimensionIf vi−1 6∈ hi and Pi 6= ∅, then vi ∈ `, the line bounding hi .How to compute vi?
The line ` has equation ai,1x1 + ai,2x2 = bi ,we eliminate x2: x2 = (bi − ai,1x1)/ai,2.
This gives rise to a one dimensional problem:
Maximize c1x1 + c2(bi − ai,1x1)/ai,2subject to
aj,1x1 + aj,2(bi − ai,1x1)/ai,2 ≤ bjj = 1,2, . . . , i − 1
Depending on the coefficient of x1, every inequality gives either anupper or a lower bound, so we left with A ≤ x1 ≤ B.
Lemma (cost of one dimensional linear programming)Solving an LP problem in 1 variable with i inequalities takes O(i) time.
Computational Geometry (MCS 481) Linear Programming in 2D L-10 8 February 2019 18 / 21
algorithm for 2D bounded LPAlgorithm 2DBOUNDEDLP(H, c)
Input: H = (h1,h2, . . . ,hn), c = (c1, c2).Output: (x , y) optimal vertex or i if Pi = ∅.
1 set M constraints, v0 is corner of orthogonal wedge2 for i from 1 to n do3 if vi−1 ∈ hi then4 vi = vi−1
5 else if 1D LP is infeasible then6 return i
else7 vi = solution of 1D LP8 return vn
Exercise 2: Show the correctness of 2DBOUNDEDLP.
Computational Geometry (MCS 481) Linear Programming in 2D L-10 8 February 2019 19 / 21
cost of incremental linear programmingTheorem (cost of incremental linear programming)
Algorithm 2DBOUNDEDLP takes O(n2) operations for n half planes.
The proof usesn∑
i=1
O(i) is O(n2).
h7 h6 h5 h4 h3
h2
h1v2
v3
v4v5
v6
v7
c
Computational Geometry (MCS 481) Linear Programming in 2D L-10 8 February 2019 20 / 21