Download as pdf or txt
Download as pdf or txt
You are on page 1of 5

Linear Programming

Prepared for

Prof. Mousa Mohamed Mousa

Ahmed Mohamed AbdulDayem


SEC. 2
Problem 1

let xi ϵ {0, 1} so that xi = 1 means that a fire station is built in city i.


Min Z=x1+ x2+ x3+ x4+ x5+ x6
Constraints
 x1 + x2 >= 1 (City 1)
 x1 + x2 + x6 >= 1 (City 2)
 x3 + x4 >= 1 (City 3)
 x3 + x4 + x5 >= 1 (City 4)
 x4 + x5 + x6 >= 1 (City 5)
 x2 + x5 + x6 >= 1 (City 6)
xi = 0 or 1 ( i = 1 ,2 ,3 ,4 ,5 , 6)
MATLAB

• Optimal: 2 fire station at least, x2=x4=1, x1=x3= x5=x6= 0, Thus,


Menoufia Governorate can build two fire stations: one in city2
and one in city 4.
LiPS

>> Optimal solution FOUND


>> Minimum = 2
*** RESULTS - VARIABLES ***
╔═════════════╤═════════════╤═════════════╤═════════════╗
║ Variable│ Value│ Obj. Cost│ Reduced Cost║
╠═════════════╪═════════════╪═════════════╪═════════════╣
║ X1│ 0│ 1│ -1║
╟─────────────┼─────────────┼─────────────┼─────────────╢
║ X2│ 1│ 1│ 0║
╟─────────────┼─────────────┼─────────────┼─────────────╢
║ X3│ 0│ 1│ 0║
╟─────────────┼─────────────┼─────────────┼─────────────╢
║ X4│ 1│ 1│ 0║
╟─────────────┼─────────────┼─────────────┼─────────────╢
║ X5│ 0│ 1│ 0║
╟─────────────┼─────────────┼─────────────┼─────────────╢
║ X6│ 0│ 1│ 0║
╚═════════════╧═════════════╧═════════════╧═════════════╝
*** RESULTS - CONSTRAINTS ***
╔═══════════╤═══════════╤═══════════╤═══════════╗
║ Constraint│ Value│ RHS│ Dual Price║
╠═══════════╪═══════════╪═══════════╪═══════════╣
║ Row1│ 1│ 1│ 0║
╟───────────┼───────────┼───────────┼───────────╢
║ Row2│ 1│ 1│ 0║
╟───────────┼───────────┼───────────┼───────────╢
║ Row3│ 1│ 1│ 1║
╟───────────┼───────────┼───────────┼───────────╢
║ Row4│ 1│ 1│ 0║
╟───────────┼───────────┼───────────┼───────────╢
║ Row5│ 1│ 1│ 0║
╟───────────┼───────────┼───────────┼───────────╢
║ Row6│ 1│ 1│ 1║
╟───────────┼───────────┼───────────┼───────────╢
║ BND.X1│ 0│ 1│ 0║
╟───────────┼───────────┼───────────┼───────────╢
║ BND.X2│ 1│ 1│ 0║
╟───────────┼───────────┼───────────┼───────────╢
║ BND.X3│ 0│ 1│ 0║
╟───────────┼───────────┼───────────┼───────────╢
║ BND.X4│ 1│ 1│ 0║
╟───────────┼───────────┼───────────┼───────────╢
║ BND.X5│ 0│ 1│ 0║
╟───────────┼───────────┼───────────┼───────────╢
║ BND.X6│ 0│ 1│ 0║
╚═══════════╧═══════════╧═══════════╧═══════════╝
Problem 2
Variables
x1: The number of scoops of butter.
X2: The number of slices of bread.
X3: The number of bottles of orange juice.
X4: the number of slices of fat.
Min Z=5x1+ 2x2+ 3x3+ 8x4
Constraints
• 400x1 + 200x2 +150x3 +500x4 >= 500 (Calories)
• 3x1 + 2x2 >= 6 (Sugar)
• 2x1 + 2x2 + 4x3 + 4x4 >= 10 (Carbohydrates)
• 2x1 + 4x2 + 1x3 + 5x4 >= 8 (Fat)
MATLAB

• Optimal: x1=0 ; x2=3 ; x3=1 ; x4=0 and The minimum cost equal
$9.
LiPS

>> Optimal solution FOUND


>> Minimum = 9

*** RESULTS - VARIABLES ***


╔═════════════╤═════════════╤═════════════╤═════════════╗
║ Variable│ Value│ Obj. Cost│ Reduced Cost║
╠═════════════╪═════════════╪═════════════╪═════════════╣
║ X1│ 0│ 5│ -2.75║
╟─────────────┼─────────────┼─────────────┼─────────────╢
║ X2│ 3│ 2│ 0║
╟─────────────┼─────────────┼─────────────┼─────────────╢
║ X3│ 1│ 3│ 0║
╟─────────────┼─────────────┼─────────────┼─────────────╢
║ X4│ 0│ 8│ -5║
╚═════════════╧═════════════╧═════════════╧═════════════╝
*** RESULTS - CONSTRAINTS ***
╔═══════════╤═══════════╤═══════════╤═══════════╗
║ Constraint│ Value│ RHS│ Dual Price║
╠═══════════╪═══════════╪═══════════╪═══════════╣
║ Row1│ 750│ 500│ 0║
╟───────────┼───────────┼───────────┼───────────╢
║ Row2│ 6│ 6│ 0.25║
╟───────────┼───────────┼───────────┼───────────╢
║ Row3│ 10│ 10│ 0.75║
╟───────────┼───────────┼───────────┼───────────╢
║ Row4│ 13│ 8│ 0║
╚═══════════╧═══════════╧═══════════╧═══════════╝

You might also like