Topic-3-Simplex Algorithm-LPPs
Topic-3-Simplex Algorithm-LPPs
and
0 1 2 0 2 1
1 2 3 C2 ↔ C3 1 3 2 Interchange column 2 and column 3
3 1 1 3 1 1
3. The addition of a multiple of one row (or column) to another row (or column).
Notation: kRj + Ri → Ri or kCj + Ci → Ci
For example,
0 1 2 1 3 5 0 1 2 4 1 2
1 2 3 R1 + R2 → R1 1 2 3 ; 1 2 3 2C3 + C1 → C1 7 2 3
3 1 1 3 1 1 3 1 1 5 1 1
8
3.2 The Simplex Method
The Simplex method is an approach to solving linear programming models using slack variables,
tableaus, and pivot variables as a means to finding the optimal solution of an optimization problem.
To solve a linear programming model using the Simplex method the following steps are necessary:
1. Writing the LPP in Standard form
Standard form is the baseline format for all linear programs before solving for the optimal
solution and has three requirements: (1) must be a maximization problem, (2) all linear
constraints must be in a less-than-or-equal-to (≤) inequality, (3) all variables are non-
negative (xi ≥ 0).
These requirements can always be satisfied by transforming any given linear program
using basic algebra and substitution.
Standard form is necessary because it creates an ideal starting point for solving the
Simplex method as efficiently as possible as well as other methods of solving optimization
problems.
To transform a minimization linear program model into a maximization linear program
model, simply multiply both the left and the right sides of the objective function by -1.
Transforming linear constraints from a greater-than-or-equal-to (≥) inequality to a less-
than-or-equal-to (≤) inequality can be done similarly, by multiplying by -1 on both
sides.
Example of an LPP in standard form:
Once the model is in standard form, the slack variables can be added as shown in Step
2 of the Simplex method.
9
Slack variables are additional variables that are introduced into the linear constraints of
a linear program to transform them from inequality constraints to equality constraints.
If the model is in standard form, the slack variables will always have a +1 coefficient.
Slack variables are needed in the constraints to transform them into solvable equalities
with one definite answer.
x1 + 3x2 + 2x3 + s1 = 10
x1 + 5x2 + x3 + s2 = 8
x1 , x2 , x3 , s1 , s2 ≥ 0
After the slack variables are introduced, the tableau can be set up to check for optimality
as described in Step 3.
A Simplex tableau is used to perform row operations on the linear programming model
as well as to check a solution for optimality.
The tableau consists of the coefficients corresponding to the linear constraint variables
and the coefficients of the objective function.
The top row of the tableau states what each column represents. The middle rows
represent the linear constraint variable coefficients from the linear programming model,
and the last row represents the objective function variable coefficients
x1 + 3x2 + 2x3 + s1 = 10
x1 + 5x2 + x3 + s2 = 8
−8x1 − 10x2 − 7x3 + z = 0
x1 x2 x3 s1 s2 z b
1 3 2 1 0 0 10
1 5 1 0 1 0 8
-8 -10 -7 0 0 1 0
Once the tableau has been completed, the model can be checked for an optimal solution
as shown in Step 4.
The optimal solution of a maximization linear programming model are the values as-
signed to the variables in the objective function to give the largest zeta (z) value.
To check optimality using the tableau, all values in the last row must contain values
greater than or equal to zero (≥ 0). If a value is less than zero, it means that variable
has not reached its optimal value.
10
If a tableau is not optimal, the next step is to identify the pivot variable to base a new
tableau on, as described in Step 5.
The pivot variable is used in row operations to identify which variable will become the
unit value and is a key factor in the conversion of the unit value.
The pivot variable can be identified by looking at the bottom row of the tableau and
the indicator.
Assuming that the solution is not optimal, pick the smallest negative value in the
bottom row. One of the values lying in the column of this value will be the pivot
variable.
To find the indicator, divide the (b) values of the linear constraints by their corresponding
values from the column containing the possible pivot variable. The intersection of the
row with the smallest non-negative indicator and the smallest negative value in the
bottom row will become the pivot variable/element.
Upon identifying the pivot variable, a new tableau is then created in Step 6 to optimize
the variable and find the new possible optimal solution.
The new tableau will be used to identify a new possible optimal solution. Row oper-
ations can be performed to optimize the pivot variable while keeping the rest of the
tableau equivalent.
Once the new tableau has been completed, the model can be checked for an optimal
solution.
11
Step 7: Checking Optimality
As explained in Step 4, the optimal solution of a maximization linear programming model
are the values assigned to the variables in the objective function to give the largest zeta
value.
Optimality will need to be checked after each new tableau to see if a new pivot variable
needs to be identified.
A solution is considered optimal if all values in the bottom row are greater than or equal
to zero. If negative values exist, the solution is still not optimal and a new pivot point
will need to be determined.
Step 8: Identifying optimal values
Once the tableau is proven optimal the optimal values can be identified. These can be
found by distinguishing the basic and non-basic variables.
A basic variable can be classified to have a single 1 value in its column and the rest
be all zeros. If a variable does not meet this criteria, it is considered non-basic.
If a variable is non-basic it means the optimal solution of that variable is zero.
If a variable is basic, the row that contains the 1 value will correspond to the b value.
The b value will represent the optimal solution for the given variable.
12
Basic variables: x1 , s1 , z Non-basic variables: x2 , x3 , s2
For the variable x1 , the 1 is found in the second row. This shows that the optimal x1
value is found in the second row of the b values, which is 8.
Variable s1 has a 1 value in the first row, showing the optimal value to be 2 from the
b column. Due to s1 being a slack variable, it is not actually included in the optimal
solution since the variable is not contained in the objective function.
The zeta variable has a 1 in the last row. This shows that the maximum objective value
will be 64 from the b column.
The final solution shows each of the variables having values of:
x1 = 8; x2 = 0; x3 = 0; s1 = 2; s2 = 0; z = 64
The maximum (optimal) value is 64 and found at (8, 0, 0) of the objective function.
Example 3.2.1. Solve the following LPP using the simplex method.
M aximize, p = 5x + 4y
subject to :
3x + 5y ≤ 78
4x + y ≤ 36
x, y ≥ 0
Solution:
3x + 5y + u =78
4x + y + w =36
−5x − 4y + p =0
step 3: Creating the tableau Each row is the coefficient of each of the equations above.
x y u w p b
3 5 1 0 0 78
4 1 0 1 0 36
-5 -4 0 0 1 0
13
step 4: Identifying Pivot element/value
From the botton row, identify the smallest negative number. In this case, its -5 in column
1. So column 1 is the pivot column. Next, divide the b values in the last column by
corresponding values in the pivot column 1.
x y u w p b
3 5 1 0 0 78 26
4 1 0 1 0 36 9
-5 -4 0 0 1 0
Since 9 is smallest, row 2 is the pivot row and 4 is the pivot element.
x y u w p b
3 5 1 0 0 78
1 1/4 0 1/4 0 9
-5 -4 0 0 1 0
Next, reduce the rest of the values in the pivot column to zero. Perform the operations:
3R2 − R1 → R1 and 5R2 + R3 → R3.
x y u w p b
0 17/4 1 -3/4 0 51
1 1/4 0 1/4 0 9
0 -11/4 0 5/4 1 45
Since we still have a negative element in the bottom row, we repeat step 4 and identify a new
pivot element. The negative element (-11/4) occurs in the second column. Therefore column
2 is the new pivot column. Upon diving the values under column b with corresponding pivot
column values, we have
x y u w p b
0 17/4 1 -3/4 0 51 12
1 1/4 0 1/4 0 9 36
0 -11/4 0 5/4 1 45
Since 12 is the smallest value, row 1 is our new pivot row and 17/4 is the new pivot element.
4
Next, reduce the pivot element to 1 using the operation: 17 R1 → R1.
14
x y u w p b
0 1 4/17 -3/17 0 12
1 1/4 0 1/4 0 9
0 -11/4 0 5/4 1 45
1
Next, get zeros (0’s) elsewhere in the pivot column using the operations: 4 R1 − R2 → R2
and 11
4 R1 + R3 → R3.
x y u w p b
0 1 4/17 -3/17 0 12
1 0 -1/17 7/17 0 6
0 0 11/17 13/17 1 78
x = 12; y = 6; u = 0; w = 0; p = 78
Example 3.2.2. Solve the following LPP using the simplex method.
M aximize, p = 3x + 4y + z
subject to :
3x + 10y + 5z ≤ 120
5x + 2y + 8z ≤ 6
8x + 10y + 3z ≤ 105
x, y, z ≥ 0
15
Solution:
The LPP is already in standard form. Introducing slack variables u, v and w yields:
3x + 10y + 5z + v = 120
5x + 2y + 8z + u = 6
8x + 10y + 3z + w = 105
−3x − 4y − z + p = 0
x y z v u w p b
3 10 5 1 0 0 0 120
5 2 8 0 1 0 0 6
8 10 3 0 0 1 0 105
-3 -4 -1 0 0 0 1 0
The second column has the smallest negative value (-4). Upon diving the values in column b with
the corresponding values in the pivot column 2, we obtain
x y z v u w p b
3 10 5 1 0 0 0 120 12
5 2 8 0 1 0 0 6 3
8 10 3 0 0 1 0 105 10.5
-3 -4 -1 0 0 0 1 0
x y z v u w p b
3 10 5 1 0 0 0 120
5/2 1 4 0 1/2 0 0 3
8 10 3 0 0 1 0 105
-3 -4 -1 0 0 0 1 0
Next, reduce the other elements/values in the pivot column to 0. We perform the following row
operations:
−10R2 + R1 →R1
−10R2 + R3 →R3
4R2 + R4 →R4
This yields:
16
x y z v u w p b
-22 0 -35 1 -5 0 0 90
5/2 1 4 0 1/2 0 0 3
-17 0 -37 0 -5 1 0 75
7 0 15 0 2 0 1 12
Notice that there are no more negative values/numbers in the bottom row. We therefore stop and
read the optimal values.
We can clearly see that the Basic variables are y, v, w and p (They have a 1 and 0’s only). The
Non-basic variables are x, z and u (do not have a 1 and 0’s only).
The final solution is:
x = 0; y = 3; z = 0; v = 90; u = 0; w = 75; p = 12
The above optimal solution can also be obtained using the Simplex (Algebraic) method in
TORA software as follows:
TORA moment
Main Menu =⇒ Linear Programming =⇒ Enter required data =⇒ Solve Problem =⇒
Algebraic =⇒ Iterations =⇒ All-slack starting solution (for Max. problem only).
17
The optimal solution is:
x = 0; y = 3; z = 0; v = 90; u = 0; w = 75; p = 12
For minimization problem with two-phases, follow the steps below:
TORA moment
Main Menu =⇒ Linear Programming =⇒ Enter required data =⇒ Solve Problem =⇒
Algebraic =⇒ Iterations =⇒ Two-phase method (for Min. problem). Results.
Exercise 2.
1. Solve the above Reddy Mikks model (in Example 1) using the simplex method. The LPP
model is:
Maximize z = 5x1 + 4x2
subject to:
6x1 + 4x2 ≤ 24
x1 + 2x2 ≤ 6
− x1 + x2 ≤ 1
x2 ≤ 2
x1 , x2 ≥ 0
Solution: x1 = 3; x2 = 1.5; z = 21, 000
2. Solve using the Simplex method the following problem:
Maximize z = f (x, y) = 3x + 2y
subject to :2x + y ≤ 18
2x + 3y ≤ 42
3x + y ≤ 24
x ≥ 0; y ≥ 0
Solution: x = 3; y = 12; z = 33
18
3. Find the minimum value of w = 0.12x1 + 0.15x2 subject to the following constraints:
Solution: x1 = 3; x2 = 2; z = 33/50
19
3.3 LP Models: Investment Problem
In finance, financial decisions are taken based on the trench hold between risk and return. Investors
are usually faced with problems of what asset to invest into and how to come up with an investment
portfolio that can provide the highest return and also lowest risk level. Linear programming has
been used to assist investors to come up with the best investment portfolio.
Example 3.3.1.
Suppose you have $12,000 to invest, and three different funds from which to choose: the municipal
bonds fund (with a 7% return), the local bank’s CDs (with an 8% return) and the high-risk account
(with a 12% return). To minimize the risk, you decide not to invest any more than $2000 in the
high-risk account. For tax reasons, you need to invest at least three times as much in the municipal
bonds as in the bank CDs. Assuming the year end yields are as expected, what are the optimal
investment amounts.
20
Part B: LP model Solution:
Using the Simplex Algorithm in TORA software, the solution to the above LP program is:
Invest $7500 in municipal bonds, $2500 in bank CDs and $2000 in the high-risk account; for the
maximum return or revenue or profit of $965.
Net cash ow requirements are given in thousands of dollars. The company has the following sources
of funds
In any one of the first three months, it can issue 90-day commercial paper bearing a total
interest of 2% for the 3-month period,
There are many questions that the company might want to answer: What interest payments will
the company need to make between January and June? Is it economical to use the line of credit in
some of the months? If so, when? How much?
21
Linear programming gives us a mechanism for answering these questions quickly and easily. It also
allows to answer some “what if” questions about changes in the data without having to resolve the
problem. What if Net Cash Flow in January were -200 (instead of -150)? What if the limit on
the credit line were increased from 100 to 200? What if the negative Net Cash Flow in January
is due to the purchase of a machine worth 150 and the vendor allows part or all of the payment
on this machine to be made in June at an interest of 3% for the 5-month period? The answers to
these questions are readily available when this problem is formulated and solved as a linear program.
We begin by modelling the above short term financing problem. That is, we write it in the
language of linear programming. There are rules about what one can and cannot do within
linear programming. These rules are in place to make certain that the remaining steps of the
process (solving and interpreting) can be successful.
Key to a linear program are the decision variables, objective, and constraints.
During the 6 months, we should be funding short term capital to fulfill the cash flow require-
ments. Given that the sources of funds have different interests and terms, we can set up a
mathematical optimization problem for this work. We will use the company’s wealth v in
June as the objective function and the following decision variables:
In January (i = 1), there is a cash requirement of $150. To meet this requirement, the
company can draw an amount x1 from its line of credit and issue an amount y1 of commercial
paper. Considering the possibility of excess funds z1 , the cash flow balance equation is as
follows.
x1 + y1 − z1 = 150.
Next, in February (i = 2), there is a cash requirement of $100. In addition, principal plus
interest of 1.01x1 is due on the line of credit and 1.003z1 is received on the invested excess
funds. To meet the requirement in February, the company can draw an amount x2 from its
line of credit and issue an amount y2 of commercial paper. So, the cash flow balance equation
for February is as follows.
22
For the months of April, May, and June, issuing a commercial paper is no longer an option,
so we will not have variables y4 , y5 and y6 in the formulation. Furthermore, any commercial
paper issued between January and March requires a payment with 2% interest 3 months later.
Thus, we have the following additional equations:
Note that xi is the balance on the credit line in month i, not the incremental borrowing in
month i. Similarly, zi represents the overall excess funds in month i. This choice of variables
is quite convenient when it comes to writing down the upper bound and non-negativity
constraints.
0 ≤xi ≤ 100
yi ≥ 0
zi ≥ 0.
Maximize v
subject to: x1 + y1 − z1 = 150
x2 + y2 − 1.01x1 + 1.003z1 − z2 = 100
x3 + y3 − 1.01x2 + 1.003z2 − z3 = −200
x4 − 1.02y1 − 1.01x3 + 1.003z3 − z4 = 200
x5 − 1.02y2 − 1.01x4 + 1.003z4 − z5 = −50
− 1.02y3 − 1.01x5 + 1.003z5 − v = −300.
x1 ≤ 100
x2 ≤ 100
x3 ≤ 100
x4 ≤ 100
x5 ≤ 100
xi , yi , zi ≥ 0
Formulating a problem as a linear program means going through the above process of clearly
defining the decision variables, objective, and constraints.
23
Using the solver in TORA, the company’s wealth v in June will be $92,497. To achieve this, the
company will issue $150,000 in commercial paper in January, $49,020 in February and $203,434 in
March. In addition, it will draw $50,980 from its line of credit in February. Excess cash of $351,944
in March will be invested for just one month.
Exercise 3. How would the formulation of the short-term financing problem above change if the
commercial papers issued had a 2 month maturity instead of 3?
Exercise 4. A company will face the following cash requirements in the next eight quarters (positive
entries represent cash needs while negative entries represent cash surpluses).
Q1 Q2 Q3 Q4 Q5 Q6 Q7 Q8
100 500 100 -600 -500 200 600 -900
The other two borrowing opportunities are available at the beginning of every quarter: a 6-
month loan with a 1.8% interest per quarter, and a quarterly loan with a 2.5% interest for
the quarter.
Any surplus can be invested at a 0.5% interest per quarter. Formulate a linear program that maxi-
mizes the wealth of the company at the beginning of Q9 .
Exercise 5. A home buyer in France can combine several mortgage loans to finance the purchase
of a house. Given borrowing needs B and a horizon of T months for paying back the loans, the
home buyer would like to minimize his total cost (or equivalently, the monthly payment p made
during each of the next T months). Regulations impose limits on the amount that can be borrowed
from certain sources. There are n different loan opportunities available. Loan i has a fixed interest
rate ri , a length Ti ≤ T and a maximum amount borrowed bi . The monthly payment on loan i
is not required to be the same every month, but a minimum payment mi is required each month.
However the total monthly payment p over all loans is constant. Formulate a linear program that
finds a combination of loans that minimizes the home buyer’s cost of borrowing. [Hint: In addition
to variables xti for the payment on loan i in month t, it may be useful to introduce a variable for
the amount of outstanding principal on loan i in month t.]
24