1. Unit V : Linear Programming
Syllabus :
•Standard and Slack forms
•Formulation of Problems as Linear Programs
•Simplex Algorithm
•Duality
•Initial Basic Feasible Solution
•Problem Formulation for
Single Source Shortest path
Maximum Flow Problem
2. Unit V : Linear Programming
Introduction :
Operations Research :
•Operations Research (OR) includes identification of a real life
problem, formulation of the problem as OR model and
providing the realistic solution to the problem. Generally these
problems are optimization problems (NP-Hard)
•OR includes the following techniques :
Linear Programming
Probability, Decision Analysis and Games
Queuing Systems
Job Sequencing – PERT / CPM
Non-Linear Programming etc.
3. Unit V : Linear Programming
Introduction :
OR Models :
Example -1: Construct a maximum area rectangle out of a
piece of wire of length L.
Example -2: Amy, Jim, John and Kelly are standing on the
east bank of a river and wish to cross to the west side using
canoe. The canoe can hold at most two people at a time. Amy
being the most athletic, can row across the river in one minute.
Jim, John and Kelly would take 2, 5, and 10 minutes
respectively to row across. If two people are their in canoe, the
slower person dictates the crossing time. The objective is for
all four people to be on the other side of the river in the
shortest time possible.
a) Identify at least two feasible plans for crossing
4. Unit V : Linear Programming
Introduction :
OR Models contd…:
b) Define the objective criterion for evaluating
the alternatives.
c) What is the shortest time for moving all four
people to the other side of the river?
Example -3: (LP Model) The Reddy Mikks company
produces both interior and exterior paints from the two raw
materials M1 and M2.The following table provides the basic
data of the problem:
Tons of Raw
Matlerial / ton
of
Daily Max.
Raw Matl
Availability in
tons
Exterior Paint Interior Paint
5. Unit V : Linear Programming
Introduction :
OR Models contd …:
Example -3 contd…: A market survey indicates that the
daily demand for interior paint cannot exceed that of exterior
paint by more than one ton. Also maximum daily demand for
interior paint is two tons.
Reddy Mikks wants to determine the optimum (best)
product mix of interior and exterior paints that maximizes the
total daily profit.
6. Unit V : Linear Programming
Introduction :
OR Models contd …:
Example -4 : Formulation of the problem as LP Model
A firm manufactures two types of products A and B,
and sells them at a profit of Rs. 2 on type A and Rs. 3 on type
B. Each product is processed on two machines G and H. Type
A requires 1 minute of processing time on machine G and 2
minutes on machine H. Type B requires 1 minute on both G
and H. The machine G is available for not more than 6 hours
and 40 minutes while machine H is available for 10 hours
during any working day. Formulate LP model to maximize
daily profit.
7. Unit V : Linear Programming
Introduction :
OR Models contd …:
Example -4 contd,,,: Formulation of the problem as LP Model
Linear Program (Mathematical Model or OR Model)
Maximize z = 2x1 + 3x2 (Type A = x1and Type B =x2)
Subject to x1 + x2 ≤ 400
2x1 + x2 ≤ 600
x1 , x2 ≥ 0
Description
Time
required in
Minutes for
products
Max.
Available
time in
Minutes per
day
Product A Product B
Processing time on G 1 1 400
Processing time on H 2 1 600
Profit per piece 2 3
8. Unit V : Linear Programming
Introduction :
OR Models contd …:
Example-5 : Political Problem :
Suppose that you are a politician trying to win an
election. Your district has three different area types – Urban,
Seburban, and Rural. These areas have registered voters
100000, 200000, and 50000 respectively. Although not all the
registered voters actually go to the polls, you decide that to
govern effectively, you would like at least half the registered
voters in each of these three regions to vote for you. You are
honorable and would never consider supporting policies in
which you do not believe. You realize, however, that certain
issues may be more effective in winning votes in certain
places. Your primary issues are building more roads, 24 hours
9. Unit V : Linear Programming
Introduction :
OR Models contd …:
Example-5 contd… : Political Problem :
Linear Program (Mathematical Model or OR Model)
Minimize x1 + x2+ x3+ x4
Subject to 2x1+ 8x2+ 0x3+10x4 ≥ 50
5x1+ 2x2+ 0x3+ 0x4 ≥ 100
3x1 - 5x2+ 10x3- 2x4 ≥ 25
x1, x1, x1, x1≥ 0
Policy
Votes in thousands
per lakh INR spent
Urban Sub-urban Rural
Build Roads -2 5 3
24 hour water supply 8 2 -5
Farm subsidies 0 0 10
LBT Tax 10 0 -2
10. Unit V : Linear Programming
Introduction :
General Linear Programs :
•In the general linear programming problem, we wish to optimize a
linear function subject to a set of linear inequalities.
•Given a set of real numbers a1, a2, … an and a set of variables
x1, x2, … , xn we define a linear function f on those variables by:
f (x1, x2, … , xn) = a1x1+ a2x2+ … + anxn = Σ ajxj
1<= j<= n
•If b is a real number and f is a linear function, then,
f (x1, x2, … , xn) = b is a linear equality and
f (x1, x2, … , xn) ≥ b or
f (x1, x2, … , xn) ≤ b are the linear inequalities
•We shall use the general term linear constraints to denote either
linear equalities or linear inequalities
•In linear programming strict inequalities are not allowed i.e.
11. Unit V : Linear Programming
Introduction :
General Linear Programs contd… :
•Formally, a linear-programming problem is the problem of either
minimizing or maximizing a linear function subject to a finite set of
linear constraints.
•If we are to minimize, then we call the linear program a
minimization linear program and if we are to maximize, then we
call the linear program a maximization linear program.
Applications of linear programming:
•Political problem (Elections)
•Optimal Product Mix in Manufacturing
•Airline Schedule of flights
•Oil company – where to drill ?
•Graph problems – Single source shortest path, vertex cover problem,
maximum flow problem
12. Unit V : Linear Programming
Introduction :
Algorithms for linear programming :
•Simplex Algorithm : Often solves general linear programs
quickly in practice in polynomial time, however it may need
exponential time for some problem instances. The algorithm moves
along the exterior of the feasible region and maintains a feasible
solution that is a vertex of the simplex at each iteration.
•Ellipsoid Algorithm : The first polynomial-time algorithm for
linear programming which runs slowly in practice.
•Interior Point Methods : These are also a polynomial-time
algorithm s which move through the interior of the feasible region,
but the final solution is a vertex. For large inputs, interior point
algorithms can run as fast as and sometimes faster than the simplex
algorithm.
•Integer linear program : If we add to a linear program the
13. Unit V : Linear Programming
Introduction :
Standard and Slack forms :
•Standard and Slack form are useful when we specify and work
with linear programs. In standard form, all the constraints are
inequalities, whereas in slack form, all constaints are equalities.
Standard Form :
In standard form, we are given n real numbers c1, c2, … , cn;
m real numbers b1, b2, … , bm and mn real numbers aij for i = 1,2,
… m and j = 1,2, … , n. We wish to find n real numbers x1, x2,
… , xn that
maximize Σ cjxj
… (1) 1<= j<= n
subject to Σ aijxj ≤ bi
… (2)
1<= i<= n
14. Unit V : Linear Programming
Introduction :
Terminology used in Linear Programs:
•Feasible solution : A setting of the variables x- that satisfies all
the constraints. Whereas A setting of the variables x- that fails to
satisfy at least one constraint is an infeasible solution.
•Objective value : A solution x- (feasible) has objective value cTx-.
•Optimal solution : A feasible solution x- whose objective value is
maximum over all feasible solutions is an optimal solution.
•Infeasible linear program: If a linear program has no feasible
solutions, then the linear program is infeasible, otherwise it is feasible.
•Unbounded linear program : If a linear program has some feasible
solutions but does not have a finite optimal value then the linear program
is unbounded. However a linear program can have finite optimal
objective value even if the feasible region is not bounded.
15. Unit V : Linear Programming
Converting linear programs into standard form:
•It is always possible to convert a linear program given as
minimizing or maximizing a linear function subject to linear
constraints, into a standard form. A linear program might not
be in standard form for any of the following four possible
reasons.
1.The objective function might be minimization rather
than maximization.
2.There might be variables without non-negativity
constraints.
3.There might be constraints with equal sign rather
than ≤ sign.
4.There might be inequality constraints but instead of
having ≤ sign, they have a ≥ sign. Example
16. Unit V : Linear Programming
Converting linear programs into standard form:
Equivalent linear programs :
•Two maximization linear programs L and L’ are equivalent if
for each feasible solution x- to L with objective value z, there
is a corresponding feasible solution x-’ to L’ with objective
value z, and for each feasible solution x-’ to L’ with objective
value z, there is a corresponding solution x- to L with objective
value z.
•A minimization linear program L and a maximization linear
program L’ are equivalent if for each feasible solution x- to L
with objective value z, there is a corresponding feasible
solution x-’ to L’ with objective value –z and for each feasible
solution x-’ to L’, with objective value z, there is a
corresponding feasible solution x- to L with objective value –z.
17. Unit V : Linear Programming
Converting linear programs into standard form:
Example
Reduce the following linear program to standard form :
minimize - 2 x1 + 3x2
subject to x1 + x2 = 7
x1 - 2x2 ≤ 4
x1 ≥ 0
Solution : Linear program in Standard form
maximize 2 x1 - 3x2’ + 3x2”
subject to x1 + x2’ - x2” ≤ 7
- x1 - x2’ + x2” ≥ -
7
x1 - 2x2’ + 2x2” ≤ 4
18. Unit V : Linear Programming
Converting linear programs into standard form:
Example
Solution contd …:
The final solution can be written as :
maximize 2 x1 - 3x2 + 3x3
subject to x1 + x2 - x3 ≤ 7
- x1 - x2 + x3 ≥ - 7
x1 - 2x2 + 2x3 ≤ 4
x1, x2 , x3 ≥ 0
19. Unit V : Linear Programming
Converting linear programs into slack form:
•To efficiently solve a linear program with the simplex
algorithm, we prefer to express it in a form in which some of
the constraints are equality constraints.
•More precisely, we shall convert it into a form in which the
non-negativity constraints are the only inequality constraints
and the remaining constraints are equalities.
•Let Σ aijxj ≤ bi … (1)
1<= i<= n
be an inequality constraint. We introduce a new variable
s and rewrite inequality as the two constraints
s = bi - Σ aijxj … (2)
1<= i<= n
s ≥ 0 … (3)
20. Unit V : Linear Programming
Converting linear programs into slack form:
•We call s as a slack variable because it measures the slack or
difference between the LHS and RHS of equation (1). It is
convenient to write slack variable on the LHS.
•We can convert each inequality constraint of a linear program
in this way to obtain an equivalent linear program in which the
only inequality constraints are the non-negativity constraints.
•While converting standard form to slack form , we shall use
xn+i (instead of s) to denote the slack variableassociated with
the ith inequality. The ith constraint is therefore,
xn+i = bi - Σ aijxj and
1<= i<= n
xn+i ≥ 0
21. Unit V : Linear Programming
Converting linear programs into slack form:
Example in standard form explained above when
converted into slack form would be,
maximize 2 x1 - 3x2 + 3x3
subject to x4 = 7 - x1 - x2 + x3
x5 = -7 + x1 + x2 - x3
x6 = 4 - x1 + 2x2 - 2x3
x1, x2 , x3, x4, x5 , x6 ≥ 0
•We call the variables on the LHS of the equalities as Basic
Variables and those on the RHS as the Non-basic Variables.
•For linear programs that satisfy these conditions, we shall omit the
words “maximize” and “subject to” as well as the explicit non-
22. Unit V : Linear Programming
Converting linear programs into slack form:
•The resulting form is called as slack form.
z = 2x1 - 3x2 + 3x3
x4 = 7 - x1 - x2 + x3
x5 = -7 + x1 + x2 - x3
x6 = 4 - x1 + 2x2 - 2x3
23. Unit V : Linear Programming
Converting linear programs into slack form:
•The slack form in general is :
z = v + Σ cjxj
1<= j<= n
xi = bi - Σ aijxj for i ε B
j ε N
where N = set of non-basic variables index
B = set of basic variables index
A = set of coefficients of non-basic variables
bi = RHS value of ith constraint
b = set of values of RHS of constraints
c = set of coefficients of objective function
v = optimal constant term which makes it
easy to
determine value of objective function.
n
24. Unit V : Linear Programming
Converting linear programs into slack form:
•Slack form tuple (N, B, A, b, c, v) for the above example is :
N = {1, 2, 3}
B = {4, 5, 6}
| 1 1 -1| | 7 |
A = |-1 -1 1| b = |-7|
| 1 - 2 2| | 4|
c = (2, -3, 3)T
v = 0
n
25. Unit V : Linear Programming
Simplex Algorithm :
•The simplex algorithm is the classical method for solving
linear programs. It’s running time is not polynomial in the
worst case, but it is often remarkably fast in practice.
•Similar to Gaussian elimination used to solve simultaneous
equations, the simplex algorithm as well use Gaussian
elimination for inequalities.
An iteration of the simplex algorithm :
•Associated with each iteration there will be a “basic solution”
that we can obtain from the slack form of the linear program.
•An iteration converts one slack form into an equivalent slack
form.
n
26. Unit V : Linear Programming
Simplex Algorithm :
An iteration of the simplex algorithm contd…:
•The objective value of the associated basic feasible solution
will be no less than that at the previous iteration. Objective
value of basic solution can easily be obtained by setting each
non-basic variable to 0.
•To achieve this increase in the objective value, we choose a
non-basic variable such that if we increase that variable value
from 0, then the objective value would also increase.
•The amount by which we can increase the variable is limited
by the other constraints. In particular we raise it until some
basic variable becomes 0.
•Rewrite the slack form, exchanging the roles of that basic
variable and the chosen non-basic variable.
n
27. Unit V : Linear Programming
Simplex Algorithm :
An example of the simplex algorithm :
Consider the following linear program in standard
form:
maximize 3x1 + x2 + 2x3 …
(1)
subject to x1 + x2 + 3x3 ≤ 30 …
(2)
2x1 + 2x2 + 5x3 ≤ 24 …
(3)
4x1 + x2 + 2x3 ≤ 36 …
(4)
x1, x2, x3 ≥ 0 …
(5)
n
28. Unit V : Linear Programming
Simplex Algorithm :
Pivoting : We can formulate the procedure for pivoting which
is used in each iteration of the simplex algorithm.
Procedure pivot (N, B, A, b, c, l, e)
// input is a linear program in slack form, entering variable and
// leaving variable.
1.Compute the coefficients of the equation for the new basic
variable i.e. for the entering variable xe, using tight constraint
equation of the leaving variable xl.
2.Compute the coefficients of the remaining constraints by
replacing the values of xe, i.e. get A^ and b^.
3.Compute the objective function by replacing value of xe &
get c^ and v^ modified.
4.Compute new sets of basic and non-basic variables
n
29. Unit V : Linear Programming
Simplex Algorithm :
The formal Simplex Algorithm :
Algorithm SIMPLEX(A, b, c)
// Input is a linear program in standard form. The procedure
// INITIALIZE-SIMPLEX checks whether input linear
program // is feasible & if so, it finds it’s slack form
& returns.
1.(N, B, A, b, c, v) = INITIALIZE-SIMPLEX(A, b, c)
2.Choose entering variable (xe ) having positive coefficient in
objective function.
3.Find the leaving variable (xl) corresponding to entering
variable using tight constraint.
4.If xl is ∞, for all the constraints then the linear program is
“unbounded” otherwise proceed.
n
30. Unit V : Linear Programming
Simplex Algorithm :
The formal Simplex Algorithm :
Algorithm SIMPLEX(A, b, c)
7. Compute & return the basic solution :
for i = 1 to n do
if i Є B
x-
i = bi
else x-
i= 0
return (x-
1, x-
2, …, x-
i)
n
31. Unit V : Linear Programming
Simplex Algorithm :
Duality :
•We have seen how to solve optimization programming using
simplex algorithm. But we do not know whether it finds
actually optimal solution to a linear problem. i.e. we have not
proved that simplex algorithm finds an optimal solution to a
linear program.
•In order to do so, we shall use a powerful concept called as
“linear-programming duality”.
•Duality enables us to prove that a solution is indeed optimal.
•Given a linear program, in which the objective is to
maximize, we shall describe how to formulate a dual linear
program in which the objective is to minimize and whose
optimal value is identical to that of the original problem.
n
32. Unit V : Linear Programming
Simplex Algorithm :
Duality : Dual form of a given primal linear program :
•Given a linear program (primal) in standard form
maximize Σ cjxj
… (1) 1<= j<= n
subject to Σ aijxj ≤ bi for i = 1, 2, …,m
… (2)
1<= i<= n
xj ≥ 0 for j = 1, 2, …,n
… (3)
•We define the dual linear program as :
minimize Σ biyi
… (4) 1<= i<= m
subject to Σ aijyi ≥ cj for j = 1, 2, …,n
n
33. Unit V : Linear Programming
Simplex Algorithm :
Duality : Dual form of a given primal linear program :
•Given a linear program (primal) in standard form
maximize 3x1 + x2 + 2x3 …
(1)
subject to x1 + x2 + 3x3 ≤ 30 …
(2)
2x1 + 2x2 + 5x3 ≤ 24 …
(3)
4x1 + x2 + 2x3 ≤ 36 …
(4)
x1, x2, x3 ≥ 0 …
(5)
•We define the dual linear program as :
n
34. Unit V : Linear Programming
Simplex Algorithm :
Duality :
Following are the steps to get a dual of a given primal:
1.Change maximization in primal to minimization in
dual.
2.Change the roles of coefficients on the RHS of
constraints and the coefficients in objective function.
3.Replace each inequality ≤ sign in primal by ≥ sign in
dual.
4.Each of the m constraints in primal has an associated
variable yi in dual.
5.Each of the n constraints in dual has an associated
variable xj in primal.
Example – Graphical Method
n
35. Unit V : Linear Programming
Simplex Algorithm :
The initial basic feasible solution :
•The INITIALIZE-SIMPLEX first checks
whether a linear program is feasible and if
it is it produces a slack form for which the
basic solution is feasible. This ensures that
the simplex procedure always produces the
correct result.
•A linear program may be feasible, yet the
initial basic solution might not be feasible.
n
36. Unit V : Linear Programming
Simplex Algorithm :
The initial basic feasible solution contd….:
•In order to determine whether a linear program has any feasible
solutions, we will formulate an auxiliary linear program. For this
auxiliary linear program we can find a slack form for which the
basic solution is feasible. Furthermore, the solution of his auxiliary
linear program determines whether the initial linear program is
feasible and if so, it provides a feasible solution with which we can
initialize SIMPLEX.
Example : For the linear program represented by inequalities (1) to
(4). This linear program is feasible if we can find non-negative
values for x1 and x2 such that inequalities (2) and (3) are satisfied.
n
37. Unit V : Linear Programming
Simplex Algorithm :
The initial basic feasible solution contd….:
Example contd….:
•The auxiliary linear program is (Laux) :
maximize - x0 … (1)
subject to 2x1 - x2 - x0 ≤ 2 … (2)
x1 - 5x2 - x0 ≤ -4 … (3)
x1, x2, x0 ≥ 0 … (4)
•Laux in slack form would be :
z = - x0
x3 = 2 - 2x1 + x2 + x0
x4 = - 4 - x1 + 5x2 + x0
In this program the basic solution would set x4 = - 4,
which is not feasible.
n
38. Unit V : Linear Programming
Simplex Algorithm :
The initial basic feasible solution contd….:
Example contd….:
•We can convert this slack form into one which is feasible by
giving one call to PIVOT. Let x0 be an entering variable and
x4 be a leaving variable, then we get :
z = - 4 - x1 + 5x2 - x4
x0 = 4 + x1 - 5x2 + x4
x3 = 6 - x1 - 4x2 + x4
The associated basic solution is
(x -
0, x -
1, x -
2, x -
3, x -
4) = (4, 0, 0, 6, 0) which is
feasible.
•We now repeatedly call PIVOT until we obtain an optimal
solution to Laux .
39. Unit V : Linear Programming
Simplex Algorithm :
The initial basic feasible solution contd….:
Example contd….:
•In this case one call to PIVOT with entering variable x2 and
leaving variable x0 we get
z = - x0
x2 = 4/5 - x0 /5 + x1/5 + x4/5
x3 = 14/5 + 4 x0 /5 - 9x1/5 + x4/5
The associated basic solution is
(x -
0, x -
1, x -
2, x -
3, x -
4) = (4, 0, 0, 6, 0) which is
feasible.
This slack form is the final solution to Laux .
•If x0 is basic variable perform one (degenerate) PIVOT to
make it non-basic.
40. Unit V : Linear Programming
Simplex Algorithm :
The initial basic feasible solution contd….:
Example contd….:
•Now since x0 = 0, we can remove it from the set of
constraints. We then restore the original objective function
with appropriate substitutions made to include only non-basic
variables, we get
z = - 4/5 + 9x1/5 - x4/5
x2 = 4/5 + x1/5 + x4/5
x3 = 14/5 - 9x1/5 + x4/5
•This slack form has a feasible basic solution and we can
return it to procedure SIMPLEX.
41. Unit V : Linear Programming
Simplex Algorithm :
The initial basic feasible solution contd….:
Algorithm
Algorithm INITIAL-SIMPLEX (A, b, c)
1.Let k be the index of the minimum bi
2.If bk ≥ 0
return ({1, 2, …, n}, {n+1,n+2, …, n+m},
A, b, c, 0)
1.form Laux by adding x0 to LHS of each constraint
and set the objective function to –x0
2.let (N, B, A, b, c, v) be the resulting slack form for
Laux
42. Unit V : Linear Programming
Simplex Algorithm :
The initial basic feasible solution contd….: Algorithm
Algorithm INITIAL-SIMPLEX (A, b, c) contd…
1.if the optimal solution to Laux sets to x-
0 = 0
if x0 is basic
perform one (degenerate) PIVOT to make
x0 non-basic
form the final slack form of Laux , remove x0
from the constraints and restore the original
objective function of L, but replace each basic
variable in this objective function by the RHS of its
associated constraint
return the modified final slack form (N, B, A, b,
c, v)
43. Unit V : Linear Programming
Examples of Linear programming: Problem formulations
Now we shall examine how linear programming can be used
to solve the following problem :
1.Single Source Shortest Path Problem (A Graph
problem)
2.Maximum Flow Problem (A Network problem)
3.Vertex Cover problem (A Graph problem)
4.0/1 Knapsack problem : (A combinatorial
Problem)