Professional Documents
Culture Documents
Part 1
Teuku Naraski Zahari, S.T., M.T.
Introduction
Previously, we saw how to solve two-variable linear programming
problems graphically. Unfortunately, most real-life LPs have many
variables, so a method is needed to solve LPs with more than two
variables.
Add the slack variable 𝑠𝑖 to the 𝑖 th constraint and add the sign
restriction 𝑠𝑖 ≥ 0.
How to Convert an LP to Standard Form
(2/2)
To convert an inequality constraint with more-than-or-equal-to (≥) to
an equality constraint, we define an excess variable/surplus variable
𝑒 where 𝑒𝑖 is the excess variable for the 𝑖 th constraint.
Subtract the excess variable 𝑒𝑖 from the 𝑖 th constraint and add sign
restriction 𝑒𝑖 ≥ 0.
because 𝑠1 = 40 − 15 − 20 = 5 ≥ 0, which
40
means 5 sq.yd of leather are unused.
o Point (15, 20) also satisfies the 2nd constraint
, because 𝑠2 = 60 − 2(15) − 20 = 10 labor
hours are unused. (20,20)
o Finally, note that the point x1 = x2 = 25 fails
Constraint 1
to satisfy the 2nd constraint, because 𝑠2 =
60 − 2(25) − 25 = −15 indicates that (25, 25)
uses more labor than is available.
30 40 𝑥1
Example 1
Leather Limited (5/5)
Hence the standard form of the original LP is,
Example 2
Converting a ≥ inequality constraint (1/2)
Let’s consider the following LP:
Example 2
Converting a ≥ inequality constraint (2/2)
• Define an excess variable for each of the 𝑖 th constraint 𝑒𝑖, which
are the amount by which the 𝑖 th constraint is over satisfied.
• Thus, the LP in standard form will be:
The Simplex Algorithm
The simplex algorithm can be used to solve LPs in which the goal is to maximize
the objective function.
Step 1 Convert the LP to standard form
Step 2 Obtain a Basic Feasible Solution (BFS) from the standard form, if
possible
Step 3 Determine whether the current BFS is optimal
Step 4 If the current BFS is not optimal, determine which non-basic variable
(NBV) should become a basic variable (BV) and which basic variable
should become a non basic variable to find a BFS with a better
objective function value.
Step 5 Use elementary rule operations (EROs) to find a new BFS with a better
objective function value. Go back to Step 3.
Basic and Nonbasic Variables (1/2)
• To solve a LP with 𝑛 variables and 𝑚
constraints algebraically, we would need 𝑥2
60
Constraint 2
Point NBV BV Z
A
A 𝑥1 ; 𝑠1 𝑥2 ; 𝑠2 120 40
𝑧 = 4𝑥1 + 3𝑥2
B 𝑠1 ; 𝑠2 𝑥1 ; 𝑥2 240
B
(20,20)
C 𝑥2 ; 𝑠2 𝑥1 ; 𝑠1 120 Constraint 1
D 𝑥1 ; 𝑥2 𝑠1 ; 𝑠2 0 D C
30 40 𝑥1
Basic Feasible Solution
• A set of constraints can be written as 𝐀𝐱 = 𝐛, a system of 𝑚 linear
equations in 𝑛 variables, where
𝑎11 𝑎21 ⋯ 𝑎1𝑛 𝑥1 𝑏1
𝑎12 𝑎22 ⋯ 𝑎2𝑛 𝑥2 𝑏2
𝐀= ⋮ ⋮ ⋮ , 𝐱 = , 𝐛 =
⋮ ⋮
𝑎1𝑛 𝑎2𝑛 ⋯ 𝑎𝑚𝑛 𝑥𝑛 𝑏𝑚
• A basic solution to 𝐀𝐱 = 𝐛 is obtained by setting 𝑛 – 𝑚 variables equal
to 0 and solving for the remaining m variables.
o This assumes that setting the 𝑛 – 𝑚 variables equal to 0 yields a
unique value for the remaining 𝑚 variables.
• Any basic solution in which all variables are nonnegative is called a
basic feasible solution (or BFS).
Example 2
Dakota Furniture Company (1/17)
The Dakota Furniture company manufactures desk, tables, and
chairs. The manufacture of each type of furniture requires lumber
and two types of skilled labor: finishing and carpentry. The amount of
each resource needed to make each type of furniture is given in the
table below.
Resource Desk Table Chair
Dakota believes that demand for desks and chairs is unlimited, but at
most 5 tables can be sold.
The LP is:
max 𝑧 = 60𝑥1 + 30𝑥2 + 20𝑥3
s.t. 8𝑥1 + 6𝑥2 + 𝑥3 ≤ 48 (lumber constraint)
𝑥1, 𝑥2, 𝑥3 ≥ 0
Example 2
Dakota Furniture Company (4/17)
• Begin the simplex algorithm by converting the constraints of the LP
to the standard form.
• Then convert the LP’s objective function into equation and put in
the row 0.
• To put the constraints in standard form, simply add slack variables
s1, s2, s3, s4, respectively to the four constraints.
• Label the constraints row 1, row 2, row 3, row 4, and add the sign
restrictions si ≥ 0
Example 2
Dakota Furniture Company (5/17)
• Putting rows 1-4 together in row 0 and the sign restrictions yields
these equations and basic variables.
Row 4 x2 + s4 =5 s4 = 5
Example 2
Dakota Furniture Company (6/17)
• To perform the simplex algorithm, we need a basic (although not
necessarily nonnegative) variable for row 0.
• Since z appears in row 0 with a coefficient of 1, and z does not
appear in any other row, we use z as the basic variable.
• With this convention, the basic feasible solution for our initial
canonical form has BV = {𝑧, 𝑠1, 𝑠2, 𝑠3, 𝑠4} and NBV = {𝑥1, 𝑥2, 𝑥3}.
• The initial BFS is then, 𝑧 = 0, 𝑠1 = 48, 𝑠2 = 20, 𝑠3 = 8, 𝑠4 = 5, 𝑥1 = 𝑥2 = 𝑥3 =
0.
• A slack variable can be used as a basic variable if the right hand
side of the constraint is nonnegative.
Example 2
Dakota Furniture Company (7/17)
• Once we have obtained a BFS, we need to determine whether it is
optimal. To do this, we try to determine if there is any way 𝑧 can be
increased by increasing some NBV from its current value of zero
while holding all other NBV at their current values of zero.
• For each NBV in the objective function 𝑍 = 60𝑥1 + 30𝑥2 + 20𝑥3, we
can determine if increasing a NBV will increase z.
• Increasing 𝑥1 causes the greatest rate of increase in 𝑧. If 𝑥1
increases from its current value of zero, it will have to become a
basic variable.
o For this reason, 𝑥1 is called the entering variable.
o Note that 𝑥1 has the most negative coefficient in row 0.
Example 2
Dakota Furniture Company (8/17)
• Next choose the entering variable by identifying the NBV with the
most negative coefficient in row 0.
• Increasing 𝑥1 will make z increase the largest per unit. But as it
increases, the current BV will change value. Thus, increasing 𝑥1 may
cause a current BV to become negative.
• 𝑥1 can only be increased as long as the BV are nonnegative i.e.
𝑠1 , 𝑠2 , 𝑠3 , 𝑠4 ≥ 0. By keeping the other NBV 𝑥2 , 𝑥3 = 0,
48 20 8
𝑥1 ≤ 8
= 6 for 𝑠1 ≥ 0, 𝑥1 ≤ 4
= 5 for 𝑠2 ≥ 0, and 𝑥1 ≤ = 4
2
• In other words, 𝑥1 ≤ 4 for 𝑠1 , 𝑠2 , 𝑠3 , 𝑠4 ≥ 0.
Example 2
Dakota Furniture Company (9/17)
The rule for determining how large an entering variable can be:
• When entering a variable into the basis, compute the ratio
𝑅𝐻𝑆 𝑖𝑛 𝑟𝑜𝑤 𝑗
𝐶𝑜𝑒𝑓𝑓𝑖𝑐𝑖𝑒𝑛𝑡 𝑜𝑓 𝑒𝑛𝑡𝑒𝑟𝑖𝑛𝑔 𝑣𝑎𝑟𝑖𝑎𝑏𝑙𝑒 𝑖𝑛 𝑟𝑜𝑤 𝑗
Row 1 - x3 + s1 - 4s3 = 16 s1 = 16
Row 2 - x2 + 0.5 x3 + s2 - 2 s3 =4 s2 = 4
Row 3 x1 + 0.75x2 + 0.25x3 + 0.5s3 =4 x1 = 4
Row 4 x2 + s4 =5 s4 = 5
Row 4 x2 + s4 =5 s4 = 5
Example 2
Dakota Furniture Company (16/17)
• In Canonical Form 2
o BV = {z, s1, x3, x1, s4}
o NBV = {s3, s2, x2}
• Yielding the BFS 𝑧 = 280, 𝑠1 = 24, 𝑥3 = 8, 𝑥1 = 2, 𝑠4 = 5, and 𝑠2 = 𝑠3 =
𝑥2 = 0
• Solving for z in row 0 yields
𝑧 = 280 − 5𝑥2 − 10𝑠2 − 10𝑠3
• We can see that increasing 𝑥2, 𝑠2, or 𝑠3 (while holding the other NBVs
to zero) will not cause the value of z to increase.
Example 2
Dakota Furniture Company (17/17)
• The solution at the end of the 2nd iteration is therefore optimal.
• The following rule can be applied to determine whether a
canonical form’s BFS is optimal:
o A canonical form is optimal (for a max problem) if each NBV has
a nonnegative coefficient in the canonical form’s row 0.