Operations Research 2013/2014

advertisement
Solving linear programming problems
Graphical method
Simplex algorithm
Graphical method
The graphical method of solving linear programming problems can be
applied to models with two decision variables. This method consists
of two steps (see also the first lecture):
1
Draw the set of feasible solutions (a feasibility region) on the
plane.
2
Draw the objective function for z = 0 and move it parallel up
(for max) and down (for min) until it touches the set of feasible
solutions.
Michał Kulej
Operations Research 2013/2014
Solving linear programming problems
Graphical method
Simplex algorithm
An unique solution
A problem may have exactly one optimal solution, which is located in
a corner of the feasibility region.
max z =
Michał Kulej
5x1 + 4x2
6x1 + 4x2 ≤ 24
x1 + 2x2 ≤ 6
x2 − x1 ≤ 1
x2 ≤ 2
x1 , x2 ≥ 0
Operations Research 2013/2014
Graphical method
Simplex algorithm
Solving linear programming problems
Infinite number of solutions
A problem may have infinite number of optimal solutions located on a
segment joining two corner points.
max z =
Michał Kulej
2x1 + 4x2
6x1 + 4x2 ≤ 24
x1 + 2x2 ≤ 6
x2 − x1 ≤ 1
x2 ≤ 2
x1 , x2 ≥ 0
Operations Research 2013/2014
Solving linear programming problems
Graphical method
Simplex algorithm
Unbounded objective function
The objective function of a problem may be unbounded.
max z =
Michał Kulej
2x1 + 2x2
2x1 − x2 ≤ 40
x2 ≥ 10
x1 , x2 ≥ 0
Operations Research 2013/2014
Solving linear programming problems
Graphical method
Simplex algorithm
No solution
A problem may be infeasible. This happens when the constraints are
contradictory.
max z =
Michał Kulej
3x1 + 2x2
6x1 + 4x2 ≤ 12
x1 ≥ 3
x2 ≥ 2
Operations Research 2013/2014
Solving linear programming problems
Graphical method
Simplex algorithm
Conclusions (2-varaiable case)
1
The feasibility region is a convex polyhedron (bounded or unbounded).
2
If a problem has an optimal solution, then at least one optimal solution is
located in a corner of the feasibility region.
3
If the objective function is unbounded or the problem is infeasible, then
the model is not well defined. In the first case some constraints are missing and in the second case the constraints are contradictory. Perhaps,
the model does not describe the real problem correctly.
Michał Kulej
Operations Research 2013/2014
Solving linear programming problems
Graphical method
Simplex algorithm
Model in standard form
A model is in a standard form if
1
all the constraints are equalities (with the exception of the nonnegativity
of the variables),
2
all the right hand sides are nonnegative and
3
all the variables can take only nonnegative values.
max (min) z =
c1 x1 + c2 x2 + · · · + cn xn
a11 x1 + a12 x2 + · · · + a1n xn = b1
a21 x1 + a22 x2 + · · · + a2n xn = b2
...
am1 x1 + am2 x2 + · · · + amn xn = bm
xi ≥ 0, i = 1, . . . , n
[Obj. function]
[Constraint 1]
[Constraint 2]
...
[Constraint m]
[Non. constr.]
Every linear programming model can be transformed into the standard form.
Michał Kulej
Operations Research 2013/2014
Solving linear programming problems
Graphical method
Simplex algorithm
Model in standard form
Transform the following model into the standard form:
max z =
2x1 + 3x2 − x3
x1 − 2x2 ≤ 5
−x2 − 3x3 ≤ −3
x1 + x2 − 2x3 = 20
x1 , x2 ≥ 0
Michał Kulej
Operations Research 2013/2014
Solving linear programming problems
Graphical method
Simplex algorithm
Model in standard form
Step 1. Multiply the second constraint by -1.
max z =
2x1 + 3x2 − x3
x1 − 2x2 ≤ 5
x2 + 3x3 ≥ 3
x1 + x2 − 2x3 = 20
x1 , x2 ≥ 0
Step 2. Add nonnegative slack variables s1 and s2 to the first and
second constraint.
max z =
2x1 + 3x2 − x3
x1 − 2x2 + s1 = 5
x2 + 3x3 − s2 = 3
x1 + x2 − 2x3 = 20
x1 , x2 , s1 , s2 ≥ 0
Michał Kulej
Operations Research 2013/2014
Solving linear programming problems
Graphical method
Simplex algorithm
Model in standard form
Step 3. Substitute x3 = u3 − v3 , where u3 and v3 are new nonnegative
variables.
max z =
2x1 + 3x2 − u3 + v3
x1 − 2x2 + s1 = 5
x2 + 3u3 − 3v3 − s2 = 3
x1 + x2 − 2u3 + 2v3 = 20
x1 , x2 , s1 , s2 , u3 , v3 ≥ 0
We get an equivalent model, which is in the standard form.
Michał Kulej
Operations Research 2013/2014
Solving linear programming problems
Graphical method
Simplex algorithm
Basic solutions
In a set of m equations with n variables (m < n), if we set n − m
variables equal to 0, then we obtain a system of m linear equations
with m variables (called basic variables). If this system has an unique
solution, then it is called a basic solution.
A basic solution is feasible if all its variables take nonnegative values.
In the 2-variable case, the set of feasible basic solutions corresponds
to the set of corner points of the feasibility region.
Michał Kulej
Operations Research 2013/2014
Solving linear programming problems
Graphical method
Simplex algorithm
Basic solutions
max z =
2x1 + 3x2
2x1 + x2 ≤ 4
x1 + 2x2 ≤ 5
x1 , x2 ≥ 0
Michał Kulej
max z =
2x1 + 3x2
2x1 + x2 + s1 = 4
x1 + 2x2 + s2 = 5
x1 , x2 , s1 , s2 ≥ 0
Operations Research 2013/2014
Solving linear programming problems
Graphical method
Simplex algorithm
Basic solutions
If a linear programming problem has an optimal solution, then it also
has a basic feasible solution which is optimal.
A number of basic feasible solutions is finite, so in principle we could
enumerate all of them and choose the one which minimizes (maximizes) the objective function. However, this method is very slow and fails
when the objective function is unbounded (why?).
The simplex algorithm is a procedure which locates the optimal basic
feasible solution in an efficient manner.
Michał Kulej
Operations Research 2013/2014
Solving linear programming problems
Graphical method
Simplex algorithm
Simplex algorithm
Step 1. Convert the objective function and constraints into the following form:
z
−2x1
2x1
x1
−3x2
+x2
+2x2
=0
=4
=5
+s1
+s2
The above problem is in a basis form with respect to the basis (s1 , s2 ). Notice
that s1 and s2 do not appear in the first equation which corresponds to the objective function. The problem can also be represented as the following starting
simplex tableau:
z
s1
s2
x1
-2
2
1
x2
-3
1
2
Michał Kulej
s1
0
1
0
s2
0
0
1
0
4
5
Operations Research 2013/2014
Solving linear programming problems
Graphical method
Simplex algorithm
Simplex algorithm
Remarks:
1
The numbers in the z-row are called optimality coefficients or reduced costs.
2
All the basic variables must have the optimality coefficients equal
to 0.
3
For the nonbasic variables two cases are possible:
1
2
Some variable has a negative optimality coefficient. Then it
is possible to increase the value of the objective function by
making the value of the variable positive.
All the nonbasic variables have nonnegative optimality coefficients, in which case the current basic solution is optimal.
Michał Kulej
Operations Research 2013/2014
Solving linear programming problems
Graphical method
Simplex algorithm
Simplex algorithm
Step 2. Perform an iteration (Gauss-Jordan elimination) by inserting x2 into
the basis and removing s2 from the basis.
z
s1
s2
x1
-2
2
1
x2
-3
1
2
s1
0
1
0
s2
0
0
1
0
4 (4/1)
5 (5/2)
z
s1
x2
x1
-0.5
1.5
0.5
x2
0
0
1
s1
0
1
0
s2
1.5
-0.5
0.5
7.5
1.5
2.5
The nonbasic variable x2 has the negative coefficient in the z-row. Hence increasing the
value of x2 will increase the value of the objective function z. The maximal value of x2
is equal to min{4/1, 5/2} = 2.5. After increasing x2 to 2.5 the value of s2 falls to 0. So,
the variable s2 leaves the basis. The second basis form is:
z
−0.5x1
1.5x1
0.5x1
+1.5s2
−0.5s2
+0.5s2
Michał Kulej
+s1
+x2
= 7.5
= 1.5
= 2.5
Operations Research 2013/2014
Solving linear programming problems
Graphical method
Simplex algorithm
Simplex algorithm
Step 3. Perform an iteration (Gauss-Jordan elimination) by inserting x1 into
the basis and removing s1 from the basis.
z
s1
x2
x1
-0.5
1.5
0.5
x2
0
0
1
s1
0
1
0
s2
1.5
-0.5
0.5
7.5
1.5 (1.5/1.5)
2.5 (2.5/0.5)
z
x1
x2
x1
0
1
0
x2
0
0
1
s1
1/3
2/3
-1/3
s2
4/3
-1/3
2/3
The nonbasic variable x1 has the smallest negative coefficient in the z-row. Hence
increasing the value of x1 will increase the value of the objective function z. The maximal
value of x1 is equal to min{2.5/2.5, 2.5/0.5} = 1. After increasing x1 to 1 the value of
s1 falls to 0. So, the variable s1 leaves the basis. The second basis form is:
z
1/3s1
2/3s1
−1/3s1
+4/3s2
−1/3s2
+2/3s2
Michał Kulej
+x1
+x2
=8
=1
=2
Operations Research 2013/2014
8
1
2
Solving linear programming problems
Graphical method
Simplex algorithm
Simplex algorithm
z
x1
x2
x1
0
1
0
x2
0
0
1
s1
1/3
2/3
-1/3
s2
4/3
-1/3
2/3
8
1
2
The last table represents an optimal solution x1 = 1, x2 = 2 with the maximal
value of the objective function equal to 8.
Michał Kulej
Operations Research 2013/2014
Solving linear programming problems
Graphical method
Simplex algorithm
Simplex algorithm
Exercise
Solve the Reddy Mikks model (first lecture) using the simplex algorithm. First
transform the model into the standard form. As a result we get the first basis
form:
z
−5x1 − 4x2
6x1 + 4x2
x1 + 2x2
−x1 + x2
x2
x1 , x2 ,
+s1
+s2
+s3
s1 ,
Michał Kulej
s2 ,
s3 ,
+s4
s4
=0
= 24
=6
=1
=2
≥0
Operations Research 2013/2014
Graphical method
Simplex algorithm
Solving linear programming problems
Simplex algorithm
z
s1
s2
s3
s4
z
x1
s2
s3
s4
x1
-5
6
1
-1
0
x1
0
1
0
0
0
x2
-4
4
2
1
1
x2
-2/3
2/3
4/3
5/3
1
s1
0
1
0
0
0
s1
5/6
1/6
-1/6
1/6
0
Michał Kulej
s2
0
0
1
0
0
s3
0
0
0
1
0
s2
0
0
1
0
0
s3
0
0
0
1
0
s4
0
0
0
0
1
s4
0
0
0
0
1
0
24 (24/6)
6 (6/1)
1 (-)
2 (-)
20
4 (4*3/2)
2 (2*3/4)
5 (5*3/5)
2 (2/1)
Operations Research 2013/2014
Solving linear programming problems
Graphical method
Simplex algorithm
Simplex algorithm
z
x1
x2
s3
s4
x1
0
1
0
0
0
x2
0
0
1
0
0
s1
0
1/4
-1/8
3/8
1/8
Michał Kulej
s2
3/4
-1/2
3/4
-5/4
-3/4
s3
1/2
0
0
1
0
s4
0
0
0
0
1
21
3
3/2
5/2
1/2
Operations Research 2013/2014
Solving linear programming problems
Graphical method
Simplex algorithm
Simplex algorithm
If the objective function should be minimized, we can multiply it by -1 and then
maximize.
Before the simplex algorithm starts we should represent the problem in a basic
form. This is easy when all the constraints have the form of ≤ with nonnegative
right hand sides. In this case the additional slack variables form the first basis.
Otherwise and additional procedure should be used.
Michał Kulej
Operations Research 2013/2014
Solving linear programming problems
Graphical method
Simplex algorithm
Artificial base method
Consider the following example:
max z =
−4x1 − 3x2
3x1 + x2 = 3
4x1 + 3x2 ≥ 6
x1 + 2x2 ≤ 4
x1 , x2 ≥ 0
Step 1. Convert the problem to the standard form:
max z =
−4x1 − 3x2
3x1 + x2 = 3
4x1 + 3x2 − s1 = 6
x1 + 2x2 + s2 = 4
x1 , x2 , s1 , s2 ≥ 0
Michał Kulej
Operations Research 2013/2014
Solving linear programming problems
Graphical method
Simplex algorithm
Artificial base method
Step 2. Add additional variables r1 and r2 and change the objective function.
max z =
−4x1 − 3x2 − 100r1 − 100r2
3x1 + x2 + r1 = 3
4x1 + 3x2 − s1 + r2 = 6
x1 + 2x2 + s2 = 4
x1 , x2 , s1 , s2 , r1 , r2 ≥ 0
Remark: We should multiply the artificial variables with a suitably large constant so that their values in every optimal solution are 0.
Step 3. Obtain a basic form by eliminating r1 and r2 from the objective function.
z
−696x1 − 399x2 + 100s1
3x1 + x2
4x1 + 3x2 − s1
x1 + 2x2 +
+r1
+r2
+s2
= −900
=3
=6
=4
Step 4. Apply the simplex algorithm to solve the problem.
Michał Kulej
Operations Research 2013/2014
Solving linear programming problems
Graphical method
Simplex algorithm
Artificial base method
If the value of some artificial variable in the optimal solution is positive, then
the original problem is infeasible.
In commercial packages, typically a different method of obtaining the first base
is used. This method is called a two-phase method and its description can be
found in the literature.
Michał Kulej
Operations Research 2013/2014
Solving linear programming problems
Graphical method
Simplex algorithm
Alternative optima
z
x2
x1
x1
0
0
1
x2
0
1
0
s1
2
1
-1
s2
0
-1
2
10
1
3
Michał Kulej
z
x2
s2
x1
0
1/2
1/2
x2
0
1
0
s1
2
1/2
-1/2
Operations Research 2013/2014
s2
0
0
1
10
2.5
1.5
Solving linear programming problems
Graphical method
Simplex algorithm
Alternative optima
If in the last (optimal) simplex tableu, some nonbasic variable has the optimality coefficient equal to 0, then we can obtain an alternative optimum by
performing additional iteration in which we insert this variable into the basis.
If (x1 , . . . , xn ) and (y1 , . . . , yn ) are two different optimal solutions, then each
solution of the form
(λx1 + (1 − λ)y1 , . . . , λxn + (1 − λ)yn ), λ ∈ [0, 1]
is also optimal. Hence in this case, the number of optimal solutions is infinite.
Michał Kulej
Operations Research 2013/2014
Solving linear programming problems
Graphical method
Simplex algorithm
Unbounded objective function
z
s1
s2
x1
-2
1
2
x2
-1
-1
0
Michał Kulej
s1
0
1
0
s2
0
0
1
0
10 (-)
40 (-)
Operations Research 2013/2014
Solving linear programming problems
Graphical method
Simplex algorithm
Unbounded objective function
If in some simplex tableu, there exists a variable with a negative optimality coefficient and all the constraint coefficients in this variable’s
column are negative or zero then the objective function is unbounded.
If the objective function is unbounded, then the model is not well defined. Perhaps, some constraints of the model are missing.
Michał Kulej
Operations Research 2013/2014
Solving linear programming problems
Graphical method
Simplex algorithm
Degenerate solutions
Consider the following problem:
max z =
3x1 + 9x2
x1 + 4x2 ≤ 8
x1 + 2x2 ≥ 4
x1 , x2 ≥ 0
The second simplex tableu is the following:
z
x2
s2
x1
-3/4
1/4
1/2
x2
0
1
0
s1
9/4
1/4
-1/2
s2
0
0
1
18
2 (2*4)
0 (0*2)
In the basis solution, the basic variable s2 = 0. Such a solution is called degenerate. After performing the next iteration, the value of the objective function
will not increase.
Michał Kulej
Operations Research 2013/2014
Solving linear programming problems
Graphical method
Simplex algorithm
Degenerate solutions
The last simplex tableu is the following:
z
x2
x1
x1
0
0
1
x2
0
1
0
s1
3/2
1/2
-1
s2
3/2
-1/2
2
18
2
0
It is possible (in very rare situations) for the simplex method to enter a repetitive sequence of iterations never improving the objective value and never
satisfying the optimality conditions (it is called cycling). However, there exist
some technical modifications of the simplex method which allow us to avoid
such a bad behavior (see the literature).
Michał Kulej
Operations Research 2013/2014
Download