Introduction to Linear Programming
Introduction to Linear Programming
211
212 Numerical Methods and Optimization: An Introduction
Formulate an LP that would allow Yiming to design the least expensive diet
that satisfies the above requirements.
Yiming has to decide how much of each of the food types should be included
in his diet. Therefore, it is natural to define a decision variable for the amount
of each food type consumed daily:
His objective is to minimize the cost, which can be easily written as a linear
function of decision variables as follows:
calcium:
270x1 + 20x2 + 25x3 + 23x4 + 35x5 ≥ 800;
vitamin C:
x1 + 106x3 ≥ 75;
and calories:
Project
1 2 3 4 5 6
Investment ($) 10,000 25,000 35,000 45,000 50,000 60,000
Payout ($) 12,000 30,000 41,000 55,000 65,000 77,000
Partial investment (i.e., financing only a fraction of the project instead of the
whole project) is allowed for each project, with the payout proportional to the
investment amount. For example, if Jeff decides to invest $5,000 in project 2,
the corresponding payout will be $30,000×($5,000/$25,000)=$6,000. Jeff has
$100,000 available for investment. Formulate an LP to maximize the end-of-
year payout resulting from the investment.
Let
xi = fraction of project i financed, i = 1, . . . , 6.
Then we have the following LP formulation:
In addition, it is required that at least half of the day-shift nurses have week-
ends (Saturday and Sunday) off. Formulate this problem as an LP.
Note that a nurse’s schedule can be defined by the first day of the three-day
working cycle. Thus, we can define the decision variables as follows:
z = x 1 + x2 + x3 + x4 + x5 + x6 + x7 .
To ensure the required number of nurses for Monday, the total number of
nurses that have Monday on their working schedule should be at least 16:
x1 + x6 + x7 ≥ 16.
The demand constraints for the remaining 6 days of the week are formulated
in the same fashion:
x1 + x2 + x7 ≥ 12 (Tuesday)
x1 + x2 + x3 ≥ 18 (Wednesday)
x2 + x3 + x4 ≥ 13 (Thursday)
x3 + x4 + x5 ≥ 15 (Friday)
x4 + x5 + x6 ≥9 (Saturday)
x5 + x6 + x7 ≥7 (Sunday).
Note that only the first three schedules do not involve working on week-
ends. Therefore, the requirement that at least half of the nurses have weekends
off can be expressed as
x1 + x2 + x3 1
≥ .
x1 + x2 + x3 + x4 + x5 + x6 + x7 2
x1 + x2 + x3 − x4 − x5 − x6 − x7 ≥ 0.
Introduction to Linear Programming 217
minimize x1 + x2 + x3 + x4 + x5 + x6 + x7
subject to x1 + x6 + x7 ≥ 16
x1 + x2 + x7 ≥ 12
x1 + x2 + x3 ≥ 18
x2 + x3 + x4 ≥ 13
x3 + x4 + x5 ≥ 15
x4 + x5 + x6 ≥ 9
x5 + x6 + x7 ≥ 7
x1 + x2 + x3 − x4 − x5 − x6 − x7 ≥ 0
x 1 , x2 , x3 , x4 , x5 , x6 , x7 ≥ 0.
This problem has multiple optimal solutions with z ∗ = 31. One of them is
given by
The same shades can be obtained by mixing secondary colors (orange, green,
and purple), each of which is based on mixing two out of three primary col-
ors in equal proportions (red/yellow for orange, yellow/blue for green, and
red/blue for purple). Joe currently has 20 gallons each of red, yellow, and blue
paint, and 10 gallons each of orange, green, and purple paint. If needed, he
can purchase any of the primary color paints for $20 per gallon, however he
would like to save by utilizing the existing paint supplies as much as possible.
Formulate an LP helping Joe to minimize his costs.
We will use index i ∈ {1, . . . , 6} for red, yellow, blue, orange, green, and
purple colors, respectively, and index j ∈ {1, 2} for brown and gray colors,
respectively. Then our decision variables can be defined as
Next we specify the constraints. The total amount of brown and gray paint
made must be at least 50 gallons each:
The amount of each paint used for mixing must not exceed its availability:
x11 + x12 ≤ 20 + x1
x21 + x22 ≤ 20 + x2
x31 + x32 ≤ 20 + x3
x41 + x42 ≤ 10
x51 + x52 ≤ 10
x61 + x62 ≤ 10.
To express the constraints ensuring that the mixing yields the right shade of
brown, note that only three out of six colors used for mixing contain red, and
the total amount of red paint (including that coming from orange and purple
paints) used in the brown mix is
Hence, a constraint for the proportion of red color in the brown mix can be
written as follows:
x11 + 0.5x41 + 0.5x61
= 0.4.
x11 + x21 + x31 + x41 + x51 + x61
This equation can be easily expressed as a linear equality constraint:
Similarly, the proportion of yellow and blue colors in the brown mix is given
by:
x21 + 0.5x41 + 0.5x51
= 0.3
x11 + x21 + x31 + x41 + x51 + x61
and
x31 + 0.5x51 + 0.5x61
= 0.3,
x11 + x21 + x31 + x41 + x51 + x61
which can be equivalently written as
and
−0.3x11 − 0.3x21 + 0.7x31 − 0.3x41 + 0.2x51 + 0.2x61 = 0,
Finally, note that the fact that 20(x1 + x2 + x3 ) is minimized will force each
of the variables x1 , x2 , and x3 to be 0 unless additional red, yellow, or blue
paint is required. The resulting formulation is given by
All variables must be nonnegative. The objective is to minimize the total cost
of transportation:
m n
z= cij xij .
i=1 j=1
We need to make sure that the number of units shipped out of Wi does not
exceed si :
n
xij ≤ si , i = 1, . . . , m.
j=1
m
xij ≥ dj , j = 1, . . . , n.
i=1
We will use index i for the ith resource, i = 1, . . . , m; and index j for the
th
j product, j = 1, . . . , n. We define the decision variables as
c 1 x1 + . . . + c n xn .
The resource constraints, which make sure that the corporation does not ex-
ceed the availability of each resource, are given by
ai1 x1 + . . . + ain xn ≤ bi , i = 1, 2, . . . , m.
Introduction to Linear Programming 221
maximize c1 x1 + ... + c n xn
subject to a11 x1 + ... + a1n xn ≤ b1
.. .. .. ..
. . . .
am1 x1 + ... + amn xn ≤ bm
x1 , . . . , x n ≥ 0,
or, equivalently,
n
maximize c j xj
j=1
n
subject to aij xj ≤ bi , i = 1, 2, . . . , m
j=1
xj ≥ 0, j = 1, 2, . . . , n.
Denoting by
⎡ ⎤ ⎡ ⎤ ⎡ ⎤
a11 ··· a1n b1 c1
⎢ .. .. ⎥ , ⎢ ⎥ ⎢ ⎥
A=⎣ . ..
. . ⎦ b = ⎣ ... ⎦ , c = ⎣ ... ⎦ ,
am1 ··· amn bn cn
maximize cT x
subject to Ax ≤ b
x ≥ 0.
rather strong assumption, especially given that most of the real-life processes
we attempt to model are nonlinear in nature and are typically influenced by
some uncertainties. On the other hand, any mathematical model is only an
approximation of reality, and in many situations a linear approximation is
sufficiently reasonable to serve the purpose. Recall that a linear function f (x)
in IRn is given by
f (x) = c1 x1 + . . . + cn xn ,
where c1 , . . . , cn are constant real coefficients. This implies the properties of
additivity,
f (x + y) = f (x) + f (y) for any x, y ∈ IRn ,
and proportionality,
First, consider the line representing the points where the solid color fabric
constraint is satisfied with equality, x1 + x2 = 450. This line passes through
Introduction to Linear Programming 223
x2 x2
(a) solid fabric constraint (b) printed fabric constraint
450
(x1 + x2 ≤ 450) (x2 ≤ 300)
300
450
x1 x1
x2
(c) budget constraint (d) demand constraint (x1 ≤ 350)
x2
(4x1 + 5x2 ≤ 2, 000)
400
500 350
x1 x1
(e) nonnegativity constraints (f) the feasible region
x2 x2
x1 x1
FIGURE 10.1: Drawing the feasible region in the Heavenly Pouch, Inc.
example.
224 Numerical Methods and Optimization: An Introduction
x2
450
budget constraint
'
points (0,450) and (450,0) and splits the plane into two halves, where only
the points in the lower half-plane satisfy the solid color fabric constraint (Fig-
ure 10.1(a)). Similarly, we can plot the half-planes representing the sets of
points satisfying the printed fabric constraint, the budget constraint, and the
demand constraint, respectively (see Figure 10.1). Intersection of all these
half-planes with the nonnegative quadrant of the plane will give us the fea-
sible region of the problem (Figure 10.1(f)), which represents the set of all
points that satisfy all the constraints. Figure 10.2 shows the feasible region of
the Heavenly Pouch LP, with lines corresponding to each constraint marked
accordingly.
To solve the LP graphically, we will use level sets of the objective function,
which in case of a maximization LP are sometimes referred to as iso-profit
lines. Given a target objective function value (profit) z̄, the iso-profit line is
the set of points on the plane where z = z̄, i.e., it is just the level set of
the objective function z at the level z̄. The iso-profit lines corresponding to
different profit values z̄ may or may not overlap with the feasible region. We
typically start by plotting the iso-profit line for a reasonably low value of z̄ to
Introduction to Linear Programming 225
x2
450
z = 6, 000
'
120 budget constraint
'
z = 3, 000
'
ensure that it contains feasible points and hence can be conveniently shown
on the same plot as the feasible region. For the Heavenly Pouch LP, it appears
reasonable to first plot the iso-profit line for z = 15x1 + 25x2 = 3, 000, which
passes through the points (200, 0) and (0, 120) (see Figure 10.3). We see that
this profit level is feasible, so we can try a higher value, say z = 6, 000. We
see from the illustration that as we increased the target profit value, the new
iso-profit line is parallel to the previous one (since the slope remained the
same), and can be thought of as the result of movement of the previous iso-
profit line up or to the right. If we keep increasing the target value of z, the
corresponding iso-profit line will keep moving toward the upper right corner
of the figure. It is clear that if we select the profit value that is too optimistic
(say z = 10, 000), the iso-profit line will have no common points with the
feasible region.
However, we do not need to keep guessing which values of z would work.
Instead, we observe that the optimal solution in our example corresponds to
the last point that the iso-profit line will have in common with the feasible
region as we move the line toward the upper right corner. From the figure,
226 Numerical Methods and Optimization: An Introduction
Example 10.8 Consider again the Heavenly Pouch example discussed in Sec-
tion 10.1 and just solved graphically. Suppose that the price of a non-reversible
carrier is raised by $5, so the new objective function is z = 20x1 + 25x2 . Solve
the resulting modified Heavenly Pouch LP graphically.
In this case, the iso-profit line has the same slope as the line defining
the budget constraint, so the two lines are parallel (see Figure 10.4). Thus,
all points on the thick line segment between points x∗ = [125, 300]T and
x = [250, 200]T in the figure are optimal. The optimal objective function value
is z ∗ = 10, 000. Thus, there are infinitely many solutions, all of which belong
to the convex combination of two extreme points (also known as vertices or
corners) of the feasible region. As we will see later, any LP that has an optimal
solution must have at least one corner optimum.
minimize x1 + x2
subject to 100x1 + 50x2 ≥ 500 (store visitors)
500x1 + 1, 000x2 ≥ 5, 000 (website visitors)
x 1 , x2 ≥ 0. (nonnegativity)
We start solving the problem graphically by plotting the lines describing the
constraints and drawing the feasible region (Figure 10.5). Then we plot two
level sets for the objective function, which in case of minimization problems
are called iso-cost lines, for z = 15 and z = 10. We observe that as the value
of z decreases, the iso-cost line moves down, toward the origin. If we keep
decreasing z, the iso-cost line will keep moving down, and at some point, will
contain no feasible points. It is clear from the figure that the last feasible point
the iso-cost line will pass through as we keep decreasing the value of z will be
the point of intersection of the lines defining the store visitors constraint and
228 Numerical Methods and Optimization: An Introduction
x2
10
z = 15
'
← store visitors
20/3 constraint z = 10
'
z ∗ = 20/3
'
10/3
website visitors
' constraint
0 10/3 5 20/3 10 x1
we find the optimal solution x∗1 = x∗2 = 10/3 ≈ 3.333, z ∗ = 20/3 ≈ 6.666.
Thus, the store should spend $6,666 on advertising and split this budget evenly
between the magazine and online advertising to reach its goals.
Note that even though the LP we just solved has an unbounded feasible
region, it still has an optimal solution. However, if the objective function was
improving along one of the directions in which the feasible region is unbounded
(called direction of unboundedness), an optimal solution would not exist.
Example 10.10 Consider a problem that has the same objective function and
feasible region as the LP in the previous example, but change the objective to
Introduction to Linear Programming 229
maximization:
maximize x1 + x2
subject to 100x1 + 50x2 ≥ 500
500x1 + 1, 000x2 ≥ 5, 000
x 1 , x2 ≥ 0.
Clearly the objective function value tends to infinity if one of the variables is
increased toward infinity; thus this LP has no optimal solution.
Example 10.11 Assume that the retail store in Example 10.9 has an ad-
vertising budget limited to $5,000. This condition is reflected in the budget
constraint in the corresponding LP model:
minimize x1 + x2
subject to 100x1 + 50x2 ≥ 500 (store visitors)
500x1 + 1, 000x2 ≥ 5, 000 (website visitors)
x1 + x2 ≤ 5 (budget)
x 1 , x2 ≥ 0. (nonnegativity)
From the illustration in Figure 10.5 it is clear that the set of points such that
x1 + x2 ≤ 5 does not overlap with the set of points satisfying each of the
remaining constraints of the LP. Thus, no feasible point exists for this LP.
Indeed, we previously determined that an advertising campaign that will yield
the target results will cost at least $6,666.
For example, the Heavenly Pouch LP, as well as LPs in Examples 10.8 and 10.9
are optimal (which also implies that they are feasible LPs). In particular, the
LP in Example 10.9 is optimal despite its feasible region being unbounded. The
LP considered in Example 10.10 is unbounded, and the LP in Example 10.11
is infeasible.
Later (Theorem 11.5 at page 266) we will establish the following fact.
If an optimal LP has more than one optimal solution, then it is easy to show
that it has infinitely many optimal solutions. Indeed, consider a maximization
LP
max cT x,
x∈X
where X is a polyhedral set, and assume that the LP has two alternative
optimal solutions x∗ and x with the optimal objective value z ∗ = cT x∗ = cT x .
Then, for an arbitrary α ∈ (0, 1) consider a convex combination of x∗ and x ,
y = αx∗ + (1 − α)x ∈ X . We have
so, y is also an optimal solution of the LP. Thus, we established that the
following property holds.
Exercises
10.1. Romeo Winery produces two types of wines, Bordeaux and Romerlot,
by blending Merlot and Cabernet Sauvignon grapes. Making one bar-
rel of Bordeaux blend requires 250 pounds of Merlot and 250 pounds
of Cabernet Sauvignon, whereas making one barrel of Romerlot re-
quires 450 pounds of Merlot and 50 pounds of Cabernet Sauvignon. The
profit received from selling Bordeaux is $800 per barrel, and from selling
Introduction to Linear Programming 231
Romerlot, $600 per barrel. Romeo Winery has 9,000 pounds of Merlot
and 5,000 pounds of Cabernet Sauvignon available. Formulate an LP
model aiming to maximize the winery’s profit. Solve the LP graphically.
10.2. O&M Painters produce orange and maroon paints by mixing the so-
called primary red, yellow, and blue paint colors. The proportions of red,
yellow, and blue paints used to get the required shades are 50%, 40%,
and 10%, respectively for orange, and 60%, 10%, and 30%, respectively
for maroon. What is the maximum combined amount of orange and
maroon paints that O&M Painters can produce, given that they have
6 gallons of red paint, 4 gallons of yellow paint, and 1.8 gallons of blue
paint available for mixing? Formulate this problem as an LP and solve
it graphically.
10.3. The Concrete Guys make two types of concrete by mixing cement, sand,
and stone. The regular mix contains 30% of cement, 15% of sand, and
55% of stone (by weight), and sells for 5 cents/lb. The extra-strong mix
must contain at least 50% of cement, at least 5% of sand, and at least
20% of stone, and sells for 8 cents/lb. The Concrete Guys have 100,000 lb
of cement, 50,000 lb of sand, and 100,000 lb of stone in their warehouse.
Formulate an LP to determine the amount of each mix the Concrete
Guys should make in order to maximize their profit.