Professional Documents
Culture Documents
Operations Research Lectures PDF
Operations Research Lectures PDF
Operations Research Lectures PDF
Lecture 1
Linear Programming:
Transportation Problem
Introduction
Transportation problem is a special kind of Linear Programming Problem (LPP)
in which goods are transported from a set of sources to a set of destinations subject
to the supply and demand of the sources and destination respectively such that the
total cost of transportation is minimized. It is also sometimes called as Hitchcock
problem.
In this type of problem, either a dummy row or a dummy column is added
according to the requirement to make it a balanced problem. Then it can be
solved similar to the balanced problem.
Methods to Solve
To find the initial basic feasible solution there are three methods:
1. North-West Corner Method
2. Least Cost Method
3. Vogel’s Approximation Method (VAM)
(2)
Basic Structure
→ D1 to D4 are the destinations where the products/goods are to be delivered from
different sources S1 to S4.
→ Si is the supply from the source Oi
→ dj is the demand of the destination Dj
→ Cij is the cost when the product is delivered from source Si to destination Dj.
Important Notes:
→ Objective Function is to minimize the cost and find the optimum cost.
Solution
- First check if the demand equal to the supply:
Q. Demanded = 5 + 15 +15 +15 = 50
Q. Supplied = 15 + 25 + 10 = 50
Demand = Supply → Balanced
- Start to fulfill the demand of the store 1 from the sources.
Store1 or A will take all its demand from S1 so we will cross the column of this store
because its demand has fulfilled.
(3)
S\D A B C D Q. Supplied
S1 5 10 10 2 20 11 15 → 10 → 0
S2 12 5 7 15 9 5 20 25 → 20 → 5 → 0
S3 4 14 16 10 18 10 → 0
Q. Demanded 5→0 15 → 5 → 0 15 → 0 15 → 5 → 0 50
Note:
✔ All the demand and supply must finish up to be 0 (because of equilibrium)
✔ In the last remaining cell the demand for the respective columns and rows are
equal
Total cost = 5×10+10×2+5×7+15×9+5×20+10×18 = $520
S\D A B C D Q. Supplied
S1 10 15 2 20 11 15 → 0
S2 12 0 7 15 9 10 20 25 → 10 → 0
S3 5 4 14 16 5 18 10 → 5→ 0
Q. Demanded 5→0 15 → 0 15 → 0 15 →10→ 0 50
Note:
→ If the cell demand = supply then we must cross only its row or column not both.
(like highlighted cell)
Total cost = 15×2+15×9+10×20+5×4 +5×18 = $475
Number of Filled cells = M + N – 1
Total Cells = M * N
Number of Constraints = M + N
Where
M → Number of Rows
N → Number of Columns
(4)
Constraints:
1. Amount that can be supplied form S1 to A, B, C, and D <= 15
2. Amount that can be supplied form S2 to A, B, C, and D <= 25
3. Amount that can be supplied form S3 to A, B, C, and D <= 10
4. Amount A demanded from S1, S2, S3, and S4 <= 5
5. Amount B demanded from S1, S2, S3, and S4 <= 15
6. Amount C demanded from S1, S2, S3, and S4 <= 15
7. Amount D demanded from S1, S2, S3, and S4 <= 15
P2 -- 5 7 7
P3 -- 7 7 2
P4 -- -- 7 2
(5)
Exercise:
S\D A B C D Q. Supplied
E 6 8 8 5 30
F 5 11 9 7 40
G 8 9 7 13 50
Q. Demanded 35 28 32 25 120
(6)
Solution:
In this type of problem, the concept of a dummy row or a dummy column will be
used.
As in this case, since the supply is more than the demand so a dummy demand
column will be added and a demand of (total supply – total demand) will be given
to that column i.e. 117 – 95 = 22 as shown in the image below. If demand were
more than the supply then a dummy supply row would have been added.
Note:
The cost in the new dummy column or row is zero.
Now you can solve the problem as a balanced problem using the three method and
calculate the total cost then choose the method that give the least cost.
Finished :)
(7)
Operations Research
Lecture 2
Linear Programming Model
LP Model
Operations Research (OR): is a scientific approach to the solution of problems
in the management of complex systems that enables decision makers to make
better decisions.
هي عبارة عن الطريقة أو االسلوب العلمي المستخدم لحل المشاكل في االدارات واألنظمة الكبيرة
To Create LP Model
First: We determine the decision variables as follows:
X1 → Daily production rate of A,
X2 → Daily production rate of B,
X3 → Daily production rate of C
Second: We determine the Objective Function.
Because we concerned with profit so the objective function is Max.
Max. Z = 4X1 + 2X2 + 3X3
(2)
Third: We determine the constraints that governs the objective function as follows:
Subject To (ST):
7X1 + 3X2 + 6X3 ≤ 150
4X1 + 4X2 + 5X3 ≤ 200
X1 , X2 , X3 ≥ 0
(Non-negative Constraint)
Note:
- We use ≥ in constraints with: (Min, more than, at least, not less than)
- We use ≤ in constraints with: (Max, budget, less than, capacity, at most,
restricted)
(3)
Z → production of C
(4)
Objective Function:
Max. C = 3X + 2Y + 5Z
Subject To (ST):
X + 2Y + Z ≤ 430
3X + Z ≤ 460
X + 4Y ≤ 420
X, Y, Z ≥ 0
(Non-negative Constraint)
→ Don’t forget non-negative constraint.
→ Variable names is optional
→ When you found the word “Profit” so the objective functions is Max, and
when you found the word “Cost” so the objective function is Min.
(5)
Operations Research
Lecture 3
Linear Programming Model:
Graphical Representation
LP Model: Graphical Representation
Previously, we learn how to create a linear programming model and make
the General model. We will solve this model graphically to find the optimal
solution.
Definitions you should know first:
• Solution: Is the set of values of decision variables that satisfy the
constraints of an LP problem.
• Feasible Solution: Is the set of values of decision variables that satisfy all
the constraints and non-negativity conditions of an LP problem
simultaneously.
• Infeasible Solution: Is the set of values of decision variables that do not
satisfy all the constraints and non-negativity conditions of an LP problem
simultaneously.
• Basic Solution: Is any intersect between two lines in a graphical
representation of the constraints.
• Basic Feasible Solution: Is the solution that combine the characteristics of
both Basic and Feasible Solution.
• Optimal Solution: A basic feasible solution that optimizes (maximizes or
minimizes) the objective function value of the given LP problem.
• Unbounded Solution: A solution that can increase or decrease infinitely the
value of the objective function of the LP problem.
Notes:
• A feasible region is a region that combined among all the constraints.
Steps to Solve:
1. Convert constraints from inequality (≤ or ≥) to equality (=),
2. Substitute for variable to 0 and find the another one’s value.
3. Draw the line in the first positive quarter (non-negative constraints)
(2)
4. If constraint has ≤ then the feasible region will be below the line, and if
constraint has ≥ then the feasible region will be above the line.
5. Find the common area among all feasible regions.
6. Find basic points in the shape and substitute by it in the objective function to
find the optimal solution
Example 1:
3X1 + 2X2 = 12
Solution
X1 0 4
X2 6 0
Example 2
X1 + X2 ≤ 8
Solution
Transform to X1 + X2 = 8
X1 0 8
X2 8 0
feasible region is bounded and plotted on the line and
all area below the line.
(3)
Example 3:
4X1 + X2 ≥ 10
Solution
Transform to 4X1 + X2 = 10
X1 0 2.5
X2 10 0
Feasible Region
Example 4:
2X1 – 3X2 ≤ 12
Transform to 2X1 – 3X2 = 12
X1 0 6 Feasible Region
X2 -4 0
Example 5:
Max Z = 10X1 + 6X2
ST
5X1 + 3X2 ≤ 30
X1 + 2X2 ≤ 18
X1, X2 ≥ 0
(4)
1. 5X1 + 3X2 = 30
X1 0 6
X2 10 0 B
A
2. X1 + 2X2 = 18
X1 0 18
X2 9 0
5X1 + 3X2 = 30
(-) 5X1 + 10X2 = 90
-------------------------
-7X2 = -60
60 60
X2 = 7
, so we will substitute by X2 = 7
in the first equation.
60 30
X1 = 30 – 3 * 7
= 7
(5)
30 60
At point B (X1 = 7
, X2 = 7
):
30 60
Z = 10 * 7
+6* 7
= 60 (Optimal Solution)
Note: it must be a common region among all constraints and if not there will be an
infeasible solution.
(6)
2) Max Z = 40X1 + 100X2
ST
12X1 + 6X2 ≤ 3,000
4X1 + 10X2 ≤ 2,000
2X1 + 3X2 ≤ 900
X1 , X2 ≥ 0
Find Optimal Solution Graphically?
Finished :)
(7)
Operations Research
Lecture 4
Linear Programming:
Simplex Method
LP: Simplex Method
A linear programming model consists of:
• Objective Function
• Constraints
• Non-negative Constraint
We discussed earlier the graphical solution of a LP model and we are continuing
to know how to solve LP model using Mathematical Methods.
There are two mathematical methods:
• Simplex Method: used when all constraints are ( ≤ )
• Big-M Method (M Technique): used when one or more constraint is (=, ≥).
Steps to Solve:
1. Transform LP model to Standard form
2. All constants in constraints must be positive (+)
3. Check which method will you use (Simplex or Big-M) by checking the sign
in all constraints.
4. Add a slack variable(S) to the constraint which has a ≤ sign and convert the
sign to =
5. Determine the basic variables and non-basic variables:
Basic variable has a value while non-basic variable its value is 0.
6. Always X1 and X2 are non-basic variables
7. calculate the value of slack variables (S).
8. Draw the initial solution table.
(2)
Example P. 47:
Max Z = 3X1 + 2X2
ST
X1 + X2 ≤ 4
X1 – X2 ≤ 2
X1 , X2 ≥ 0
Find optimal solution using mathematical method?
Solution
All constants have ≤, so we will solve using simplex.
First we will convert General LP to Standard LP:
1. X1 + X2 + S1 = 4
2. X1 – X2 + S2 = 2
3. Max Z = 3X1 + 2X2 + 0S1 + 0S2
We have 4 variables in only two equations so we will determine which variables
are basic and which are non-basic.
→ X1, X2 are Non-Basic variables so there value will be 0,
→ S1, S2 are Basic variables.
S2 0 2 1 -1 0 1
Z = CB * XB = 0 0 0 0 0
Optimal Test 3 2 0 0
The row before last row calculated by (CB * Xi).
Optimal test row = Co-eff of Z - The row before last row
(3)
To find if this solution is optimal solution or not:
• If the objective function is Max:
Optimal test row values must be negative or 0
• If the objective function is Min:
Optimal test row values must be positive or 0
→ If the solution is not the optimal solution so the solution should be improved
until it’s become optimal solution.
Co-eff of Z Ćj 3 2 0 0
Basic Var. CB XB X1 X2 S1 S2 Ratio
S1 0 4 1 1 1 0 4
S2 0 2 1 -1 0 1 2
Z = CB * XB = 0 0 0 0 0
Optimal Test 3 2 0 0
(4)
current pivot row
New pivot row = pivot element
→ If we look at the previous table we will find that it’s not an optimal solution
because the optimal test row contain positive values so we will improve the
solution.
Co-eff of Z Ćj 3 2 0 0
Basic Var. CB XB X1 X2 S1 S2 Ratio
S1 0 2 0 2 1 0 1
X2 3 2 1 -1 0 1 -2
Z = CB * XB = 3*2 = 6 3 -3 0 3
Optimal Test 0 5 0 -3
Co-eff of Z Ćj 3 2 0 0
Basic Var. CB XB X1 X2 S1 S2
X2 2 1 0 2 1/2 -1/2
X1 3 3 1 0 1/2 1/2
Z = CB * XB = 2*1 + 3*3 = 11 3 2 5/2 1/2
Optimal Test 0 0 -5/2 -1/2
This solution is optimal solution because optimal test row doesn’t contain positive.
(5)
Operations Research
Lecture 5
Linear Programming:
Big-M Method
LP: Big-M Method
Steps to Solve:
1. Transform General LP model to Standard form
2. All constants in constraints must be positive (+)
3. If at least one constraint has = or ≥ sign then we will use Big-M method
4. Add a slack variable(S) to the constraint which has a ≤ sign or deduct a
surplus variable(S) to the constraint which has a ≥ and convert the sign to =
5. If the constraint has a = or ≥ sign we will add artificial variable (a)
6. In the objective function we will add (M) variable and its sign will be
determined based on the type of the objective function:
- Max (Profit) → -M
- Min (Cost) → +M
M → is a very big number (called penalty)
7. Determine the basic variables and non-basic variables:
Basic variable has a value while non-basic variable its value is 0.
8. Always X1 ,X2 , -S are non-basic variables
9. calculate the value of Basic variables.
10. Draw the initial solution table.
Example P. 61:
Max Z = 3X1 + 2X2
ST
2X1 + X2 ≤ 2
3X1 + 4X2 ≥ 12
X1 , X2 ≥ 0
Find optimal solution using mathematical method?
(2)
Solution
the is one constraint has ≥ sign, so we will solve using Big-M method.
First we will convert General LP to Standard LP:
1. 2X1 + X2 + S1 = 2
2. 3X1 + 4X2 - S2 + a1= 12
3. Max Z = 3X1 + 2X2 + 0S1 + 0S2 – Ma1
We have 5 variables in only two equations so we will determine which variables
are basic and which are non-basic.
→ X1, X2 , and S2 are Non-Basic variables so there value will be 0,
→ S1, a1 are Basic variables.
a1 -M 12 3 4 0 -1 1
Z = CB * XB = -12M -3M -4M 0 M -M
Optimal Test 3 + 3M 2 + 4M 0 -M 0
The row before last row calculated by (CB * Xi).
Optimal test row = Co-eff of Z – The row before last row
To find if this solution is optimal solution or not:
• If the objective function is Max:
Optimal test row values must be negative or 0
• If the objective function is Min:
Optimal test row values must be positive or 0
→ If the solution is not the optimal solution so the solution should be improved
until it’s become optimal solution.
(3)
Improve the solution:
First decide the enter variable and then the outer variable:
→ the enter variable (Pivot Column) in max will be highest positive number in
optimal test row,
→ the outer variable can be found by ratio and we choose lowest positive value,
Ratio is calculated by divide XB by Pivot Column (Green column).
Co-eff of Z Ćj 3 2 0 0 -M
Basic Var. CB XB X1 X2 S1 S2 a1 Ratio
S1 0 2 2 1 1 0 0 2
a1 -M 12 3 4 0 -1 1 3
Z = CB * XB = 0 -3M -4M 0 M -M
Optimal Test 3+3M 2+4M 0 -M 0
Here the incoming variable is X2 because 4M is greater than 3M, and the outgoing
variable is S1
Co-eff of Z Ćj 3 2 0 0 -M
Basic Var. CB XB X1 X2 S1 S2 a1
X2 2 2 2 1 1 0 0
a1 -M 4 -5 0 -4 -1 1
Z = CB * XB = 4 – 4M 4+5M 2 2+4M M -M
Optimal Test -1-5M 0 -2 – 4M -M 0
current pivot row
New pivot row =
pivot element
→ If we look at the previous table we will find that it’s an optimal solution because
the optimal test row does not contain positive values.
Exercise:
Min Z = 4X1 + X2
S.T
3X1 + X2 = 3
4X1 + 3X2 ≥ 6
X1 + 2X2 ≤ 4
X1,X2 ≥ 0
(5)
Operations Research
Lecture 6
Games Theory
Games Theory
Any match is a competitive situation between persons called players.
Players are divided into:
Row Player العب الصف
Column Player العب العمود
Each player has strategies in a match and may win or lose the match.
- Any positive number represents a gain for Row Player and a loss for Column Player.
- Any Negative number represents a gain for Column Player and a loss for Row Player.
Example: Player B
2 5 1
Player A [ ]
3 −1 0
Let us explain this:
- This matrix is 2*3 level, which means that it has 2 rows and 3 column.
- Rows represent the strategies of the row player (2 rows = 2 strategies) and as on for
column (3 column = 3 strategies) for column player.
- + gain for row player, loss for column player
- - gain for column player, loss for row player.
If player A choose the first strategy (first row) and player B choose second strategy (second
column) the end game will be a gain for player A by 5 points.
If player B choose the second strategy (second column) and player A choose second strategy
(second row) the end game will be a gain for player B by 1 point.
Each player seek to maximize his points so we have to find the final score or end game.
Methods to solve:
1- The game has a saddle point ( نقطة تعادلPure or fair Strategy)
2- The game has no saddle point ( ال يوجد نقطة تعادلmixed strategy)
a. Matrix level 2 * 2 Probabilities, Matrices Method
b. Matrix Level 2 * 3 or 3 *2 subgames method مبارايات فرعية
c. Matrix Level 2 * M or M * 2 Dominance مبدأ السيادة أو السيطرة
M>3
Example 1: B
5 9 2 8
A [18 7 5 6]
10 −4 3 7 3×4
Solution
First, check saddle point:
MinMax = MaxMin
Min Max
5 9 2 8 2 -
[18 7 5 6] 5 5
10 −4 3 7 3×4 -4 -
Max 18 9 5 8
Min - - 5 -
There is a saddle point in the match, which is 5 and this is a Pure Strategy
When the player A choose second strategy and player B choose third strategy then the end
game will be a 5 points gain for player A.
Example 2:
B
−3 9
A [ ]
6 5
Solution
First, check saddle point
Min Max
−3 9 -3 -
[ ]
6 5 5 5
Max 6 9
Min 6 -
No saddle point here because MinMax ≠ MaxMin, so we will choose either to solve the game
using:
1. Probabilities
L 1-L
K 9 −3
[ ]
1-K 5 6
K probability that player A choose first strategy
1 - K probability that player A choose second strategy
L probability that player B choose first Strategy, 1 - L probability of second strategy
9K + 5 (1 - K) = -3K + 6 (1 - K)
9K + 5 – 5K = -3K + 6 – 6K
9K – 5K + 3K + 6K = 6 -5
1 1 12
13K = 1 K = , and 1 – K = 1 - =
13 13 13
1
The probability that player A choose first strategy is and the probability of second strategy
13
12
is
13
9L – 3 (1 - L) = 5L + 6 (1 - L)
9L – 3 + 3L = 5L + 6 – 6L
9L + 3L – 5L + 6L = 6 + 3
9 9 4
13L = 9 L = , and 1 – L = 1 - =
13 13 13
9
The probability that player B choose first strategy is and the probability of second strategy
13
4
is
13
2. Matrices Method
First, we will calculate delta (∆)
∆ = multiply elements of main diagonal – multiply elements of second diagonal
المحدد = حاصل ضرب عناصر القطر الرئيسي – حاصل ضرب عناصر القطر الفرعي
∆ = 9 * 6 – (-3 * 5) = 69
Second, calculate the rotation of matrix مدور المصفوفة
6 3
Rotation matrix = [ ]
−5 9
.مدور المصفوفة = استبدال عناصر القطر الرئيسي مع عكس اشارات عناصر القطر الفرعي
Third, calculate the rotation of rotated matrix مدور المصفوفة أو مصفوفة المرافقات
6 −5
Rotation of Rotated Matrix (Attachments Matrix) =[ ]
3 9
.مدور المدور (مصفوفة المرافقات) = تحويل الصف الي عمود والعمود الي صف
Probabilities of Row Player (Player A):
6 3
[1 1] 𝑟𝑜𝑡𝑎𝑡𝑖𝑜𝑛 𝑚𝑎𝑡𝑟𝑖𝑥 [1 1] [ ] [1 12]
−5 9
= 1 = 6 −5 1 =
[1 1] 𝐴𝑡𝑡𝑎𝑐ℎ𝑚𝑒𝑛𝑡𝑠 𝑀𝑎𝑡𝑟𝑖𝑥 [ ] [1 1] [ ][ ] 13
1 3 9 1
1 12
K= , 1–K=
13 13
𝑑𝑒𝑙𝑎𝑡𝑎 ∆ 69 69
End Game = 1 = 6 −5 1 =
[1 1] 𝐴𝑡𝑡𝑎𝑐ℎ𝑚𝑒𝑛𝑡𝑠 𝑀𝑎𝑡𝑟𝑖𝑥 [ ] [1 1] [ ][ ] 13
1 3 9 1
𝒂 𝒃
[ ]
𝒄 𝒅
𝒅−𝒄
K = (𝒂+𝒅)−(𝒃+𝒄)
𝒅−𝒃
L = (𝒂+𝒅)−(𝒃+𝒄)
𝒂𝒅 − 𝒃𝒄
End Game = (𝒂+𝒅)−(𝒃+𝒄)
Example 3:
1 3 7
[ ]
2 5 −6
Solution
First, check saddle point:
Min Max
1 3 7 1 1
[ ] -6 -
2 5 −6
Max 2 5 7
Min 2 - -
No saddle point and the matrix level is 2 * 3, so we will use subgames method.
First, divide the matrix into 3 submatrices of 2*2 level:
1 3 1 7 3 7
[ ] [ ] [ ]
2 5 2 −6 5 −6
Then we will solve each matrix as a separated game and check saddle point in each matrix.
Min Max
1 3 1 -
[ ]
2 5 2 2
Max 2 5
Min 2 -
In this subgame, there is a saddle point, which is 2 so the end game will be a gain for player
A by 2 points and a loss for player B by 2 points.
2) Second Subgame
Min Max
1 7 1 1
[ ]
2 −6 -6 -
Max 2 7
Min 2 -
Example 4:
−2 −4
[3 2]
2 3
6 −1
This matrix of level 4 * 2, so we will first check saddle point and if no saddle point we then
use dominance method to solve it.
Finished
Operations Research
Lecture 7
Transportation Problem
Improvement
Transportation Problem: Improvement
As we learnt, there are many types of solutions but the one that we concern about is optimal
solution.
How to find optimal solution in transportation problem:
1. Solve the problem using any method (north-west, lowest cost, Vogel)
2. Check this condition:
Number of filled cells must equal to N + M – 1
N -> number of rows
M -> number of columns
3. Check the optimality by calculating the path cost of the non-basic cells.
4. If all path costs are positive, so this is an optimal solution, otherwise you have to make
an improvement.
Example:
W1 W2 W3 W4 Supply
Demand 5 8 7 14 34
Demand 5 8 7 14 34
Demand 5 8 7 14 7 34
Demand 5 8 7 14 4 34
D1 21 22 10 10
D2 21 -- 10 10
D3 -- -- 10 10
W1 W2 W3 W4
As the cost row have negative values, so we should improve the solution and determine the
incoming cell and outgoing cell.
Incoming cell (is the cell with highest negative value) = -52 (X32)
Determine the outgoing cell using the path of the incoming cell:
Path + X32 – X33 + X23 – X22
Choose the negative only:
X33 and X22
Choose the cell with highest cost, which is X33 = 70
Go to the path and add 4 (amount) to cell with + sign and deduct 4 from cell with – sign.
X32 = 0 + 4 = 4
X22 = 6 – 4 = 2
X23 = 3 + 4 = 7
X33 = 4 – 4 = 0
Therefore, the improved solution will be as follows:
W1 W2 W3 W4
Note: the outgoing cell (X33) will not be included when we calculate the path and improve
this solution
Finished