You are on page 1of 70

Linear Programming*

Nur Aini Masruroh

*part of the lecture are adopted from OPC (IE5001) lecture note ISE dept NUS

Outline

Introduction Problem formulation Solution methods


Graphical solution Simplex method

Duality Sensitivity analysis Post optimal analysis

Introduction

What is linear programming?

Concerned with the determination of the best allocation of scarce resource Special condition linearity

Linear expression

2x1 + 3x2 x3 + 5

Nonlinear expression

x1 + 3x2x3 - 2

A LP model
Maximize (minimize) : c1x1 + c2x2 + + cnxn (objective function) Subject to a11x1 + a12x2 + + a1nxn b1 a21x1 + a22x2 + + a2nxn b2

am1x1 + am2x2 + + amnxn bm x1, x2, , xn 0 Where xj, j = 1,2, , n decision variable bi, I = 1,2,,m resources, m of them cj, j = 1,2,,n cost/profit coefficients aij, I = 1,2,,m; j=1,2,,n resource requirement

Constraints

Four LP assumptions
1.

2.

3.

4.

Deterministic parameter values All values of aij, cj, and bi are known with 100% of accuracy and never change Proportionality The criterion and the constraints expand or contract proportionally to the level of each activities, i.e. no economies of scale Additivity The total contribution of all activities is identical to the sum of the contribution for each activity individually, i.e. the whole is equal to the sum of its parts (joint effects or interactions are nonexistent) Divisibility Fractional levels for the decision variables are permissible

FORMULATING LP MODEL

Soal 1
Pyrotec company memproduksi 3 produk elektronik; jam, radio, dan pemanggang roti. Produk-produk tersebut membutuhkan sumber daya sebagai berikut:
Kebutuhan sumber daya Produk Jam Radio Pemanggang roti Biaya/unit ($) 7 10 5 Waktu tenaga kerja/unit (jam) 2 3 2

Anggaran produksi harian sebesar $2,000 dan tenaga kerja yang tersedia sebanyak 600 jam. Permintaan pelanggan harian maksimum sebanyak 200 jam, 300 radio, dan 150 pemanggang roti. Jam dijual seharga $15, radio seharga $20, dan pemanggang roti seharga $12. Tentukan production mix yang optimal untuk memaksimumkan profit

Soal 2
Perusahaan barang tembikar memproduksi 2 jenis produk tiap hari yaitu cangkir dan mangkok. Perusahaan mempunyai 2 sumber daya yang terbatas jumlahnya untuk memproduksi produk produk tersebut yaitu tanah liat dan tenaga kerja. Dengan keterbatasan sumber daya tersebut perusahaan ingin mengetahui berapa banyak mangkok dan cangkir yang dapat diproduksi tiap hari yang akan memaksimumkan laba. Data kebutuhan sumber daya tiap produk terdapat dalam table berikut:

Tersedia 40 jam tenaga kerja dan 120 pon tanah liat setiap hari untuk produksi.

Soal 3
Perusahaan penerbit Agensi menerbitkan 2 jenis majalah bulanan, yaitu majalah Restoran dan Perumahan. Perusahaan mendistribusikan majalah-majalahnya secara gratis ke hotel-hotel, pertokoan di wilayah tertentu. Keuntungan perusahaan didapatkan sepenuhnya dari iklan di majalah tersebut. Setiap eksemplar majalah Restoran memberikan keuntungan $ 0,5. Sedangkan majalah Perumahan $ 0,75 per eksemplarnya. Majalah Perumahan mempunyai desain yang lebih mewah dengan biaya pencetakan $ 0,25 per eksemplar, sementara biaya pencetakan majalah Restoran $ 0,15 per eksemplar. Total anggaran bulanan perusahaan $ 4000. Kapasitas rak penyimpanan sementara di gudang adalah 18000 eksemplar/bulan. Sesuai perjanjian dengan pemasang iklan, sirkulasi tiap majalah harus dipertahankan minimal 8000 eksemplar per bulan. Perusahaan mencoba menghitung berapa banyak jumlah majalah harus dicetak tiap bulannya dengan tujuan memaksimalkan pendapatan. Formulasikan problem tersebut ke dalam bentuk Linear Programming.

Soal 4
A company has excess production capacity on three types of machines which can be used to make two products A and B Data
A Machining Boring Polishing Selling price Cost of material 25 units/hr 28 units/hr 35 units/hr $5/unit $2/unit B 40 units/hr 35 units/hr 25 units/hr $6/unit $3/unit Cost/hr 20 14 17.5

Soal 4 (contd)
Problems: 1. How should the excess capacity on machines be used to maximize profit?
2.

Minimize cost while maximize revenue


Maximize utilization of the machinery

3.

Soal 5 (oil blending problem)


A refinery produces 3 grades of oil A, B, and C from 4 grades of crude oil 1, 2, 3, and 4 Data

Crude 1 2 3 4

Quantity available 3000 2000 4000 1000

Cost/barrel 3 6 4 5

Soal 5 (contd)

Blending requirements:

Oil A

Not more than 30% of 1 Not less than 40% of 2 Not more than 50% of 3 Not more than 50% of 1 Not less than 10% of 2 Not more than 70% of 1

Oil B

Oil C

Soal 5 (contd)

Selling price

A - $5.5 B - $4.5 C - $3.5

Problem: what blends of crude should be used to make each grade of oil in order to maximize profit subject to quantities available and blending requirements?

SOLVING LINEAR PROGRAMMING

Graphical solution

Find all pairs of (x1, x2) which satisfy each constraint separately Find all pairs of (x1, x2) which satisfy all constraints. That is, find set of feasible solutions Choose the one which gives the max value of objective function

Graphical solution example 1


Max z = 40 x1 + 50 x2 Subject to 150 x1 + 350 x2 5000 100 x1 + 50 x2 1500 x1, x2 0

Graphical solution example 1

Graphical solution example 2 (no solution)


Max z = 3 x1 + 2 x2 Subject to 2 x1 + x2 2 3 x1 + 4 x2 12 x1, x2 0

Graphical solution example 2 (no solution) contd

Graphical solution example 3 (unbounded solution)


Max z = 2 x1 + x2 Subject to x1 - x2 10 2 x1 - x2 40 x1, x2 0

Graphical solution example 3 (unbounded solution)

Graphical solution example 3 (unbounded solution) remarks

There is no upper limit on the value which the objective function can assume Error in formulation

In real world, this does not exist

Graphical solution example 4 (infinite number of solutions)


Max z = 4 x1 + 14 x2 Subject to 2x1 + 7x2 21 7 x1 + 2x2 21 x1, x2 0

Graphical solution example 4 (infinite number of solutions)

Graphical solution example 4 (infinite number of solutions) remarks

More than one combination of values of decision variables will result in the optimal solution for the objective function Choose one solution based on qualitative consideration Objective function parallel to one of the binding constraints

Simplex method

Simplex algorithm outline


1.

2.

Find some feasible corner points and calculate z While z can be improved by moving to an adjacent corner point

Select the adjacent corner point giving the greater rate of improvement in z Calculate the coordinates of the new point and new z value

3.

Stop

Simplex algorithm example


max z = 7x1+ 10x2 subject to 5x1+ 4x2 24 2x1+ 5x2 13 x1 , x2 0 Convert the inequalities into equations form max z = 7x1+ 10x2 subject to 5x1+ 4x2 + s1 = 24 2x1+ 5x2 + s2 = 13

Simplex algorithm example (contd)


Solution # 1: s1 = 24, s2 = 13, x1= 0, x2 = 0, z = 0 Can z be improved by making x1 > 0 ? Yes, if x1 > 0, then for each unit increase in x1 , z goes up 7 Can z be improved by making x2> 0 ? Yes, if x2 > 0, then for each unit increase in x2 , z goes up 10 Which variable should be solved for in the next solution? Since by making x2> 0 , it gives the greatest rate of improvement, this variable should be chosen to enter the basic.

Simplex algorithm example (contd)


Which variable should leave the basic? This can be determined as follows: For the constraint c1: 5x1+ 4x2 + s1 = 24, max x2 can increase is 6 For the constraint c2: 2x1+ 5x2 + s2 = 13, max x2 can increase is 2.6, in this case s2 = 0. We obtain the following solution: Solution # 2: s1 = 13.6, x2 = 2.6, x1= 0, s2 = 0, z = 26

Simplex algorithm example (contd)


The above solution procedures can be carried out in the following Simplex tableau form: Simplex Tableau Pivot column Iteration 1:
Basic
Z S1 S2
Pivot row Pivot element

x1
-7 5 2

x2
-10 4 5

s1
0 1 0

s2
0 0 1

RHS
0 24 13

Ratio

24/4=6 13/5=2.6

Simplex algorithm example (contd)


Select x2 as the entering variable and s2 as the leaving variable gives Set 0 to cells in the pivot column Iteration 2: except pivot element
Basic Z S1 x1 -3 17/5 x2 0 0 s1 0 1 s2 2 -4/5 RHS 26 68/5 (68/5)/(17/5)=4 Ratio

X2

2/5

1/5

13/5

(13/5)/(2/5)=6.5

All elements in the pivot row are divided by pivot element

Apply Gauss-Jourdan elimination to other cells

Gauss-Jordan Elimination

New value = old value (new value of element in the pivot row in the respective column)(old value of the pivot column in the respective row) Example: cell s1 x1 new value = 5 (2/5)(4) = 17/5

Simplex algorithm example (contd)


Select x1 as the entering variable and s1 as the leaving variable gives Iteration 3:
Basic Z x1 0 x2 0 s1 15/17 s2 22/17 RHS 38

X1
X2

1
0

0
1

5/17
-2/17

-4/17
5/17

4
1

Since all the coefficients in Row (0) are now all non-negative, the current solution is optimal

Simplex summary
At each iteration, all variables are partitioned into 2 classes as shown below:

Simplex method for solving a general LP problem


Consider the following LP model:

max
Subject to :

z cjxj
j 1

a x
j 1 ij

si bi j 1,...,n

i 1,2,...,m

x j 0,

If bi are all 0, then an initial feasible solution can be obtained as follows: xj = 0, j=1,,n si = bi, i=1,,m

Simplex method for solving a general LP problem (contd)


What happens if bi < 0 for some i? In this case, the LP problem can be solved by the Two-Phase Method. Example 2 max z = 7x1+ 10x2 subject to 5x1+ 4x2 24 2x1+ 5x2 13 x1 , x2 0

Simplex method: example 2


Step 1: Define an artificial variable ri for each of the or = type constraint and add them to the LP model (PhaseI) max z = -r1 subject to 5x1+ 4x2 - s1 + r1 = 24 2x1+ 5x2 + s2 = 13 x1, x2, s1, s2, r1 0 Step 2: Eliminate r1 from Row(0) before we have the first solution. That is Row(0) Row(0)-Row(1) Row(0): z - 5x1 - 4x2 + s1 = -24

Simplex method: example 2 (contd)


Iteration 1: Basic Z x1 -5 x2 -4 s1 1 s2 0 r1 0 RHS -24 Ratio

r1
S2

5
2

4
5

-1
0

0
1

1
0

24
13

24/5=4.8
13/2=6.5

Simplex method: example 2 (contd)


Select x1 as the entering variable and r1 as the leaving variable

Iteration 2:
Basic Z x1 S2 x1 0 1 0 x2 0 4/5 17/5 s1 0 -1/5 2/5 s2 0 0 1 r1 1 1/5 -2/5 RHS 0 24/5 3.4

The solution to the Phase-I LP problem is now optimal. Hence we have obtained a basic feasible solution to the original LP problem

Simplex method: example 2 (contd)


Step 3: Drop the artificial column and optimize the original objective function: max z = 7x1+ 10x2 subject to x1+ (4/5)x2 (1/5)s1 = 4.8 (17/5)x2 + (2/5)s1 + s2 = 3.4 x1, x2, s1, s2 0 An initial basic feasible solution is: x1 = 4.8, s2 = 3.4

Simplex method: example 2 (contd)


Step 4: Eliminate the coefficient of x1 from Row(0) before we start the Phase-II solution. That is Row(0) Row(0)+ 7Row(1) This gives Row(0): z (22/5)x2 (7/5)s1 = 33.6 The initial Simplex tableau is given below: Basic Z x1 0 x2 -22/5 s1 -7/5 s2 0 RHS 33.6 Ratio

x1
S2

1
0

4/5
17/5

-1/5
2/5

0
1

4.8
3.4

4.8/0.8=6
3.4/3.4=1

Simplex method: example 2 (contd)


Select x2 as the entering variable and s2 as the leaving variable gives Iteration 2: Basic Z x1 x2 x1 0 1 0 x2 0 0 1 s1 -15/17 -5/17 2/17 s2 22/17 -4/17 5/17 RHS 38 4 1 17/2 Ratio

Simplex method: example 2 (contd)


Select s1 as the entering variable and x2 as the leaving variable gives Iteration 3: Basic Z x1 0 x2 15/2 s1 0 s2 7/2 RHS 45.5

x1
s1

1
0

5/2
17/2

0
1

5/2

6
17/2

Since all the coefficients in Row(0) are now all nonnegative, the current solution to the Phase-II LP problem is optimal.

Special cases of LP solution


1. If there is a tie a) For entering non-basic variables: Choose any one of them. b) For leaving basic variables: Choose any one of them. 2. What if when you solve for basic variables, one of them has a value of zero? It does not matter, it is only theoretical important. The name given to this kind of solution is degenerate.

Special cases of LP solution (contd)


3. How can you tell if the LP problem has no solution (that is, the model is inconsistent)? This can be detected if some artificial variables have positive values when the LP solution is optimal. 4. How can you tell if the LP solution is unbounded? This can be detected if an entering variable can be increased without limit. That is, the pivot column has no positive coefficients.

Special cases of LP solution (contd)


5. How can you tell if there is more than one optimal solution? This can be detected if there exists a non-basic variable which has a coefficient of zero in the final objective function row. Note that if P1and P2 are two optimal corner points then P1+(1- )P2 are equally good solution, for any 0 1.

Special cases of LP solution (contd)


6. Redundant constraint If one or more equality constraints are linear combination of the other equality constraints, then they are redundant and can be eliminated. For example, consider the following LP problem: max z = 2x1+ 3x2 subject to x1 + x2 = 4 (1) -x1 + 3x2 = 7 (2) 4x2 = 11 (3) x1 , x2 0 Constraint (3) = (1)+(2), and hence any one of them can be eliminated.

Duality
Primal Problem: max z = 7x1+ 10x2 subject to y1: 5x1+ 4x2 24 y2: 2x1 + 5x2 13 x1 , x2 0 Dual Problem: min w = 24y1+ 13y2 subject to x1: 5y1+ 2y2 7 x2: 4y1 + 5y2 10 y1 , y2 0

Dual problem example 2


Primal Problem: max z = 3x1+ 4x2 subject to y1: -2x1+ 3x2 6 y2: 5x1 - x2 40 y3: x1 + x2 7 x1 , x2 0 Dual Problem: min w = 6y1+ 40y2 + 7y3 subject to x1: -2y1+ 5y2 + y3 3 x2: 3y1 - y2 + y3 4 y1 , y2 , y3 0

Dual problem example 3


Primal Problem: max z = 7x1+ 10x2 - x3 subject to y1: 5x1+ 4x2 24 y2: 2x1 +5x2 + 3x3 = 13 y3: x1 - 2x2 + x3 5 y4: x2 + 2x3 10 x10, x20 , x3 unrestricted Dual Problem: min w = 24y1+ 13y2 + 5y3 + 10y4 subject to x1: 5y1 + 2y2 + y3 7 x2: 4y1 + 5y2 - 2y3 + y4 10 x3: 3y2 + y3 + 2y4 = -1 y10 , y2 unrestricted, y30 , y40

Dual problem example 4


Primal Problem: max : z = c1x1 + c2x2 + + cnxn Subject to a11x1 + a12x2 + + a1nxn b1 a21x1 + a22x2 + + a2nxn b2 M am1x1 + am2x2 + + amnxn bm x1, x2,, xn 0 Dual Problem: min : w = b1y1 + b2y2 + + bmym Subject to a11y1 + a21y2 + + am1ym c1 a12y1 + a22y2 + + am2ym c2 M a1ny1 + a2ny2 + + amnym cn y1, y2,, ym 0

Dual problem in general


Primal max ith constraint type ith constraint type ith constraint = type xj 0 Dual min yj 0 yj 0 yi unrestricted jth constraint type

xj 0
xj unrestricted

jth constraint type


jth constraint = type

Significance of dual problem


1. 2.

Mathematically very important Computationally One model (with fewer constraints) is easy to solve

Primal

Dual

3. Economic interpretation of the dual variable (shadow price) Shadow price of constraint I gives the rate of change in the objective function per unit change in the RHS value of the constraints. That is, Shadow price of constraints i = z/ bi = Dual variable yi

Properties of primal and dual problems


1. Dual of the dual is primal 2. Any feasible value of max z any feasible value of min w 3. Optimal of z = optimal value of w 4. If primal is unbounded then dual has no solution 5. If dual is unbounded then primal has no solution

Properties of primal and dual problems (contd)


6. From the final tableau of the primal, the optimal solution of the dual can be obtained

The value of the slack or artificial coefficient in the objective function row in the final optimal primal tableau gives the optimal value of the associated dual variable. Complementary slackness

Product of the jth decision variable and jth dual slack = 0 ith slack variable ith dual variable = 0 at optimal If si > 0 then yi = 0 If yi > 0 then si = 0

Sensitivity analysis
Sensitivity analysis is to answer the following question: How does the optimal solution change as a coefficient is varied from its given value? Why sensitivity analysis is important? Many coefficients are estimated Want to know the sensitivity of the optimal solution with respect to these coefficients.

Sensitivity analysis (contd)


There are three kinds of such analysis: Objective function ranging (coefficient ranging) RHS value ranging Constraint coefficient ranging In this course, we shall discuss the first two types of sensitivity analysis only.

Range of objective function coefficients


Case 1: Non-basic variable What happens if the coefficient of a non-basic objective function, cj, is changed by an amount of ? What range of values for is the current solution remains optimal? Consider the following LP problem: max z = 20x1+ 10x2 subject to 5x1+ 4x2 24 2x1+ 5x2 13 x1 , x2 0

Range of objective function coefficients (contd)


Initial simplex tableau: Basic Z s1 s2 x1 -20 5 2 x2 -10 4 5 s1 0 1 0 s2 0 0 1 RHS 0 24 13

Final simplex tableau:

Basic Z x1 s2

x1 0 1 0

x2 6 4/5 17/5

s1 4 1/5 -2/5

s2 0 0 1

RHS 96 24/5 17/5

Range of objective function coefficients (contd)


If c2= 10 + , what would happen to the coefficients in the objective function row? We note that in applying the Simplex algorithm, the Row(0) are updated from tableau to tableau in the following manner: Row(0) Row(0)+ iRow(i) That is, Row(0) values are determined solely by row operations of adding multiples of the other rows to Row(0). Therefore, the term should remain unchanged in the final tableau.

Range of objective function coefficients (contd)


It follows that the final simplex tableau is given by:

Basic Z
x1 s2

x1 0
1 0

x2 6-
4/5 17/5

s1 4
1/5 -2/5

s2 0
0 1

RHS 96
24/5 17/5

Hence, the existing basic will remain optimal as long as 6 0 6 In other words, the solution will remain optimal as long as c2 16

If c2 > 16, then Row(0) coefficient for x2 becomes negative and x2 would enter the solution and s2 would become non-basic

Range of objective function coefficients (contd)


Case 2: Basic variable What happens if the coefficient of a basic objective function, cj, is changed by an amount of ? If c1 = 20+, what would happen to the coefficients in the objective function row? The final Simplex tableau now becomes Basic Z x1 s2 x1 - 1 0 x2 6 4/5 17/5 s1 4 1/5 -2/5 s2 0 0 1 RHS 96 24/5 17/5

Range of objective function coefficients (contd)


Note that the coefficient in column x1and Row(0) should be eliminated through the following row operations: Row(0) Row(0)+ Row(1) This reduces to the following Simplex tableau: Basic Z x1 s2 x1 0 1 0 x2 6+(4/5) 4/5 17/5 s1 4+ /5 1/5 -2/5 s2 0 0 1 RHS 96+(24/5) 24/5 17/5

Range of objective function coefficients (contd)


Hence, in order for the current solution to remain optimal, we need 6+(4/5) 0 4+/5 0 It follows that -7.5 -20
This gives -7.5 or c1 12.5.

Range of RHS values


What happens if bi, is changed by an amount of ?

If b1 = 24+, then the final Simplex tableau now becomes


Basic Z x1 s2 x1 0 1 0 x2 6 4/5 17/5 s1 4 1/5 -2/5 s2 0 0 1 RHS 96+4 24/5+ /5 17/5-(2/5)

That is, the RHS column is replaced by the sum of the


RHS column and times the s1 column.

Range of RHS values (contd)


Now, in order for the current solution remains optimal, it must be feasible. That is 24/5 + /5 0 17/5 (2/5) 0 This gives -24 8.5 or 0 b1 32.5.

Range of RHS values (contd)


Similarly, if b2 = 13+, then the final Simplex tableau now becomes

Basic Z x1 s2

x1 0 1 0

x2 6 4/5 17/5

s1 4 1/5 -2/5

s2 0 0 1

RHS 96 24/5 17/5+

It follows that
-17/5 or b2 9.6

Range of RHS values (contd)


In general, for bi 0, the new RHS col in the final simplex tableau becomes

For the type constraint: RHS + col of si For the type constraint: RHS - col of si For the = type constraint: RHS + col of ri

The range of can be determined by solving a set of simple linear inequalities associated with the new RHS values in rows 1 to m.

You might also like