










Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!











A linear program consists of an objective function and a number of linear constraints. The goal is to optimize (minimize or maximize) the objective function under the constraints. Though highly restrictive in that all the functions involved are linear, linear programming has a wide number of practical as well as theoretical applications. Most optimization prob- lems we have considered so far can be cast as the solution to a linear program, sometimes with the added constraint that the solution must be integer, which makes the problem much harder.
Dieter’s Problem
A dieter wants to minimize the cost of food that provides the minimal nutritional require- ments. The following are the parameters of the problem:
m... number of foods n... number of nutrients cj... cost per gram of food j bi... requirement of nutrient i aij... grams of nutrient i per gram of food j
and the variables in the problem are:
xj... grams of food i taken
The problem is formulated as a linear program as follows:
min
∑m j=1 cj^ xj subj
∑m j=1 aij^ xj^ ≥^ bi^ for^ i^ = 1,... , n xi ≥ 0 for j = 1,... , m.
Pill Maker’s Problem
A pill maker produces pills for each of the nutrients and wants to price them so that it maximizes the profit while staying competitive with the different foods. In addition to the previous parameters, the problem has the variables:
yi... cost per gram of nutrient i
and is also formulated as a linear program:
max
∑n i=1 biyi subj
∑n i=1 aij^ yi^ ≤^ cj^ for^ j^ = 1,... , m yi ≥ 0 for i = 1,... , n.
We will see later that these two problems are dual of each other. Linear programming duality shows that both have the same solution (if it exists).
We consider the max flow problem in a (directed) network G = (V, E), with source and sink s, t ∈ V , and edges capacities ce for e ∈ E. Let Out(v) and In(v) denote the outgoing and ingoing edges of v, and let fe denote the flow through edge e: the problem is formulated as a linear program as follows:
max
e∈Out(s) fe subj
e∈Out(v) fe^ −^
e∈In(v) fe^ =^0 for^ v^ ∈^ V^ − {s, t} fe ≤ ce for e ∈ E fe ≥ 0.
Let P = {p 1 , p 2 ,... , pm} and Q = {q 1 , q 2 ,... , qn} be two sets of points in the plane. We would like to know whether there is a line such that P and Q are on opposite sides of
... to make it more interesting, let’s say that points on are not allowed. This problem can be formulated as a linear program. Let pi, 1 , pi, 2 and qi, 1 , qi, 2 be the coordinates of pi and qi. First, we may assume that is not vertical (parallel to the x 2 -axis) for that case can be easily solved (a one-dimensional problem), and so let be described by the equation x 2 = αx 1 + β. We also distinguish two cases: P above and Q below, or viceversa. We deal with the first case, the other is symmetric. So what we want is
pi, 2 > αpi, 1 + β for i = 1,... , m qi, 2 < αqi, 1 + β for i = 1,... , n
To obtain nonstrict inequalities, we introduce ≥ 0
pi, 2 ≥ + αpi, 1 + β for i = 1,... , m qi, 2 ≤ − + αqi, 1 + β for i = 1,... , n
As objective function we take: max . If the LP solution has = 0 or no solution then the sets are not strictly separable. If we insist in obtaining a linear program with only nonnegative variables then we can set α = α+^ − α−^ where α+, α−^ ≥ 0 and similalry for β (a standard trick to change a free variable into positive variables).
Note that this is a problem with just 3 variables (or 5). There are special algorithms that are very efficient when this is the case. In fact, there is a linear time algorithm (with the constant depending on the dimension). We’ll see this later.
Now, we arrange the equations with x 1 , x 2 on the left (as independent variables) and s 1 , s 2 on the right (as dependent variables): right:
z = x 1 + x 2 s 1 = 1 + x 1 − x 2 s 2 = 12 − 3 x 1 − 2 x 2
If we set x 1 = x 2 = 0, then we can read the values s 1 = 1, s 2 = 12 and z = 0. This corresponds to vertex ©1 in the figure. Now, we look at the coefficients of x 1 and x 2 in the expression for z: both are positive, so increasing either will increase z. We choose x 1 to be increased. It can be increased only as far as s 1 and s 2 remain nonnegative: s 1 increases as x 1 increases, so there is no problem, on the other hand, s 2 = 12 − 3 x 1 becomes zero when x 1 = 4. So we exchange the roles of x 1 and s 2 : the equations are rewritten so that s 1 is on the left and x 1 is on the right: first we get
x 1 = 4 −
s 2 −
x 2
and substitute it in the other equations
z =
s 2 −
x 2
s 2 +
x 2
s 1 = 1 +
s 2 −
x 2
− x 2 = 5 −
s 2 −
x 2.
In summary
z = 4 −
s 2 +
x 2
s 1 = 5 −
s 2 −
x 2
x 1 = 4 −
s 2 −
x 2
So now we have x 2 = s 2 = 0 and s 1 = 5, x 1 = 4, z = 4, which corresponds to vertex © 2 in the figure. We see now that only increasing x 2 pays off. To see, how much it can be increased, we consider the equations: s 1 = 5 − (5/3)x 2 = 0 and x 1 = 4 − (2/3)x 2 = 0 which give x 2 = 3 and x 2 = 6, so x 2 can be increased up to 3 and then s 1 becomes 0. So we rearrange the equations with x 2 on the left and s 1 on the right:
x 2 = 3 −
s 2 −
s 1
and
z = 4 −
s 2 +
s 2 −
s 1
s 2 −
s 1
x 1 = 4 −
s 2 −
s 2 −
s 1
s 2 +
s 1.
In summary
z = 5 −
s 2 −
s 1
x 2 = 3 −
s 2 −
s 1
x 1 = 2 −
s 2 +
s 1
Now we have s 1 = s 2 = 0 and x 1 = 2, x 2 = 3, z = 5, which corresponds to vertex ©3 in the figure. We see now that there is advantage in increasing either of the variables s 1 , s 2. The fact that the equations are rewritten in this form (both coeffients of the independent variables are negative), implies that the objective function is at most 5, and so z achieves its maximum under the constraints in vertex ©3.
We consider the LP: max cT^ x subj Ax = b x ≥ 0
where n ≥ m, c is an n×1 column vector, A is an m×n matrix, b is an m×1 column vector, all with entries in R, and x is an n × 1 vector of variables. (If the LP has inequalities, they can be turned into equalities by using slack variables; also if there are free or negative variables they can be changed into nonnegative ones: x = x+^ − x−^ or x′^ = −x respectively. So it is without loss of generality that we take the LP in this form.) Their entries are denoted cj , ai,j , bi and xj respectively. We assume that rank(A) = m, otherwise linearly dependent rows could be removed. For S ⊆ { 1 , 2 ,... , n}, let AS denote the m × |S| matrix whose columns are the columns of A whose indices are in S, keeping the order. Similarly xS and cS. Let B ⊆ { 1 ,... , n} with |B| = m correspond to linearly independent columns of A (such B exists because A has rank m). Such set of columns are called a basis for the LP. Then we can rewrite the constraints as
AB xB + AN xN = b.
Since AB has rank m, it is invertible, so we can write
xB = A− B^1 b − A− B^1 AN xN.
The variables on the left are the basic variables, while those on the right are the nonbasic ones. Similarly, the equation for the objective function can rewritten as
z = cTB xB + cTN xN.
Substituting the expression above for xB in terms of xN in the expression for z we get
z = cTB A− B^1 b + (cTN − cTB A− B^1 AN )xN.
If we set xN = 0, then we get
xB = b ≡ A− B^1 b and z = z ≡ cTB A− B^1 b.
This type of solution xN = 0, xB = b corresponding to a basis is called a basic solution. If xB ≥ 0 then it is a basic feasible solution. It is a vertex in the polyhedron of feasible points, though we are not proving it here. Then we can write, with A = −A− B^1 AN and c = cTN − cTB A− B^1 AN ,
xB = b + AxN z = z + cT^ xN
This describes xB and z as functions of xN. c is called the vector of reduced costs of the nonbasic variables. The constraints written in this form let us formulate a condition for a basic feasible solution to be optimal.
and also in the expression for z:
z = z +
l∈N
clxl
= z +
l∈N −{j}
clxl +
cj aij
xi − bi −
l∈N −{j}
ailxl
z −
cj bi aij
cj aij
xi +
l∈N −{j}
cl −
cj ail aij
xl.
In summary, the new dictionary is:
xj =
−bi aij
aij
xi +
l∈N −{j}
−ail aij
xl
xk =
bk −
akj bi aij
akj bi aij
xi +
l∈N −{j}
akl −
akj ail aij
xl for k ∈ B − {i}
z =
z −
cj bi aij
cj aij
xi +
l∈N −{j}
cl −
cj ail aij
xl
Theorem 2. If ∆ > 0 in each pivoting step, then the simplex algorithm terminates with an optimal basic feasible solution.
Proof. Since ∆ > 0, no basis is repeated, and since the number of basis is at most
(n m
then the algorithm halts after at most that many pivoting steps.
Cycling and Perturbation
In a generic situation, all basic variables are nonzero and so ∆ > 0. Unfortunately, non- generic or degenerate situations are possible in which basic variables may be zero and then ∆ = 0. If this happens and the choice of new basic variable is arbitrary, then a basis can be repeated, the algorithm may cycle, and termination cannot be guaranteed. Fortunately, degenerate situations can be removed by perturbations.^1 There are several known pertur- bation methods or rules. One is to replace b (in Ax = b) with b + ~, where the ~j = j+1, where > 0 is arbitrarily small. This perturbation is implemented symbolically: is not substituted with an actual value, rather a lexicographic rule is derived. Specifically, the following rule is derived (we don’t verify it here) to choose among k, k′^ for both of which the value ∆ above is achieved:
ak′l |ak′j | and prefer the one which this is smallest. (^1) Think of a set of lines in the plane. In the generic situation, no more than two lines intersect at a point. In a degenerate situation, more than two lines can intersect at a point. However, if each line is “perturbed” by a rotation through a very small random angle around a random point, then in the perturbed set of lines, no more than two intersect in a point with probability 1.
Initialization: Phase I of Simplex
In general, finding a first feasible basis is as hard as solving the LP. Such first basis can be found by solving a modified LP’:
max ~ 1 T^ s subj Ax + Is = b x, s ≥ 0
where s is a column vector with variables s 1 , s 2 ,... , sm, I is the m × m identity matrix, and ~1 is a column vector of 1’s. If we assume that b ≥ 0 – which is fine since multiplying by -1 fixes the problem – LP’ has a trivial basis: the variables si:
Is = b − Ax;
so that setting x = 0 gives Is = b or si = bi > 0 which corresponds to a feasible point. So LP’ can be solved using Phase II of the simplex algorithm (we assume that LP’ is nondegenerate, if necessary through the use of the perturbation b + ~). The outcome can be used to find a feasible basis: Suppose it terminates with objective function value z and basis B, then
We now describe an LP problem with n variables and n constraints for which the simplex algorithm takes 2n^ steps under some pivoting rules. Consider the unit cube Cn in Rn defined by the constraints 0 ≤ xi ≤ 1 ,
which has 2n^ vertices. We consider maximization of the cost function z = xn. A vertex of Cn is labeled with a string of 0’s and 1’s indicating the corresponding coordinates: The string w 1 w 2 · · · wn, where wi is 0 or 1, corresponds to xi = wi. By induction on n, we construct a path Pn from 00n−^1 to 10n−^1 that visits all nodes by induction on the dimension: For n = 1, the path 0 → 1 visits the two nodes and clearly corresponds to an edge; in the induction step (from n − 1 to n), we form the path Pn:
000 n−^2 ∗ → 010 n−^2 → 110 n−^2 ∗ → 100 n−^2
where the first ∗ → indicates that we are using a path P (^) n(1)− 1 in the subcube with the first
variable set to 0 (a path that exists by induction hypothesis); the second ∗ → indicates that
we are using a path P (^) n(2)− 1 in the subcube with the first variable set to 1 (the path that exists by induction hypothesis used in the reverse direction); and the middle → corresponds to a single edge e. Thus, by induction hypothesis, the indicated path visits all nodes and travels along edges.
x 2 ≤ M, where M > 0 is arbitrarily large (a value for M can be estimated from the coefficients of the constraints or, better, M can be handled “simbolically,” just by answering appropriately all the predicates in which it is involved; the details are left as an exercise
.. .). To achieve uniqueness, we specify that we want the lexicographically smallest^2 feasible point that minimizes the objective function. We consider an ordering h 1 , h 2 ,... , hn of the constraints (halfspaces) and add them in sequence updating the LP solution as they are added. More precisely, let Hi be the union of the four bounding constrains and h 1 ,... , hi. The algorithm is based on the following observation:
Observation 3. If LP(Hi− 1 , f ) is infeasible, so is LP(Hi, f ). Otherwise, let vi− 1 be the solution for LP(Hi− 1 , f ).
(i) If vi− 1 satisfies hi then vi is also the solution for Hi.
(ii) If vi− 1 does not satisfy hi then vi can be determined as the solution to LP(Hi− 1 ∩ , f ) where is the bounding line of hi (in particular, if LP(Hi− 1 ∩ `, f ) is infeasible, so is LP(H, f )).
Proof. (i) is clear. For (ii), let Ci = P (Hi). If vi− 1 is not in consider the line segment s = vi− 1 vi. s crosses since vi− 1 is on one side and vi on the other. Let x be the intersection point. Clearly f (vi) ≥ f (vi− 1 ). If f (vi) > f (vi− 1 ) then because f is linear then f (vi) > f (x), a contradiction. If f (vi) = f (vi− 1 ) then f (vi) = f (x) and x is lexicographically smaller than vi, also a contradiction.
v
vi
i−1 h i
Ci
Summary. The following box summarizes the algorithm:
Incremental-2D-LP ({h 1 , h 2 ,... , hn}, f ) let vo be the optimal for the four bounding constraints for i = 1 to n do if vi− 1 ∈ hi then vi←vi− 1 else vi←LP({h 1 ,... , hi− 1 } ∩ , f ) where is the bounding line of hi if vi = infeasible then return infeasible return vn
(^2) In the lexicographic ordering, (x 1 , x 2 ) is smaller than (y 1 , y 2 ) if either x 1 < x 2 or x 1 = y 1 and x 2 < y 2.
Analysis. Solving a 1-d linear program takes linear time. So in the i-th step either vi− 1 ∈ hi and the running time is O(1), or vi− 1 6 ∈ hi and the running time is O(i). A worst case input sequence in which the latter always happens is possible and so the worst case running time is O(n^2 ).
On the other hand, for a fixed input, consider a sequence which is a random permutation: what is the probability of the latter case hapenning in step i? It is convenient to use again backward analysis. Fix the subset {h 1 ,... , hi} of first i constraints (but not the sequence !). The probability that the expensive case happens is equal to the probability that one of the constraints that determines vi is hi, the last constraint added. That is at most 2/i because vi is determined by at most two constraints. Since this holds for any fixed subset {h 1 ,... , hi}, then it also holds unconditionally. Therefore the expected running time is
∑
i=
(O(1) + O(i) · (2/i)) = O(n).
The previous algorithm can be generalized to arbitrary dimension d (number of variables). As before, H is a set of constraining halfspaces. We prefer to formulate it as a recursive algorithm rather than as an incremental one. Again, to keep it simple, we handle the problem of forcing always a bounded solution by adding the set of constraints H 0 containing the halfspaces −M ≤ xi ≤ +M.
Random-LP (H, B)
The algorithm is called first with B = ∅. Then defining constraints are added to B as they are found. The proof of correctness is essentially the same as for the incremental 2-d algorithm.
The expected running time satisfies the recurrence, where n = |H| and d′^ = d − |B|,
T (n, d′) ≤ 1 + T (m − 1 , d′) +
d′ m
· T (m − 1 , d′^ − 1)
for d′^ > 1, m > 0, and T (0, d′) = 1, T (m, 0) = 1 for all d′^ and m. We have used that the optimum solution is determined by d′^ constraints (d in total, but |B| aready are in B), and so the probbaility of choosing in step 3 a defining constraint is d′/m. It can be verified by induction (but it is a bit tricky; one has to choose the right induction hypothesis) that T (n, d′) = O(d′!n).
Exercise. Make sure that you understand what is going on at least for d = 0, 1 , 2 (in which case it is essentially the same incremental algorithm).
We show that ˆyT^ = cTB A− B^1 is feasible for DLP (with A = [AB | AN ] separating columns corresponding to basic and nonbasic variables):
yˆT^ A = cTB A− B^1 A = cTB A− B^1 [AB | AN ] = [cTB A− B 1 AB | cTB A− B^1 AN ] ≤ [cTB | cTN ] = cT
where we have used the relation above for the optimal basis. Since also ˆyT^ b = cTB A− B^1 b = z∗, weak-duality implies that DLP has an optimal solution at ˆy and the optimal values of primal and dual are the same. So if y∗^ is any optimal solution to DLP then cT^ x∗^ = y∗T^ b (solutions are not unique in general).
Pairs PLP and DLP for other forms can be determined by reducing the PLP form to the one above. For example consider:
PLP’: max cT^ x subj Ax ≤ b x ≥ 0
DLP’: min yT^ b subj yT^ A ≥ cT y ≥ 0
PLP’ can be written in the form of PLP: substitute A, x and c in PLP with A′^ = [A | I], x′T^ = [xT^ | sT^ ] and c′T^ = [cT^ | 0] respectively, where s are slack variables. Then we get a corresponding DLP: max yT^ b subject to yT^ [A | I] ≥ [cT^ | 0], which is equivalent to DLP’.
The following table summarizes all the possible cases:
max cT 1 x 1 +cT 2 x 2 +cT 3 x 3 subj A 11 x 1 +A 12 x 2 +A 13 x 3 ≤ b 1 A 21 x 1 +A 22 x 2 +A 23 x 3 ≥ b 2 A 31 x 1 +A 32 x 2 +A 33 x 3 = b 3 x 1 ≥ 0 x 2 ≤ 0 x 3 free
min y 1 T b 1 +yT 2 b 2 +y 3 T b 3 subj y 1 ≥ 0 y 2 ≤ 0 y 3 free y 1 T A 11 +yT 2 A 21 +y 3 T A 31 ≥ cT 1 y 1 T A 12 +yT 2 A 22 +y 3 T A 32 ≤ cT 2 y 1 T A 13 +yT 2 A 23 +y 3 T A 33 = cT 3
Note that in general, a constraint in the primal corresponds to a variable in the dual, and a variable in the primal corresponds to a constraint in the dual. We could also deduce such table for the dual of a min LP, by using min f = max(−f ).
Finally, we leave as an exercise to check the following.
Lemma 6. The dual LP of the dual LP is the primal LP.
XV.5 Example: Duality for Network Flow
The LP formulation for the Maximum Network Flow problem is:
max
e∈Out(s) fe subj
e∈Out(v) fe^ −^
e∈In(v) fe^ =^0 for^ v^ ∈^ V^ − {s, t} fe ≤ ce for e ∈ E fe ≥ 0.
or max
e∈Out(s) fe subj
e∈E ([e^ ∈^ Out(v)]^ −^ [e^ ∈^ In(v)])^ fe^ =^0 for^ v^ ∈^ V^ − {s, t} fe ≤ ce for e ∈ E fe ≥ 0.
where [e ∈ Out(v)] = 1 if e ∈ Out(v) and 0 otherwise, and similarly for [e ∈ In(v)]. We follow the rules to construct the dual problem: There is a free variable yv for each v ∈ V − {s, t}, corresponding to the first set of constraints, and a variable ye ≥ 0 for each e ∈ E corresponding to the second set of constraints. There is a constraint corresponding to each variable fe with e = (u, v): if u 6 = s and v 6 = t, then yu − yv + ye ≥ 0; : w if u = s and v 6 = t then −yv + ye ≥ 1; if u 6 = s and v = t then yu + ye ≥ 0; and if u = s and v = t then ye ≥ 1. If we set ys = −1 and yt = 0, these relations can be summarized as
yu − yv + ye ≥ 0.
Finally, the objective function in the dual is:
min
e∈E
ceye.
In summary min
e∈E ceye subj yu − yv + ye ≥ 0 for e = (u, v) ∈ E yv free for v ∈ V − {s, t} ys = − 1 yt = 0 ye ≥ 0 for e ∈ E
This LP can be simplified a bit further: Note that given any solution, we can add 1 to each yv, v ∈ V and this does not affect the objective or the constraints, other than ys = −1 and yt = 0, which become ys = 0 and yt = 1. Therefore, we obtain the LP problem:
min
e∈E ceye subj yu − yv + ye ≥ 0 for e = (u, v) ∈ E yv free for v ∈ V − {s, t} ys = 0 yt = 1 ye ≥ 0 for e ∈ E.
This is an LP for the Minimum s-t-Cut problem! Though this need to be proved.
(i) First, the 0/1 constraint can be relaxed to a nonnegative integer. Because of the minimization, still the optimal solution will be achieved when the variables have 0/ values.
(ii) Second, the integer constraint can be relaxed to nonnegative real, and still the basic solutions are integer (there may be nonbasic solutions that are noninteger though). This is based on the fact that the matrix of constraints is totally unimodular. This is explained later.
Thus, we get that the dual to the max-flow LP is indeed an LP for the min-cut problem. The statement of the max-flow min-cut theorem is a just an example of the strong LP duality.
XV.6 Complementary Slackness
Consider the following PLP and DLP pair:
PLP: max cT^ x subj Ax ≤ b x ≥ 0
DLP: min yT^ b subj yT^ A ≥ cT y ≥ 0
Theorem 8 (Complementary Slackness). If x∗^ is an optimal solution of PLP and y∗ is an optimal solution of DLP then
(y∗T^ A − cT^ )x∗^ = 0 and y∗T^ (b − Ax∗) = 0.
In particular, if xi > 0 then y∗T^ Ai = ci where Ai is the i-th column of A (if a primal
variable is nonzero, then the dual constraint is tight); and if yj > 0 then bj = Aj T^ x∗^ where Aj^ is the j-th row of A (if a dual variable is nonzero, then the primal constraint is tight).
Proof. From weak duality, we have
cT^ x∗^ ≤ y∗T^ Ax∗^ ≤ y∗T^ b.
Since by Strong Duality, cT^ x∗^ = y∗T^ b, then the two inequalities in the sequence must be equalities: y∗T^ b = y∗T^ Ax∗^ = cT^ x∗
and so the stated equations hold. Consider each component, we see that for the first equality to hold, if y∗ j > 0 then bj = Aj T x∗, where Aj T is the j-th row of A; and for the second equality to hold, if x∗ i > 0 then y∗T^ Ai = ci, where Ai is the i-th column of A.
Application to Max-Flow, Min-Cut. Exercise. Verify that complementary slack- ness is just a statement that the maximum cut edges are precisely the edges saturated with the max-flow in corresponding primal and dual solutions.
XV.7 Integer Linear Programming
The integer linear programming problem has the following form:
max cT^ x subj Ax ≤ b x ∈ Z.
where c, A, b have integer entries. The feasibility problem (whether there are solutions to the constraints) is already NP-complete. The fact that is in NP is not entirely trivial because one would needs to show that if the constraints have a solution, then there is such a solution of size polynomial in the size of the input. Here size involves how many bits are needed to represent all the numbers involved, and we omit proving this here.
Lemma 9. The ILP decision problem is NP-hard.
Proof. We use a reduction from 3-SAT. Let
φ = C 1 ∧ C 2 ∧ · · · ∧ Cm
be a 3-CNF formula where each Ci = i, 1 ∨i, 2 ∨ i, 3 and each literali,j is either some xk or ¬xk. An ILP Φ is constructed from φ as follows. Φ has an integer variable zi for each boolean variable xi in φ. For a literal , f () is defined do the following substitutions:
f (`) =
zi if = xi 1 − zi if = ¬xi
For a clause C = 1 ∨ 2 ∨ ` 3 ,
f (C) = f (1 ) + f ( 2 ) + f (` 3 ).
The ILP has the following constraints:
subj f (Cj ) ≥ 1 for j = 1,... , m xi ≤ 1 for all i xi ≥ 0 for all i xi ∈ Z for all i.
It is very easy to check that: φ is satisfiable iff Φ is feasible.
For the network flow problem, we know that when the capacities are integer, then there is an integer solution. This is a property of many linear programs: their basic solutions are integral, and so integral constraints may be dropped.
An m × n matrix A with m ≤ n is called unimodular, if any m × m submatrix of A has determinant +1, 0, or −1. If A is unimodular and B is an invertible m × m submatrix of A, then B−^1 is integral (this follows from Cramer’s rule to obtain the inverse).