Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
+ + +
+
+
+
+
+
EEM2046 Engineering Mathematics IV Operations Research
T2, 2013/14 Page 16 of 59
The Background Theory of Simplex Method
Consider a LP in its standard form with n the no. of the variables, m the no. of main
constraints (m < n) and Px = b the set of main constraints.
Minimize/Maximize z = c
T
x
subject to: Px = b
x 0,
where c, x
n
R , b
m
R , P
n m
R , m < n and rank P = m. Assume that b 0 and vector
x inclusive of the decision variables and any newly introduced variables.
Minimize/Maximize z = c
T
x
subject to: Px = b
x 0.
Set x =( )
T T T
B
,0 x
(rearrange x so that the variables that
we are interested appeared first.)
m variables that are set as
T
B
x ,
are known as basic variables.
(n m) variables that are set as
T
0 ,
are known as non basic variables.
Solve B x
B
= b,
P = (B, D), B and D correspond to the basic
variables and the nonbasic variables, respectively.
Basic solution:
x
B
= B
1
b with the nonbasic variables equal zeros.
If the basic solution 0, it is called
basic feasible solution.
EEM2046 Engineering Mathematics IV Operations Research
T2, 2013/14 Page 17 of 59
Example: Consider the following LP problem:
Minimize z
subject to : x
1
+ 2x
2
10
x
1
+ 5x
2
/4 5
x
1,
x
2
0
The standard LP form is:
Minimize z
subject to : x
1
+ 2x
2
+ s
1
= 10
x
1
+ 5x
2
/4 + s
2
= 5
x
1,
x
2
, s
1
, s
2
0
Thus, we have m = 2, n = 4 with Px = b is
x
1
+ 2x
2
+ s
1
= 10
x
1
+ 5x
2
/4 + s
2
= 5
The graph of the feasible region is
Case 1: basic feasible solution
Nonbasic variables: s
1
, s
2
= 0.
Equations: x
1
+ 2x
2
= 10
x
1
+ 5x
2
/4 = 5
Solution: x
1
= 10/13, x
2
= 4 8/13 (unique solution).
Status: basic feasible solutions as all variables > 0.
Vertex: Point A (extreme point of the feasible region).
Case 2: basic infeasible solution
Nonbasic variables: x
2
, s
2
= 0.
Equations: x
1
+ s
1
= 10
x
1
= 5
Solution: x
1
= 5, s
1
= 15 (unique solution).
Status: basic infeasible solutions as the variable x
1
< 0.
Vertex: Point B (infeasible region).
x
1
x
2
A
B
EEM2046 Engineering Mathematics IV Operations Research
T2, 2013/14 Page 18 of 59
Case 3: Nonbasic solution
Consider the solution x
1
= 5, x
2
= 0, s
1
= 5 and s
2
= 10.
Although it satisfies Px = b, but it is a nonbasic solution as we only
have one variable set to 0. Note that it does not refer to any
extreme point of the feasible region.
Definition
Consider a LP in its standard form with n the number of variables, m the no. of main
constraints (m < n) and Px = b the set of main constraints.
(a) A basic solution to Px = b is obtained by setting n m variables equal to 0 and then
solving the m equations for the m variables, provided that the resulting solution exists
and is unique.
(b) If all the variables of the basic solution are nonnegative, it is then known as basic
feasible solution. Otherwise, it is basic infeasible solution.
(c) The variables fixed at zero are called nonbasic and the ones obtained by solving the
equations are called basic.
(d) The leaving variable is the variable that is going to change its status from basic to
nonbasic.
(e) The entering variable is the variable that is going to change its status from nonbasic
to basic.
Theorem
The optimal solution to the linear programming problem
Maximize z = c
T
x, subject to { } 0 x b x x , P ,
when finite, must occur at an extreme point of its feasible set .
Theorem Optimal solution
A point x is an extreme point of the convex set if and only if x is a basic feasible
solution to Px = b, x 0.
- The theorem guarantees that an optimal solution can be found by searching through
the basic feasible solutions. Since the standard LP form includes m linear equations
with n unknown, we have to divide the n variables into two groups:
(1) n m variables are nonbasic variables which we assign zero values; and
(2) the remaining m variables are basic variables, its unique values are obtained by
solving the equations simultaneously.
The resulting values give the basic solution. If the basic solution satisfies the
nonnegativity constraints, then it is a basic feasible solution (correspond to one of
the extreme point of the feasible region). In the attempt to improve the objective
value, we identify one entering variable and one leaving variable so that a new
basic feasible solution can be obtained (move to an adjacent basic feasible solution
with better objective value). This process is repeated until the optimum reached.
EEM2046 Engineering Mathematics IV Operations Research
T2, 2013/14 Page 19 of 59
Simplex Algorithm
Step 1: Convert the problem into the standard LP form
Step 2: Construct the simplex tableau
Step 3: Identify the entering and the leaving variables
Step 4: Perform Gauss-Jordan elimination to obtain the new tableau.
Step 5: If tableau is optimal, then output optimal solution and optimal value. Otherwise,
repeat steps 3 and 4 until optimal stage reached.
- The process of selecting the leaving variable and entering variable is stated in the
optimality condition and feasibility condition.
Optimality condition
The entering variable in maximization (minimization) is the nonbasic variable with the
most negative (positive) coefficient in the objective z-equation. The optimal stage is
reached when all the nonbasic coefficients in the z-equation are nonnegative
(nonpositive).
Feasibility condition
For both maximization and minimization problems, the leaving variable is the current
basic variable associate with the smallest nonnegative ratio (element in Solution column
corresponding element in entering column).
Example: Solve the following Chemical problem by using the simplex algorithm.
(Lecture Notes Series: Engineering Mathematics Volume .)
Maximize z = 3x
1
+ 2x
2
(in $1000 unit)
subject to : x
1
+ 2x
2
6 (1)
2x
1
+ x
2
8 (2)
x
1
+ x
2
1 (3)
x
2
2 (4)
x
1
0, x
2
0
Solution:
Step 1: Convert the problem into the standard LP form
EEM2046 Engineering Mathematics IV Operations Research
T2, 2013/14 Page 20 of 59
Step 2: Construct the simplex tableau
Iteration 0:
Basic z x
1
x
2
s
1
s
2
s
3
s
4
Solution Ratio
z 1 3 2 0 0 0 0 0
s
1
0 1 2 1 0 0 0 6
s
2
0 2 1 0 1 0 0 8
s
3
0 1 1 0 0 1 0 1
s
4
0 0 1 0 0 0 1 2
The basic feasible solution is:
Step 3: Identify the entering and the leaving variables
The entering variable is
The leaving variable is
The row of the leaving variable is known as the pivot equation.
The column for the entering variable is known as the entering column.
The intersection element of the entering column and the pivot equation is
known as the pivot element.
Step 4: Perform the Gauss-Jordan elimination to obtain the new tableau.
We need to re-express the simplex tableau such that the entering column has all
zero entries, except for the pivot element, which must be unity. This can be
accomplished through a series elementary row operations, generalized as follows:
1. For the pivot equation:
new pivot equation = old pivot equation pivot element
2. For all other equations:
new equation = old equation
(its entering column coefficient) (new pivot equation)
To transform the Iteration 0 tableau, the relevant row operations are therefore:
1. For pivot equation, r
3
: r
3
= r
3
/2
2. For z-equation, r
1
: r
1
= r
1
(3) r
3
3. For s
1
-equation, r
2
: r
2
= r
2
(1) r
3
4. For s
3
-equation, r
4
: r
4
= r
4
(1) r
3
5. For s
4
-equation, r
5
: r
5
= r
5
Iteration 1:
Basic z x
1
x
2
s
1
s
2
s
3
s
4
Solution Ratio
z 1 0 1/2 0 3/2 0 0 12
s
1
0 0 3/2 1 1/2 0 0 2
x
1
0 1 1/2 0 1/2 0 0 4
s
3
0 0 3/2 0 1/2 1 0 5
s
4
0 0 1 0 0 0 1 2
The basic feasible solution is
EEM2046 Engineering Mathematics IV Operations Research
T2, 2013/14 Page 21 of 59
Step 5: The tableau is not yet optimal since the z-equation still has negative coefficients.
Repeat Step 3 and Step 4.
From the tableau above, the entering variable is
and the leaving variable is
The elementary row operations involved are as follows:
1. For pivot equation, r
2
: r
2
= r
2
/(3/2)
2. For z-equation, r
1
: r
1
= r
1
(1/2) r
2
3. For x
1
-equation, r
2
: r
3
= r
3
(1/2) r
2
4. For s
3
-equation, r
4
: r
4
= r
4
(3/2) r
2
5. For s
4
-equation, r
5
: r
5
= r
5
r
2
Iteration 2:
Basic z x
1
x
2
s
1
s
2
s
3
s
4
Solution
z 1 0 0 1/3
3
1
1
0 0
3
2
12
x
2
0 0 1 2/3 1/3 0 0
3
1
1
x
1
0 1 0 1/3 2/3 0 0
3
1
3
s
3
0 0 0 1 1 1 0 3
s
4
0 0 0 2/3 1/3 0 1 2/3
The last tableau is optimal because none of the nonbasic variables have a negative
coefficient in the z-equation.
Hence the optimal solution is _________________ and the optimal value is ____.
Example: Solve the following LP problem.
Maximize z = x
1
+ 4x
2
+ 5x
3
subject to : 3x
1
+ 6x
2
+ 3x
3
22
x
1
+ 2x
2
+ 3x
3
14
3x
1
+ 2x
2
14
x
1
, x
2
, x
3
0
Solution:
The standard LP form is
Maximize z = x
1
+ 4x
2
+ 5x
3
subject to : 3x
1
+ 6x
2
+ 3x
3
+ s
1
= 22
x
1
+ 2x
2
+ 3x
3
+ s
2
= 14
3x
1
+ 2x
2
+ s
3
= 14
x
1
, x
2
, x
3
, s
1
, s
2
, s
3
0
Basic z x
1
x
2
x
3
s
1
s
2
s
3
Solution Intercept ratio
z 1 1 4 5 0 0 0 0
s
1
0 3 6 3 1 0 0 22 22/3
s
2
0 1 2 3 0 1 0 14 14/3 (min)
s
3
0 3 2 0 0 0 1 14 -
EEM2046 Engineering Mathematics IV Operations Research
T2, 2013/14 Page 22 of 59
The elementary row operations involved are as follows:
1. For pivot equation, r
3
: r
3
= r
3
/3
2. For z-equation, r
1
: r
1
= r
1
(5) r
3
3. For s
1
-equation, r
2
: r
2
= r
2
(3) r
3
4. For s
3
-equation, r
4
: r
4
= r
4
Basic z x
1
x
2
x
3
s
1
s
2
s
3
Solution Intercept ratio
z 1 2/3 2/3 0 0 5/3 0 70/3
s
1
0 2 4 0 1 1 0 8 8/4 = 2 (min)
x
3
0 1/3 2/3 1 0 1/3 0 14/3 (14/3)/(2/3)=7
s
3
0 3 2 0 0 0 1 14 14/2=7
The elementary row operations involved are as follows:
1. For pivot equation, r
2
: r
2
= r
2
/4
2. For z-equation, r
1
: r
1
= r
1
(2/3) r
2
3. For x
3
-equation, r
3
: r
3
= r
3
(2/3) r
2
4. For s
3
-equation, r
4
: r
4
= r
4
2 r
Basic z x
1
x
2
x
3
s
1
s
2
s
3
Solution
z 1 1 0 0 1/6 3/2 0 74/3
x
2
0 1/2 1 0 1/4 1/4 0 2
x
3
0 0 0 1 1/6 1/2 0 10/3
s
3
0 2 0 0 1/2 1/2 1 10
Since all the objective coefficients are nonnegative, the optimal reached.
The optimal solution is: x
1
= 0, x
2
= 2, x
3
= 10/3.
The optimal value is z = 74/3.
3.2.1 Special cases
1. When there is no leaving variable :- Unbounded solutions
The situation occurs when the coefficient for the denominator of the intercept ratios
are either zero or negative.
Example: Consider a maximization problem.
Iteration 0:
Basic z x
1
x
2
s
1
s
2
Solution Intercept ratio
z 1 4 2 0 0 0
s
1
0 2 2 1 0 14 14/2 = 7(min)
s
2
0 1 3 0 1 9 9 / 1 = 9
EEM2046 Engineering Mathematics IV Operations Research
T2, 2013/14 Page 23 of 59
Iteration 1:
Basic z x
1
x
2
s
1
s
2
Solution Intercept ratio
z 1 0 6 2 0 28
x
1
0 1 1 1/2 0 7 Negative value
s
1
0 0 2 1/2 1 2 Negative value
x
2
can be taken as the entering variable, but the intercept ratios all carry negative
values; the feasible region is unbounded and the optimal value can be improved
infinitely.
2. When zero appears in the column of a nonbasic variable in the z-row of the optimal
tableau :- Multiple optimal solution / Alternative optimal solutions
Example: Consider a maximization problem
Iteration 0:
Basic z x
1
x
2
s
1
s
2
s
3
s
4
Solution Intercept ratio
z 1 8 4 0 0 0 0 0
s
1
0 2 1 1 0 0 0 180 180 / 2 = 90
s
2
0 1 2 0 1 0 0 160 160 / 1 = 160
s
3
0 5/11 5/11 0 0 1 0 50 50 / (5/11) = 550/5
s
4
0 1/4 1/4 0 0 0 1 50 50 / (1/4) = 200
Iteration 1:
Basic z x
1
x
2
s
1
s
2
s
3
s
4
Solution Intercept ratio
z 1 0 0 4 0 0 0 720
x
1
0 1 1/2 0 0 0 90 90 / (1/2) = 180
s
2
0 0 3/2 1/2 1 0 0 70 70 / (3/2) = 140/3
s
3
0 0 5/22 5/22 0 1 0 100/11 (100/11) / (5/22) = 40
s
4
0 0 1/8 1/8 0 0 1 55/2 (55/2) / (1/8) = 220
- The above tableau is the optimal one, with the optimal solution as x
1
=90, x
2
= 0.
- The z-row coefficient of the nonbasic variable x
2
is zero, indicating that x
2
can enter
as the basic solution without changing the value of z.
Iteration 2:
Basic z x
1
x
2
s
1
s
2
s
3
s
4
Solution
z 1 0 0 4 0 0 0 720
x
1
0 1 0 1 0 11/5 0 70
s
2
0 0 0 2 1 33/5 0 10
x
2
0 0 1 1 0 22/5 0 40
s
4
0 0 0 0 0 11/20 1 45/2
EEM2046 Engineering Mathematics IV Operations Research
T2, 2013/14 Page 24 of 59
- This is again another optimal tableau with different optimal solution, x
1
= 70, x
2
=
40.
Thus any point on the line segment joining these two extreme points will also be
optimal:
x
1
= 90 20t and x
2
= 40t with 0 t 1.
3. Tie for the leaving basic variable: Degeneracy
- When there occurs a tie in choosing the leaving variable, then one or more basic
variables may become zero in the next iteration. A basic variable with value zero is
called degenerate.
- Degeneracy implies that there is a possibility that the same BFS is encountered
more than once. This may reveal that the LP model has cycling problem or
redundant constraints.
Cycling
- In cycling, we will loop among a set of basic feasible solutions without going to the
optimal solution.
Example: Consider a maximization problem
Iteration 0:
Basic z x
1
x
2
s
1
s
2
s
3
Solution
ratio
z 1 3 1 0 0 0 0
s
1
0 1
3
1
1 0 0 0 0 (tie)
s
2
0 1 1 0 1 0 0 0 (tie)
s
3
0 1 3 0 0 1 3
Iteration 1:
Basic z x
1
x
2
s
1
s
2
s
3
Solution
ratio
z 1 0 2 3 0 0 0
x
1
0 1
3
1
1 0 0 0 0 (tie)
s
2
0 0
3
2
1 1 0 0 0 (tie)
s
3
0 0
3
2
2 1 0 1 3
Iteration 2:
Basic z x
1
x
2
s
1
s
2
s
3
Solution
z 1 3 1 0 0 0 0
s
1
0 1
3
1
1 0 0 0
s
2
0 1 1 0 1 0 0
s
3
0 1 3 0 0 1 3
The tableau obtained is exactly the same as the initial tableau. The simplex method does
not lead to other extreme point with a better objective return.
EEM2046 Engineering Mathematics IV Operations Research
T2, 2013/14 Page 25 of 59
Redundant Constraints
- At the extreme point of the redundant constraint, there would be more than one set
of nonbasic variables correspond to it. The simplex method would visit all these
sets of nonbasic variables before it moves to other point or before it finds that the
point is the optimal one.
Example: Consider a maximization problem.
Iteration 0:
Basic z x
1
x
2
s
1
s
2
s
3
Solution Intercept ratio
z 1 4 12 0 0 0 0
s
1
0 1 4 1 0 0 16 16 / 6 = 4(tie)
s
2
0 1 2 0 1 0 8 8/ 2 = 4 (tie)
s
3
0 2 1 0 0 1 6 6 / 1 = 6
Iteration 1:
Basic z x
1
x
2
s
1
s
2
s
3
Solution Intercept ratio
z 1 1 0 3 0 0 48
x
2
0 1/4 1 1/4 0 0 4
s
2
0 1/2 0 1/2 1 0 0 0 (min)
s
3
0 7/4 0 1/4 0 1 2
Iteration 2:
Basic z x
1
x
2
s
1
s
2
s
3
Solution
z 1 0 0 2 2 0 48
x
2
0 0 1 1/2 1/2 0 4
x
1
0 1 0 1 2 0 0
s
3
0 0 0 3/2 7/2 1 2
(*Note: The basic feasible solutions at iterations 1 and 2 refer to the same point,
which is the extreme point for the redundant constraint)
EEM2046 Engineering Mathematics IV Operations Research
T2, 2013/14 Page 26 of 59
3.2.2 Matrix Representation of the Simplex Tableau
- In contrast to the step-by-step algorithm of Sect 3.2.1, an entire Simplex tableau
can actually be generated directly using a set of matrix formulae.
- Consider a representative LP problem:
Maximize z = c
T
x
subject to: Ax b
x 0
- At any iteration, the matrix representation of the simplex tableau is given by:
Basic z x
slack variables
Solution
z 1 c
B
T
B
1
A c
T
c
B
T
B
1
c
B
T
B
1
b
x
B
0 B
1
A
B
1
B
1
b
where c
T
is the row vector of original objective function coefficients,
A is the matrix of original LHS coefficients of the main constraints,
b is the column vector of the RHS of the main constraints,
x
B
is the column vector of basic variables for the current iteration,
c
B
T
is the row vector of original objective coefficients corresponding to x
B
,
B is the matrix of original LHS constraint coefficients corresponding to x
B.
Example: Refer to the following LP problem (the same problem as in p. 21) which has
been solved by simplex method.
Maximize z = x
1
+ 4x
2
+ 5x
3
subject to : 3x
1
+ 6x
2
+ 3x
3
22
x
1
+ 2x
2
+ 3x
3
14
3x
1
+ 2x
2
14
x
1
, x
2
, x
3
0
The standard LP form is
Maximize z = x
1
+ 4x
2
+ 5x
3
subject to : 3x
1
+ 6x
2
+ 3x
3
+ s
1
= 22
x
1
+ 2x
2
+ 3x
3
+ s
2
= 14
3x
1
+ 2x
2
+ s
3
= 14
x
1
, x
2
, x
3
, s
1
, s
2
, s
3
0
Applying simplex method, we have the followings:
EEM2046 Engineering Mathematics IV Operations Research
T2, 2013/14 Page 27 of 59
Iteration 0:
Basic z x
1
x
2
x
3
s
1
s
2
s
3
Solution Intercept ratio
z 1 1 4 5 0 0 0 0
s
1
0 3 6 3 1 0 0 22 22/3
s
2
0 1 2 3 0 1 0 14 14/3 (min)
s
3
0 3 2 0 0 0 1 14 -
Iteration 1:
Basic z x
1
x
2
x
3
s
1
s
2
s
3
Solution Intercept ratio
z 1 2/3 2/3 0 0 5/3 0 70/3
s
1
0 2 4 0 1 1 0 8 8/4 = 2 (min)
x
3
0 1/3 2/3 1 0 1/3 0 14/3 (14/3)/(2/3)=7
s
3
0 3 2 0 0 0 1 14 14/2=7
Iteration 2:
Basic z x
1
x
2
x
3
s
1
s
2
s
3
Solution
z 1 1 0 0 1/6 3/2 0 74/3
x
2
0 1/2 1 0 1/4 1/4 0 2
x
3
0 0 0 1 1/6 1/2 0 10/3
s
3
0 2 0 0 1/2 1/2 1 10
The optimal solution is : x
1
= 0, x
2
= 2, x
3
= 10/3.
The optimal value is z = 74/3.
We could regenerate the table at iteration 1 as follows:
Since [ ]
T
B
s x s
3 3 1
x (the basic variables at iteration 1 must be known in advance),
we have
[ ], 0 5 0
T
B
c
1
1
1
]
1
1
1
1
]
1
1 0 0
0 0
0 1 1
1 0 0
0 3 0
0 3 1
3
1
1
B B
Thus, the z-row coefficients for the slack variables are:
[ ] [ ] 0 0
1 0 0
0 0
0 1 1
5 5 0
3
5
3
1
1
1
1
1
]
1
B
T
B
c
EEM2046 Engineering Mathematics IV Operations Research
T2, 2013/14 Page 28 of 59
And the z-row coefficients for the decision variables x are:
[ ] [ ] . 0
3
2
3
2
5 4 1
0 2 3
3 2 1
3 6 3
0 0
3
5
1
1
]
1
1
1
1
]
1
T T
B
A B c c
The right-hand side values (i.e. entries under the Solution column) are:
[ ]
3
70
14
14
22
0 0
3
5
1
1
1
1
]
1
b c B
T
B
,
1
1
1
]
1
1
1
1
]
1
1
1
1
]
1
14
8
14
14
22
1 0 0
0 0
0 1 1
3
14
3
1
1
b x B
B
The left-hand side coefficients (i.e. entries below the z-row) for x
and the slack variables
are respectively:
1
1
1
]
1
1
1
1
]
1
1
1
1
]
1
0 2 3
1
0 4 2
0 2 3
3 2 1
3 6 3
1 0 0
0 0
0 1 1
3
2
3
1
3
1
1
A B and
1
1
1
]
1
1 0 0
0 0
0 1 1
3
1
1
B
3.3 The Primal and the Dual Problem
Every LP has associated with it another LP which is called as the dual.
When finding the dual of a given LP problem, we refer to the given LP as the primal
problem.
To find the dual for a primal, we assume that the primal is in the standard form, then
(i) A dual variable is defined for each of the m primal constraint equations.
(ii) A dual constraint is defined for each of the n primal variables.
(iii) The LHS coefficients of the i-th dual constraint equal the constraint
coefficients of the i-th primal variable. The right hand side of the dual
constraint equal the objective coefficient of the same primal variable.
(iv) The objective coefficients of the dual equal the right hand sides of the primal
constraint equations.
(v) Finally, the objective function type, the constraint type and the variable type
of the dual LP problem may be determined from the table below:
Primal problem Dual problem
Objective function Objective function Constraints type Variable sign
Maximization Minimization
.urs
Minimization Maximization
.urs
EEM2046 Engineering Mathematics IV Operations Research
T2, 2013/14 Page 29 of 59
Example: Find the dual of the following primal problem.
Maximize w = 5x
1
+ 4x
2
subject to x
1
+ 3x
2
10
2x
1
+ 6x
2
12
5x
1
3x
2
10
2x
1
3x
2
15
x
1
, x
2
0.
Solution: Put into the standard LP form.
Maximize w = 5x
1
+ 4x
2
subject to x
1
+ 3x
2
+ s
1
= 10
2x
1
+ 6x
2
+ s
2
= 12
5x
1
3x
2
s
3
= 10
2x
1
3x
2
s
4
= 15
x
1
, x
2
, s
1
, s
2
, s
3
, s
4
0.
The dual is
Minimize z = 10y
1
+ 12y
2
+ 10y
3
+ 15y
4
subject to y
1
+ 2y
2
+ 5y
3
+ 2y
4
5
3y
1
+ 6y
2
3y
3
3y
4
4
y
1
0
y
2
0
y
3
0
y
4
0
y
1
, y
2
, y
3
, y
4
.urs.
Simplify it, we have the dual problem as
Minimize z = 10y
1
+ 12y
2
+ 10y
3
+ 15y
4
subject to y
1
+ 2y
2
+ 5y
3
+ 2y
4
5
3y
1
+ 6y
2
3y
3
3y
4
4
y
1
, y
2
0, y
3
, y
4
0
Example: Find the dual for the following primal LP problem,
Minimize w = 2x
1
+ x
2
subject to x
1
+ x
2
= 2
2x
1
x
2
3
x
1
x
2
1
x
1
0, x
2
.urs
EEM2046 Engineering Mathematics IV Operations Research
T2, 2013/14 Page 30 of 59
Solution: Set
+
2 2 2
x x x . The standard LP form is
Minimize w =
+
+
2 2 1
2 x x x
subject to
. 0 , , , ,
1
3 2
2
3 2 2 2 1
3 2 2 1
2 2 2 1
2 2 1
+ +
+
+
+
+
+
+
s s x x x
s x x x
s x x x
x x x
The dual is
Maximize z = 2y
1
+ 3y
2
+ y
3
subject to y
1
+ 2y
2
+ y
3
2
y
1
y
2
y
3
1
y
1
+ y
2
+ y
3
1
y
2
0
y
3
0
y
1
, y
2
, y
3
.urs.
Simplify the above, the dual problem is
Maximize z = 2y
1
+ 3y
2
+ y
3
subject to y
1
+ 2y
2
+ y
3
2
y
1
y
2
y
3
= 1
y
1
.urs, y
2
0, y
3
0.
3.3.1 Relationship Between Primal and Dual Problem
Property I:
For any pair of feasible primal and dual solutions:
,
_
,
_
problem on minimizati
the in value Objective
problem on maximizati
the in value Objective
At the optimal stage:
,
_
,
_
problem on minimizati
the in value Objective
problem on maximizati
the in value Objective
EEM2046 Engineering Mathematics IV Operations Research
T2, 2013/14 Page 31 of 59
Example:
Primal
Minimize w = 5x
1
+ 2x
2
subject to x
1
x
2
3
2 x
1
+ 3x
2
5
x
1,
x
2
0
Dual
Maximize z = 3 y
1
+ 5y
2
subject to y
1
+ 2 y
2
5
y
1
+ 3 y
2
2
y
1,
y
2
0
Primal Dual
Points Feasibility w Points Feasibility z
Estimation for
optimal value
(4,1) Yes 22 (1,0) Yes 3 3 optimal value 22
(3,0) Yes 15 (3,1) Yes 14 14 optimal value 15
(3,1) No (4,1) No
(3,0) Yes 15 (5,0) Yes 15 Optimal value = 15
Note: Points are chosen arbitrarily for illustration purpose only. Feasibility can be tested
by checking if the chosen points satisfy the given constraints.
Property II:
At the optimal stage, the dual variables will have the solution
y
T
=
T
B
c B
1
.
-
T
B
c and B
1
are elements from the matrix representation of the Simplex tableau,
their meanings explained in Sect. 3.2.2 (see p. 26).
- The expression
T
B
c B
1
corresponds exactly to the z-row entries below the slack
variables in the Simplex tableau. In other words, the optimal solution of the dual
variables is simply the slack variable coefficients of the primal LP at the
optimal stage.
Example: Consider the following problem:
Primal
Maximize z = x
1
+ 4x
2
+ 5x
3
subject to :
3x
1
+ 6x
2
+ 3x
3
22
x
1
+ 2x
2
+ 3x
3
14
3x
1
+ 2x
2
14
x
1
, x
2
, x
3
0
Dual
Minimize w = 22y
1
+ 14y
2
+ 14y
3
subject to :
3y
1
+ y
2
+ 3y
3
1
6y
1
+ 2y
2
+ 2y
3
4
3y
1
+ 3y
2
5
y
1,
y
2
, y
3
0.
EEM2046 Engineering Mathematics IV Operations Research
T2, 2013/14 Page 32 of 59
The optimal tableau for the primal problem is:
Basic z x
1
x
2
x
3
s
1
s
2
s
3
Solution
z 1 1 0 0 1/6 3/2 0 74/3
x
2
0 1/2 1 0 1/4 1/4 0 2
x
3
0 0 0 1 1/6 1/2 0 10/3
s
3
0 2 0 0 1/2 1/2 1 10
By Property II, the optimal solution of the dual variables can be easily obtained:
y
T
=
T
B
c B
1
= [ ] 0 2 / 3 6 / 1 ,
thus y
1
= 1/6, y
2
= 3/2 and y
3
= 0. Furthermore, by Property I, we may conclude that the
optimal value of the dual is w = 74/3.
Remarks
Because of the dual properties, it may be easier and simpler to solve a LP problem
vial its dual problem instead of solving its primal problem directly. Generally, the
number of the main constraints affects the computation effort of the simplex method
far more than the number of variables does. A dual problem with fewer constraints
than its primal can usually be solved in less simplex iterations compared to the
primal.
Economic interpretation of dual problem
Consider the primal and dual problem as follows:
Primal
0 x
b x
x c
: subject to
Maximize
A
z
T
where
c, x R
n
, b R
m
, A R
m n
.
Dual
0 y
c y
b y
: subject to
Minimize
T T
T
A
w
where
y, c R
n
, b R
m
, A R
m n
.
Suppose the objective of the primal problem is to maximize revenue, subject to the
availability of limited resources. Thus, we can think of z as representing profit dollars
( $ ).
By Property I, at the optimal stage we have
z = w = y
T
b =
m
i
i i
y b
1
Keeping in mind that b
i
represents the availability of resource i, the above can be
expressed dimensionally as
$ = (units of resource i) ($ / unit of resource i)
Thus, y
i
represents the $ amount that each unit of resource i contributes to the
profit z, also known as the dual price or shadow price. More formally, y
i
refers to
EEM2046 Engineering Mathematics IV Operations Research
T2, 2013/14 Page 33 of 59
the $ amount by which the optimal z-value can be improved if the right hand side
of the ith constraint, b
i
, is increased by 1 unit.
Example:
Refer to the Chemical problem in p. 7 and its optimal simplex tableau in p. 21. By
Property II, the optimal solution for its dual variables y
1
and y
2
are
3
1
and
3
1
1 ,
respectively. This means that if the availability of raw material A is increased by 1 unit,
then the total profit will increase by RM(
3
1
1000). Similarly, incrementing the
availability of raw material B by 1 unit will contribute RM(
3
1
1 1000) to the total profit.
So if faced with a choice, raw material B should be given the priority for increase.
3.4 Sensitivity Analysis
Sensitivity analysis is a process to explore how changes in any parameter of a
problem would affect the optimal solution. In this section, we are going to investigate
the following cases:
(a) Changes in the coefficients of the objective function (marginal profit/cost)
(b) Changes in the right hand sides (resource availability)
(c) Addition of a new decision variable (new activity)
In general, sensitivity analysis utilizes the matrix representation of simplex tableau
presented in Sect. 3.2.2:
Basic z x
slack variables
Solution
z 1 y
T
A c
T
y
T
= c
B
T
B
1
y
T
b
x
B
0 B
1
A
B
1
B
1
b
For each change, we just need to re-compute the affected parts in the tableau.
Then we check if the new values satisfy the optimality condition (coefficients in the
z-row are all non-negative) and the feasibility condition (solution of basic variables
are all non-negative).
Throughout the whole section 3.4, the following problem (first appeared in p. 21)
would be used to demonstrate the idea of the sensitivity analysis. The original
mathematics model and the respective optimal table are restated here for reference.
Example: The Product Problem.
Let x
1
, x
2
and x
3
be the units of Product 1, 2 and 3 produced daily in tons, and let z
be the total daily income obtained by selling all these products. The LP is given as:
Maximize z = x
1
+ 4x
2
+ 5x
3
subject to : 3x
1
+ 6x
2
+ 3x
3
22 (raw material A)
x
1
+ 2x
2
+ 3x
3
14 (raw material B)
3x
1
+ 2x
2
14 (raw material C)
x
1
, x
2
, x
3
0
EEM2046 Engineering Mathematics IV Operations Research
T2, 2013/14 Page 34 of 59
By simplex method, the optimal tableau is:
Basic z x
1
x
2
x
3
s
1
s
2
s
3
Solution
z 1 1 0 0 1/6 3/2 0 74/3
x
2
0 1/2 1 0 1/4 1/4 0 2
x
3
0 0 0 1 1/6 1/2 0 10/3
s
3
0 2 0 0 1/2 1/2 1 10
(a) Changes in the Coefficients of the Objective Function
The changes just affect the entries in the z-row of the simplex tableau. Thus, may
alter the optimality of the problem.
If the objective coefficient of the basic variable x
j
is changed, then the vectors
T
c and
T
B
c would change. Let
T *
c be the new coefficients for the objective function, and
T
B
*
c
be the new objective coefficients for the optimal x
B
.
Step 1: Compute the new coefficients in the z-row:
y
*T
=
T
B
*
c B
-1
,
T T
A
* *
c y .
Basic z x
slack variables
Solution
z 1
T T
A
* *
c y
y
*T
=
T
B
*
c B
1
y
*T
b
x
B
0 B
1
A
B
1
B
1
b
Note, however, that if the variable x
j
is not a basic variable, then the vector
T
B
c and y
T
remain, we just need to calculate the values of
T T
A
*
c y .
Step 2: Two cases will result:
(i) The optimality condition is satisfied, the current optimal solution
remains with the new optimal value y
*T
b.
(ii) The optimality condition is not satisfied, simplex method must be
applied to recover optimality.
Example:
Identify the new optimal solution for the Product Problem if:
(a) the prices per ton for product 2 and product 3 are changed to 5 and 6 respectively.
(b) the price per ton for product 1 is changed to 2.5.
EEM2046 Engineering Mathematics IV Operations Research
T2, 2013/14 Page 35 of 59
Solution:
(a) From the original optimal tableau, [ ]
T
B
s x x
3 3 2
x . Thus [ ] 0 6 5
*
T
B
c , and we
have
[ ] [ ] 0 1
1
0
0
0 6 5
4
3
4
1
2
1
2
1
2
1
6
1
4
1
4
1
1 * *
1
1
1
]
1
B
T
B
T
c y .
As for the remaining z-row entries represented by y*
T
A c*
T
, we have
[ ] [ ] [ ]. 0 0 2 / 3 6 5 1
0 2 3
3 2 1
3 6 3
0 1
4
3
4
1
* *
1
1
1
]
1
T T
A c y
Since all the new z-row coefficients are nonnegative, the optimality condition is still
satisfied. The current optimal solution remains unchanged, but the new optimal
value is given by
[ ] . 30
14
14
22
0 1
4
3
4
1
*
1
1
1
]
1
b y
T
The new optimal simplex tableau is
Basic z x
1
x
2
x
3
s
1
s
2
s
3
Solution
z 1 3/2 0 0 1/4 7/4 0 30
x
2
0 1/2 1 0 1/4 1/4 0 2
x
3
0 0 0 1 1/6 1/2 0 10/3
s
3
0 2 0 0 1/2 1/2 1 10
Note the changes compared to the original optimal tableau.
(b) Here, the price per ton is changed for a non-basic variable x
1
. Thus y
T
= c
B
T
B
1
is
unaffected, leaving only y
T
A c*
T
to be re-calculated.
The z-row coefficients for x
2
and x
3
will remain as 0, so we may focus solely on the
coefficient of x
1
,
[ ] . 2 1 2
3
1
3
0
2
1
2
3
6
1
*
1 1
1
1
1
]
1
c A
T
y
Since 0 2 1
*
1 1
< c A
T
y , the optimality condition is not satisfied. We have to
perform another iteration of the simplex algorithm. The simplex tableau is:
EEM2046 Engineering Mathematics IV Operations Research
T2, 2013/14 Page 36 of 59
Basic z x
1
x
2
x
3
s
1
s
2
s
3
Solution
z 1 1/2 0 0 1/6 3/2 0 74/3
x
2
0 1/2 1 0 1/4 1/4 0 2
x
3
0 0 0 1 1/6 1/2 0 10/3
s
3
0 2 0 0 1/2 1/2 1 10
Apply simplex method to recover the optimality, we have
Basic z x
1
x
2
x
3
s
1
s
2
s
3
Solution
z 1 0 1 0 5/12 1 1/4 0 26 2/3
x
1
0 1 2 0 1/2 1/2 0 4
x
3
0 0 0 1 1/6 1/2 0 3 1/3
s
3
0 0 4 0 1 1/2 1 1/2 1 2
The new optimal solutions are x
1
= 4, x
2
= 0 and x
3
= 3 1/3 with the new optimal
value is z = 26 2/3.
(b) Changes in the Right Hand Side of the Constraints
Changes in the right hand sides would affect the feasibility of the LP problem.
Given that the new RHS as b
*
.
Step 1: Compute the new solution of the basic variables: B
-1
b
*
Basic z x
slack variables
Solution
z 1
T T
A c y
y
T
=
T
B
c B
1
y
T
b
*
x
B
0 B
1
A
B
1
B
1
b
*
Step 2: Two cases will result:
(i) If B
-1
b
*
0, the resulting solution remains feasible with the new
optimal value y
T
b
*
.
(ii) If one of the values in B
-1
b
*
0, the resulting solution is infeasible.
To obtain the optimal solutions, dual simplex method must be applied.
Example:
Find the new optimal solution and optimal value of the Product Problem if:
(a) the daily availability of raw material A has been changed to 18.
(b) both the daily availability of raw material B and C have been changed to 24.
EEM2046 Engineering Mathematics IV Operations Research
T2, 2013/14 Page 37 of 59
Solution:
(a) Set
1
1
1
]
1
14
14
18
*
b .
The new solution of the basic variables are:
1
1
1
]
1
1
1
1
]
1
1
1
1
]
1
12
4
1
14
14
18
1
0
0
2
1
2
1
2
1
6
1
4
1
4
1
* 1
b B
Since B
-1
b
*
0, the solution is optimal and feasible. The new optimal value is
[ ] 24
14
14
18
0
2
3
6
1
*
1
1
1
]
1
b y
T
.
The new optimal tableau is:
Basic z x
1
x
2
x
3
s
1
s
2
s
3
Solution
z 1 1 0 0 1/6 3/2 0 24
x
2
0 1 0 1/4 1/4 0 1
x
3
0 0 0 1 1/6 1/2 0 4
s
3
0 2 0 0 1/2 1/2 1 12
The new optimal solution is x
1
= 0, x
2
= 1 and x
3
= 4 with the optimal value is
z = 24. Note the changes compared to the original optimal tableau.
(b) Set
1
1
1
]
1
24
24
22
*
b .
The affected entries are:
1
1
1
]
1
1
1
1
]
1
1
1
1
]
1
25
8
24
24
22
1
0
0
3
1
2
1
2
1
2
1
2
1
6
1
4
1
4
1
* 1
b B
Since one of the entries in 0 x <
*
B
, the resulting solution becomes infeasible. Dual
simplex method has to be applied to recover the feasibility.
EEM2046 Engineering Mathematics IV Operations Research
T2, 2013/14 Page 38 of 59
(c) Addition of A New Decision Variable
Addition of a new decision variable is similar to adding a new activity. The addition
of this new variable would only affect the optimality of a problem. The new decision
variable would become one of the basic solutions if and only if the new variable is
able to improve the objective function value. If not, this new variable would act as
the nonbasic variable.
Step 1: Add the new decision variable, x
i
, to the LP model. x
i
is assumed to be
nonbasic first.
Step 2: Calculate the z-row coefficient for x
i
: y
T
A
j
c
j
.
Step 3: Two cases will result:
(i) If the optimality condition is satisfied, the optimal solution remains.
(ii) If the optimality condition is not satisfied, the objective value can be
improved by taking x
i
as basic variable.
The entries of x
i
in the tableau is:
z-row coefficient: y
T
A
j
c
j
coefficients below z-row: B
1
A
j
Basic z x
x
i
slack variables
Solution
z 1
T T
A c y
y
T
A
j
c
j
y
T
=
T
B
c B
1
y
T
b
x
B
0 B
1
A
B
1
A
j
B
1
B
1
b
Then, perform simplex iteration until the optimal stage is reached.
Example: Suppose that a new product, Product 4, has been introduced into the Product
problem. The new LP model is as follows:
Maximize z = x
1
+ 4x
2
+ 5x
3
+ 4x
4
subject to: 3x
1
+ 6x
2
+ 3x
3
+ 3x
4
22 (raw material A)
x
1
+ 2x
2
+ 3x
3
+ x
4
14 (raw material B)
3x
1
+ 2x
2
+ x
4
14 (raw material C)
x
1
, x
2
, x
3
, x
4
0
What will the new optimal value be?
Solution: First, we assume x
4
= 0 (nonbasic variable). Its corresponding z-row coefficient
is
[ ] . 2 4
1
1
3
0
2
3
6
1
4 4
1
1
1
]
1
c A
T
y
EEM2046 Engineering Mathematics IV Operations Research
T2, 2013/14 Page 39 of 59
Since 0 2
4 4
< c A
T
y , the optimality condition is not satisfied. x
4
must enter as a
basic variable in the next simplex iteration. But first, we complete the column for x
4
in
the simplex tableau by computing
,
_
,
_
1
1
1
]
1
0
0
1
1
3
1
0
0
2
1
2
1
2
1
2
1
6
1
4
1
4
1
4
1
A B ,
and the simplex tableau with x
4
inserted is as follows.
Basic z x
1
x
2
x
3
x
4
s
1
s
2
s
3
Solution
z 1 1 0 0 2 1/6 3/2 0 74/3
x
2
0 1/2 1 0 1/2 1/4 1/4 0 2
x
3
0 0 0 1 0 1/6 1/2 0 10/3
s
3
0 2 0 0 0 1/2 1/2 1 10
By performing another simplex iteration, the tableau becomes
Basic z x
1
x
2
x
3
x
4
s
1
s
2
s
3
Solution
z 1 1 1/2 4 0 0 1 1/6 1/2 0 32 2/3
x
4
0 1 2 0 1 1/2 1/2 0 4
x
3
0 0 0 1 0 1/6 1/2 0 3 1/3
s
3
0 2 0 0 0 1/2 1/2 1 10
The new optimum value is 32 2/3 with the optimal solution is x
1
= 0, x
2
= 0, x
3
= 3 1/3
and x
4
= 4.
EEM2046 Engineering Mathematics IV Operations Research
T2, 2013/14 Page 40 of 59
4.0 Dynamic Programming
Dynamic programming (DP) is a recursive approach to solve an n-variable
optimization problem by breaking up the problem into n-stage and at each stage
computing a single variable.
DP problems may be solved using forward recursion in which the computations
proceed from the first stage to the last stage or using backward recursion in
which the computations start from the last stage and end at the first stage. Both
forward and backward recursions yield the same solution. However, most DP
literature employs backward recursion as it is generally more efficient
computationally.
The basic steps in solving DP problems using backward recursion are:
Step 1: Decomposition (break the problem into stages based on the no. of decisions to
be made)
Step 2: Define the state variables, recursive formula and decision variables
Step 3: Carry out the computation stage by stage, beginning from the last stage
Step 4: Composition (trace the decisions from the first stage to the last to form the
optimal policy)
Definition:
(a) The state variable, u, describes the possible "system conditions" at a particular stage-
j. The state variable is the information that links the stages together so that the
optimal decisions for the upcoming stages can be made without having to re-examine
the decision made at stage j.
(b) The recursive formula, ( ) u f
j
, is the objective function used to rate all the
alternatives when the system is in state u at stage j. ( ) u f
j
gives the optimal
cost/benefit beginning stage j till the last stage.
(c) The decision variable is the decision made at stage j to achieve ( ) u f
j
.
(d) The optimal policy is the sequence of decisions made at each stage.
4.1 Solution of Routing Problem by Stages (Backward recursion)
Example: The following network provides the possible routes and the distances from
City 1 to City 10. Determine the shortest route from City 1 to City 10.
City 1
City 2
City 3
City 5
City 6
City 7
City 8
City 10
5
6
6
2
3
4
10
12
6
6
4
4
City 4
7
9
4
City 9
12
8
3
EEM2046 Engineering Mathematics IV Operations Research
T2, 2013/14 Page 41 of 59
Solution:
Step 1: Decomposition (break the problem into stages)
- The problem can be divided to 4 stages. At each stage, the individual needs to decide
which city to visit next.
Step 2: Define the state variables, recursive formula and decision variables
Let
the state variable, u be our possible location at the start of a particular stage,
the recursive formula, f
j
(u) be the minimum distance to complete the tour beginning city
u till city 10, and
the decision variable, d
j
(u) be the next city visited in order to achieve f
j
(u).
Step 3: Carry out the computation
Stage 4 Computation
Assume that Stages 1, 2 and 3 have been completed. At the start of Stage 4, we must be
either in city 7, 8 or 9. Thus, u = 7, 8 or 9. Since this is final stage of the tour, the
obvious decision is to simply go from the current position to city 10.
f
4
(7) = 4 d
4
(7) = 10 (from city 7 to city 10)
f
4
(8) = 3 d
4
(8) = 10 (from city 8 to city 10)
f
4
(9) = 4 d
4
(9) = 10 (from city 9 to city 10)
Stage 3 Computation
In this stage of the tour, we start out in either city 5 or 6, i.e. u = 5 or 6. From u, we must
decide whether to proceed to city 7, 8 or 9. The immediate distance from u to city 7, 8
and 9 is given in the network, but since our goal is to reach city 10, we have to factor in
the distance calculated in Stage 4.
Set m
ut
= the distance between cities u and t, the recursive formula is
( ) ( ) { } . 6 , 5 , min
4
9 , 8 , 7
3
+
u t f m u f
ut
t
f
3
(5) = min{m
57
+ f
4
(7), m
58
+ f
4
(8), m
59
+ f
4
(9)}
= min{12+4, 12+3, 10+4} = min{16, 15, 14} = 14
d
3
(5) = 9 (from city 5 to city 9)
f
3
(6) = min{m
67
+ f
4
(7), m
68
+ f
4
(8), m
69
+ f
4
(9)}
= min{8+4, 6+3, 6+4} = min{12, 9, 10} = 9
d
3
(6) = 8 (from city 6 to city 8)
city 1 1
st
city
2
nd
city 3
rd
city
city 10
Stage 1
Stage 2
Stage 3
Stage 4
EEM2046 Engineering Mathematics IV Operations Research
T2, 2013/14 Page 42 of 59
Stage 2 Computation
We start from u=2, 3 or 4, and at each u must decide whether to proceed to city 5 or 6.
The recursive formula is:
( ) ( ) { } . 4 , 3 , 2 , min
3
6 , 5
2
+
u t f m u f
ut
t
f
2
(2) = min{ m
25
+ f
3
(5), m
26
+ f
3
(6)} = min {6 +14, 4 + 9}
= min{20, 13} = 13
d
2
(2) = 6 (from city 2 to city 6)
f
2
(3) = min{ m
35
+ f
3
(5), m
36
+ f
3
(6)} = min {2 + 14, 3 + 9}
= min{16, 12} = 12
d
2
(3) = 6 (from city 3 to city 6)
f
2
(4) = min{ m
45
+ f
3
(5), m
46
+ f
3
(6)} = min {4 + 14, 9 + 9}
= min{18, 18} = 18
d
2
(4) = 5, 6 (from city 3 to city 5 or city 6)
Stage 1 Computation
u = 1. The recursive formula is:
f
1
(1) = min{ m
12
+ f
2
(2), m
13
+ f
2
(3), m
14
+ f
2
(4) } = { 5 + 13, 7 + 12, 6 + 18}
= {18, 19, 24} = 18
d
1
(1) = 2 (from city 1 to city 2)
The above computation result can be represented in tableau form:
u
1 2 3 4 5 6 7 8 9
Stage 4 f
4
(u) 4 3 4
d
4
(u) 10 10 10
Stage 3 f
3
(u) 14 9
d
3
(u) 9 8
Stage 2 f
2
(u) 13 12 18
d
2
(u) 6 6 5,6
Stage 1 f
1
(u) 18
d
1
(u) 2
Step 4 : Composition: determine the optimal policy
The minimum distance from city 1 to city 10 is f
1
(1) = 18.
The optimal policy is
d
1
(1) = 2 : the individual chooses to go to city 2 from city 1.
d
2
(2) = 6 : he next visits city 6.
( ) ( ) { }. t f m min f
t
, , t
2 1
4 3 2
1
1 +
1
2
i
j
e
ij
P: 1 i
P: 1 j
EEM2046 Engineering Mathematics IV Operations Research
T2, 2013/14 Page 57 of 59
Dijkstras Algorithm
Input : number of vertices n, edges e
ij
and edge lengths l
ij
1. Initialization:
Set
F = {v1} NF = {v2, v3,, vn}
L = {0} L = { }
n
n l L l L l L
1 13
3
12
2 ,..., ,
Note: If edge
j
e
1
does not exist, then let
j
l
1
be .
2. Finalize the minimum distance to a vertex:
Choose a vertex in NF (say vk) corresponding to the shortest length in L (say k L ).
Transfer vk to set F and k L to set L.
Note: After the transfer, k L is now denoted as
k
L .
3. Update L
:
Update the elements in L for the new NF according to
( )
} , min{
old
kj k j j
l L L L +
Repeat Step 2 and Step 3 until NF is empty.
Output : F and L, where L contains the lengths of shortest paths from vertex 1 to the
corresponding vertices in F.
Example: Find the shortest path from vertex 1 to vertices 2,3,4 by using the Dijkstras
algorithm.
Step 1. Initialization
F = {v1} NF = {v2,v3,v4,v5}
L = {0} L = {2, 6, 8, }
Step 2.L
2
= 2 is minimum. Transfer v2 to F and L
2
= 2 to L.
Step 3. Update L
L
3
= min{6,
2
L + l
23
} = min {6, 2 + 5 } = 6
L
4
= min{8,
2
L + l
24
} = min {8, 2 + 3 } = 5
L
5
= min{,
2
L + l
25
} = min {, 2 + } =
F = {v1,v2} NF = {v3,v4,v5}
L = {0, 2} L = {6, 5, }
Step 2.L
4
= 5 is minimum. Transfer v4 to F and L
4
= 5 to L.
5
4
3
2
5
5
20
8
2
1
6
3
EEM2046 Engineering Mathematics IV Operations Research
T2, 2013/14 Page 58 of 59
Step 3. Update L
L
3
= min{6,
4
L + l
43
}= min {6, 5+5} = 6
L
5
= min{,
4
L + l
45
} =min {, 5 + 20 }= 25
F = {v1,v2,v4} NF = {v3,v5}
L = {0, 2, 5} L = {6, 25}
Step 2.L
3
= 6 is minimum. Transfer v3 to F and L
3
= 6 to L.
Step 3. Update L
L
5
= min{25,
3
L + l
35
}= min {25, 6+} = 25
F = {v1,v2,v4,v3} NF = {v5}
L = {0, 2, 5, 6} L = {25}
Step 2. Only one more vertex left in NF. Transfer v5 to PL and L
5
= 25 to L.
Iterations terminate since NF is empty.
Output : PL = {v1,v2,v4,v3,v5}
L = {0, 2, 5, 6, 25}
The shortest path from vertex 1 to vertex 2 is 2 units in length.
The shortest path from vertex 1 to vertex 4 is 5 units in length.
The shortest path from vertex 1 to vertex 3 is 6 units in length.
The shortest path from vertex 1 to vertex 5 is 25 units in length.
Exercise:
Find the shortest paths from vertex 1 to all others vertices.
[ L
2
= 7, L
3
= 3, L
4
=5, L
5
=5, L
6
=7]
3
5
4
3
2
8
4
4
1
6
3
2
1
5
2
2
EEM2046 Engineering Mathematics IV Operations Research
T2, 2013/14 Page 59 of 59
Operations Research
Linear Programming
Solved by: (1) Graphical Method
(2) Simplex method
Duality and Sensitivity Analysis
Dynamic Programming
Solved by : Dynamic Programming with Backward
Recursion
Combinatorial Problems
Dijkstras Algorithm for Shortest Paths
Kruskals Algorithm for minimal spanning tree
Prims Algorithm for minimal spanning tree