62
Operations Research Linear Programming

OR Linear Programming

Embed Size (px)

Citation preview

Page 1: OR Linear Programming

Operations ResearchLinear Programming

Page 2: OR Linear Programming

Operations Research (OR)

• Branch of mathematics that deals with the allocation of scarce resources to various activities in the most effective manner

• Objective is to search for the best (optimal) solution(s) from among a number of alternative solutions

• Introduced during World War II (WW II)

Page 3: OR Linear Programming

Operations Research (OR)

• Scientists were asked to do research on (military) operations during WW II

• Success of OR led to the spread of its large-scale applications in business, industry and government

• Spread of OR was facilitated by the rapid growth in computational power

Page 4: OR Linear Programming

Systems and models

• System– Collection of interrelated objects

• Model– Abstraction of reality– Representation of a system to study the

behaviour of the system

Page 5: OR Linear Programming

Systems and models

System Model

Assumptions/Approximations

Verification/Validation

Page 6: OR Linear Programming

Classification of models

Models

Schematic models Physical models Mathematical models

Analytic models

Simulation models

Static/Dynamic

Deterministic/Stochastic

Diagrammatic representation of the system to display inter-relationships between objects

Scaled-down look-alike model of the system

Page 7: OR Linear Programming

Academics or extra-curricular?

Suppose you consider academics and extra-curricular activities are the two most important aspects that have direct bearings on your prospects for placements. You estimate the ratio of the impact of devoting 1 hour to academics to the impact of devoting 1 hour to extra-curricular activities on your placement prospects to be 3:5. You decide not to spend more than 8 hours daily for these two activities. Moreover, you estimate that 1 hour of academics and 1 hour of extra-curricular activities burn, on an average, 100 and 250 calories, respectively, and you cannot afford to burn more than 1250 calories for these two activities based on your average daily calorie intake.

Q. How many hours should you devote to academics and extra-curricular activities daily?

Page 8: OR Linear Programming

Academics or extra-curricular?Decision variables:

x1: No. of hours devoted to academics daily

x2: No. of hours devoted to extra-curricular activities daily

Objective function:Maximize the impact on placement prospects

Max z = 3x1 + 5x2

Constraints:x1 + x2 <= 8 (1)

100x1 + 250x2 <= 1250 or 2x1 + 5x2 <= 25 (2)

Non-negativity restrictions:x1, x2 >= 0

Page 9: OR Linear Programming

Graphical solution

5

5

10

10

150

A B

C

D (1)

(2)

z = 45

z = 30

z = 15

Optimal solution:

z* = 30

x1* = 5, x2

* = 3

x1

x2

Page 10: OR Linear Programming

Assumptions in LP

• Proportionality

• Additivity

• Divisibility

• Certainty

Page 11: OR Linear Programming

Simplex algorithm

• Developed by Dantzig in 1947

• Convert the LP to standard form:

Max z = 3x1 + 5x2

Subject to

x1 + x2 + s1 = 8

2x1 + 5x2 + s2 = 25

x1, x2, s1, s2 >= 0

s1 and s2 are slack variables

Page 12: OR Linear Programming

Basic and non-basic variables

• If there are n variables and m linear equations in the standard form of an LP (n>m), we can set (n – m) non-basic variables equal to zero and solve for the remaining m basic variables that satisfy the set of linear equations (provided it has a unique solution)

• A basic solution that satisfies the non-negativity restrictions is called a basic feasible solution

Page 13: OR Linear Programming

Steps in simplex algorithm

1. Determine a starting basic feasible solution. Call it the current basic feasible solution

2. If the current basic feasible solution is optimal, stop. Otherwise, determine a new basic feasible solution that has an improved z-value

3. Calling the new basic feasible solution as the current basic feasible solution, go back to step 2

Page 14: OR Linear Programming

Initial simplex tableau

z

s2

s1

x1 x2 s1 s2Basic Solution

-3 -5 0 0

0

0

1 1 1

2 5 1

0

8

25

Entering variable: x2

Leaving variable: s2

Pivot element: 5

Page 15: OR Linear Programming

Iteration 1

z

x2

s1

x1 x2 s1 s2Basic Solution

-1 0 0 1

-1/5

0

3/5 0 1

2/5 1 1/5

25

3

5

Entering variable: x1

Leaving variable: s1

Pivot element: 3/5

Page 16: OR Linear Programming

Iteration 2

z

x2

x1

x1 x2 s1 s2Basic Solution

0 0 5/3 2/3

-1/3

-2/3

1 0 5/3

0 1 1/3

30

5

3

Optimal solution: x1* = 5, x2

* = 3, z* = 30

Upper bound on the no. of iterations

= Maximum no. of basic solutions = nCm

Page 17: OR Linear Programming

Optimality and feasibility

• Optimality condition– The entering variable in a maximization (minimization) problem

is the non-basic variable having the most negative (positive) coefficient in the z-row. Ties are broken arbitrarily. The optimum is reached at the iteration where all the z-row coefficients of the non-basic variables are non-negative (non-positive)

• Feasibility condition

– For both the maximization and minimization problems, the leaving variable is the basic variable associated with the smallest non-negative ratio. Ties are broken arbitrarily

Page 18: OR Linear Programming

Simplex method

1. Determine a starting basic feasible solution

2. Select an entering variable using the optimality condition. Stop if there is no entering variable

3. Select a leaving variable using the feasibility condition

4. Determine the new basic feasible solution by using the appropriate Gauss-Jordan computations. Go back to step 2

Page 19: OR Linear Programming

Graphical interpretation

5

5

10

10

150

A B

C

D (1)

(2)

Optimal solution:

z* = 30

x1* = 5, x2

* = 3

x1

x2

Page 20: OR Linear Programming

Example: Company X

Company X produces two products - A and B - with two raw materials, V and W the maximum availabilities of which are 7000 and 6000 units, respectively. To produce one unit of A(B), 1(2) unit(s) of V and 3(1) units of W are required. If the contributions per unit of A and B are Rs. 2 and Rs. 3, respectively, determine how many units of A and B should Company X produce in order to maximize the total contribution.

Solution: A - 1000 units and B - 3000 units

Page 21: OR Linear Programming

Treating free variables

Min z = x1 – x2

Subject to

-2x1 + x2 <= 4 (1)

- x1 + 2x2 <= 4 (2)

x1, x2 freex1

x2

-2-4

2

4

(-4/3, 4/3)

z = -8

/3

(1)(2)0

Page 22: OR Linear Programming

Conversion to standard LP

Write x1 = x1+ - x1

- and x2 = x2+ - x2

-

Min z = x1+ - x1

- - x2+ + x2

-

Subject to

- 2x1+ + 2x1

- + x2+ - x2

- + s1 = 4

- x1+ + x1

- + 2x2+ - 2x2

- + s2 = 4

x1+, x1

-, x2+, x2

-, s1, s2 >= 0

Page 23: OR Linear Programming

Initial simplex tableau

z

s2

s1

x1- x2

- s1 s2Basic Solution

1 1 0 0

0

0

2 1 1

1 2 1

0

4

4

Entering variable: x1-

Leaving variable: s1

Pivot element: 2

x1+ x2

+

-1 -1

-2 -1

-1 -2

Page 24: OR Linear Programming

Iteration 1

z

s2

x1-

x1- x2

- s1 s2Basic Solution

0 1/2 -1/2 0

0

-1/2

1 1/2 1/2

0 3/2 1

-2

2

2

Entering variable: x2+

Leaving variable: s2

Pivot element: 3/2

x1+ x2

+

0 -1/2

-1 -1/2

0 -3/2

Page 25: OR Linear Programming

Iteration 2

z

x2+

x1-

x1- x2

- s1 s2Basic Solution

0 0 -1/3

-1/3

-1/3

1 0 2/3

0 1 2/3

-8/3

4/3

Optimal solution: x1- = 4/3, x2

+ = 4/3, z* = -8/3

or x1* = -4/3, x2

* = 4/3, z* = -8/3

x1+ x2

+

0 0

-1 0

0 -1

4/3

-1/3

Page 26: OR Linear Programming

Treating “=” and “>=” constraints

• Suppose in the “academics or extra-curricular?” problem, you decide to devote exactly 8 hours (no less, no more) daily to these two activities. Also, you would like to burn at least 1250 calories for these two activities. Other data remaining the same, how many hours would you now devote to academics and extra-curricular activities daily?

Modified formulation:

Max z = 3x1 + 5x2

Subject to x1 + x2 = 8 (1)2x1 + 5x2 >= 25 (2) x1, x2 >= 0

Standard form:

Max z = 3x1 + 5x2

Subject to x1 + x2 = 82x1 + 5x2 - s = 25 x1, x2, s >= 0 s is a surplus variable

Page 27: OR Linear Programming

M-method

Max z = 3x1 + 5x2 – MR1 – MR2

Subject to

x1 + x2 + R1 = 8

2x1 + 5x2 - s + R2 = 25

x1, x2, s, R1, R2 >= 0

R1, R2 are called artificial variables

M is a large number

Page 28: OR Linear Programming

Initial simplex tableau

z

R2

R1

x1 x2 s R1Basic Solution

-3 -5 0 M

0

0

1 1 1

2 5 1

0

8

25

R2

M

0

-1

Observe that the z-row coefficients of the basic variables R1 and R2 are non-zero. To make them zero, subtract M-times the first constraint row and M-times the second constraint row from the objective row.

Page 29: OR Linear Programming

Modified initial simplex tableau

z

R2

R1

x1 x2 s R1Basic Solution

-3-3M -5-6M M 0

0

0

1 1 1

2 5 1

-33M

8

25

R2

0

0

-1

Entering variable: x2

Leaving variable: R2

Pivot element: 5

Page 30: OR Linear Programming

Iteration 1

z

x2

R1

x1 x2 s R1Basic Solution

-1-3/5M 0 -1-1/5M 0

-1/5

0

3/5 0 1

2/5 1 1/5

25-3M

3

5

R2

1+6/5M

1/5

-1/5

Entering variable: x1

Leaving variable: R1

Pivot element: 3/5

Page 31: OR Linear Programming

Iteration 2

z

x2

x1

x1 x2 s R1Basic Solution

0 0 -2/3 5/3+M

-1/3

-2/3

1 0 5/3

0 1 1/3

30

5

3

R2

2/3+M

1/3

-1/3

Entering variable: s

Leaving variable: x1

Pivot element: 1/3

Page 32: OR Linear Programming

Iteration 3

z

x2

s

x1 x2 s R1Basic Solution

2 0 0 5+M

-1

1

3 0 5

1 1 0

40

15

8

R2

M

1

0

Optimal solution: x1* = 0, x2

* = 8, z* = 40

Page 33: OR Linear Programming

Special cases in simplex

• Degeneracy

• Alternative optima

• Unbounded solutions

• Infeasible solutions

Page 34: OR Linear Programming

Degeneracy

• Suppose in the “academics or extra-curricular?” problem, you decide not to devote more than 5 hours daily to these two activities. Other data remaining the same, how many hours would you now devote to academics and extra-curricular activities daily?

Modified formulation:

Max z = 3x1 + 5x2

Subject to x1 + x2 <= 5 (1)2x1 + 5x2 <= 25 (2) x1, x2 >= 0

Standard form:

Max z = 3x1 + 5x2

Subject to x1 + x2 + s1 = 52x1 + 5x2 + s2 = 25 x1, x2, s1, s2 >= 0

Page 35: OR Linear Programming

Initial simplex tableau

z

s2

s1

x1 x2 s1 s2Basic Solution

-3 -5 0 0

0

0

1 1 1

2 5 1

0

5

25

Entering variable: x2

Leaving variable: s2

Pivot element: 5

Page 36: OR Linear Programming

Iteration 1

z

x2

s1

x1 x2 s1 s2Basic Solution

-1 0 0 1

-1/5

0

3/5 0 1

2/5 1 1/5

25

0

5

Entering variable: x1

Leaving variable: s1

Pivot element: 3/5

Page 37: OR Linear Programming

Iteration 2

z

x2

x1

x1 x2 s1 s2Basic Solution

0 0 5/3 2/3

-1/3

-2/3

1 0 5/3

0 1 1/3

25

0

5

Optimal solution: x1* = 0, x2

* = 5, z* = 25

Page 38: OR Linear Programming

Graphical interpretation

5

5

10

10

150

A B

C

(1) (2)

Optimal solution:

z* = 25

x1* = 0, x2

* = 5

x1

x2

z = 25

Redundant constraint

Page 39: OR Linear Programming

Alternative optima

• Suppose in the “academics or extra-curricular?” problem, you estimate that the effect of 1 hour of academics and the effect of 1 hour of extra-curricular activities on your placement prospects are the same. Other data remaining the same, how many hours would you now devote to academics and extra-curricular activities daily?

Modified formulation:

Max z = x1 + x2

Subject to x1 + x2 <= 8 (1)2x1 + 5x2 <= 25 (2) x1, x2 >= 0

Standard form:

Max z = x1 + x2

Subject to x1 + x2 + s1 = 82x1 + 5x2 + s2 = 25 x1, x2, s1, s2 >= 0

Page 40: OR Linear Programming

Initial simplex tableau

z

s2

s1

x1 x2 s1 s2Basic Solution

-1 -1 0 0

0

0

1 1 1

2 5 1

0

8

25

Entering variable: x1

Leaving variable: s1

Pivot element: 1

Page 41: OR Linear Programming

Iteration 1

z

s2

x1

x1 x2 s1 s2Basic Solution

0 0 1 0

0

-2

1 1 1

0 3 1

8

8

9

Entering variable: x2

Leaving variable: s2

Pivot element: 3

Page 42: OR Linear Programming

Iteration 2

z

x2

x1

x1 x2 s1 s2Basic Solution

0 0 1 0

-1/3

-2/3

1 0 5/3

0 1 1/3

8

5

3

Optimal solution: x1* = 5, x2

* = 3, z* = 8

Page 43: OR Linear Programming

Graphical interpretation

5

5

10

10

150

A B

C

D (1)

(2)

Optimal solution:

z* = 8

x1* = 8, x2

* = 0, or

x1* = 5, x2

* = 3

x1

x2

z = 10

Page 44: OR Linear Programming

Unbounded solutions

• Suppose in the “academics or extra-curricular?” problem, you decide to devote at least 8 hours daily to these two activities. Also, you would like to burn at least 1250 calories for these two activities. Other data remaining the same, how many hours would you now devote to academics and extra-curricular activities daily?

Modified formulation:

Max z = 3x1 + 5x2

Subject to x1 + x2 >= 8 (1)2x1 + 5x2 >= 25 (2) x1, x2 >= 0

Standard form:

Max z = 3x1 + 5x2 - MR1 - MR2

Subject to x1 + x2 - s1 + R1 = 82x1 + 5x2 - s2 + R2 = 25 x1, x2, s1, s2, R1, R2 >= 0

Page 45: OR Linear Programming

Initial simplex tableau

z

R2

R1

x1 x2 s1 R1Basic Solution

-3 -5 0 M

0

0

1 1 1

2 5 1

0

8

25

R2

M

0

-1

Observe that the z-row coefficients of the basic variables R1 and R2 are non-zero. To make them zero, subtract M-times the first constraint row and M-times the second constraint row from the objective row.

s2

0

-1

0

Page 46: OR Linear Programming

Modified initial simplex tableau

z

R2

R1

x1 x2 s1 R1Basic Solution

-3-3M -5-6M M 0

0

0

1 1 1

2 5 1

-33M

8

25

R2

0

0

-1

s2

M

-1

0

Entering variable: x2

Leaving variable: R2

Pivot element: 5

Page 47: OR Linear Programming

Iteration 1

z

x2

R1

x1 x2 s1 R1Basic

-1-3/5M 0 M 0

-1/5

0

3/5 0 1

2/5 1 1/5

25-3M

3

5

R2

1+6/5M

1/5

-1/5

s2

-1-1/5M

-1

0

Entering variable: x1

Leaving variable: R1

Pivot element: 3/5

Solution

Page 48: OR Linear Programming

Iteration 2

z

x2

x1

x1 x2 s1 R1Basic

0 0 -5/3 5/3+M

-1/3

-2/3

1 0 5/3

0 1 1/3

30

5

3

R2

2/3+M

1/3

-1/3

s2

-2/3

-5/3

2/3

Entering variable: s1

Leaving variable: x2

Pivot element: 2/3

Solution

Page 49: OR Linear Programming

Iteration 3

z

s1

x1

x1 x2 s1 R1Basic

0 5/2 0 M

1/2

-1

1 5/2 0

0 3/2 1/2

75/2

25/2

9/2

R2

3/2+M

-1/2

-1/2

s2

-3/2

0

1

Solution

Entering variable: s2

Leaving variable: ?

Page 50: OR Linear Programming

Graphical interpretation

5

5

10

10

150

(1)

(2)

x1

x2

z = 45

Page 51: OR Linear Programming

Infeasible solutions

• Suppose in the “academics or extra-curricular?” problem, you decide to devote at most 5 hours daily to these two activities. Also, you would like to burn at least 1500 calories for these two activities. Other data remaining the same, how many hours would you now devote to academics and extra-curricular activities daily?

Modified formulation:

Max z = 3x1 + 5x2

Subject to x1 + x2 <= 5 (1)2x1 + 5x2 >= 30 (2) x1, x2 >= 0

Standard form:

Max z = 3x1 + 5x2 - MRSubject to x1 + x2 + s1 = 52x1 + 5x2 - s2 + R = 30 x1, x2, s1, s2, R >= 0

Page 52: OR Linear Programming

Initial simplex tableau

z

R

s1

x1 x2 s1 s2Basic Solution

-3 -5 0 0

0

0

1 1 0

2 5 1

0

5

30

R

M

1

-1

Observe that the z-row coefficient of the basic variable R is non-zero. To make it zero, subtract M-times the second constraint row from the objective row.

Page 53: OR Linear Programming

Modified initial simplex tableau

z

R

s1

x1 x2 s1 s2Basic Solution

-3-2M -5-5M 0 M

0

0

1 1 0

2 5 1

-30M

5

30

R

0

1

-1

Entering variable: x2

Leaving variable: s1

Pivot element: 1

Page 54: OR Linear Programming

Iteration 1

z

R

x2

x1 x2 s1 s2Basic Solution

2+3M 0 5+5M M

0

-5

1 1 0

-3 0 1

25-5M

5

5

R

0

1

-1

In the optimal tableau, the artificial variable R is positive!

Page 55: OR Linear Programming

Graphical interpretation

5

5

10

10

150

(1) (2)

x1

x2

z = 45

Page 56: OR Linear Programming

Duality

• Consider the “academics or extra-curricular?” problem in modified form:

Primal problem

Max z = 3,00,000x1 + 5,00,000x2

Subject to

x1 + x2 <= 8

100x1 + 250x2 <= 1250

x1, x2 >= 0

Page 57: OR Linear Programming

Resources and their worth

• Resources– Time: Maximum availability 8 hours– Energy: Maximum availability 1250 calories

• Worth of resources– y1: Unit worth of resource ‘Time’

– y2: Unit worth of resource ‘Energy’

Page 58: OR Linear Programming

Dual formulation

Dual problem

Min w = 8y1 + 1250y2

Subject to

y1 + 100y2 >= 3,00,000

y1 + 250y2 >= 5,00,000

y1, y2 >= 0

Page 59: OR Linear Programming

Primal-dual conversion rules

Maximization prob. Minimization prob.

Constraints Variables

0

0

= Unrestricted

Variables Constraints

0

0

Unrestricted =

Page 60: OR Linear Programming

Academics or extra-curricular?

Primal problem expressed in standard form:

Max z = 3,00,000x1 + 5,00,000x2

Subject to

x1 + x2 + s1 = 8

100x1 + 250x2 + s2 = 1250

x1, x2, s1, s2 >= 0

Page 61: OR Linear Programming

Optimal primal tableau

z

x2

x1

x1 x2 s1 s2Basic Solution

0 0 1,66,666.67 1333.33

-1/150

-2/3

1 0 5/3

0 1 1/150

30,00,000

5

3

Optimal solution: x1* = 5, x2

* = 3, z* = 30,00,000

Page 62: OR Linear Programming

Example: Company X

z

x1

x2

x1 x2 s1 s2Basic Solution

0 0 1.4 0.20

-1/5

-1/5

0 1 3/5

1 0 2/5

11,000

3000

1000

Optimal solution: x1* = 1000, x2

* = 3000, z* = 11,000

Optimal primal tableau