Vous êtes sur la page 1sur 4

big−m.

nb 1

big M method
Johan G. F. Belinfante
presented in class: 2007 April 20

summary
The example in section 4.1 (pages 25−28) of the lp.pdf handout is worked out here using Mathematica.

elementary row operations


The following functions make it easy to do elementary row operations

In[1]:= rowexch@i_, j_D := Function@A, A . 8A@@iDD ® A@@jDD, A@@jDD ® A@@iDD<D

In[2]:= rowmul@m_, i_D := Function@A, HA . A@@iDD ® m A@@iDDLD

In[3]:= rowadd@m_, i_, j_D := Function@A, A . A@@jDD ® A@@jDD + m A@@iDDD

artificial variables
The objective function involves three variables x1, x2, x3, making it difficult (although not impossible) to use the geomet−
ric method. The feasible set for this problem is specified by one equation and one inequality, neither of which is satisfied at
the origin. So the origin is not a feasible point, and one needs to do something about it. As usual, slack variables are used
to convert linear inequalities to equations. In this case, there is only one inequality and therefore only one slack variable is
needed, called s below. Each of the resulting equations is tested to see whether they can be satisfied at the origin. For each
of those that can not be satisfied at the origin, an artificial variable is introduced with coefficient +1 or −1 so that the
modified equation can be satisfied at the origin with a positive value for the artificial variable.

Specifically, since the equation x1 + x2 + x3 = 7 is not satisfied when x1 = x2 = x3 = 0, one adds a term +r1 on the left.
The resulting equation,

x1 + x2 + x3 + r1 = 7

can be satisfied at the origin by setting r1 = 7, which is positive. The original inequality constraint 2 x1 − 5 x2 + x3 ³ 10 is
converted by introducing a slack variable s into the equation 2 x1 − 5 x2 + x3 − s = 10. At the origin, it becomes −s = 10,
which cannot be satisfied for non−negative s. By adding a term +r2 on the left side, the resulting equation can be satisfied
with all variables equal to 0. Penalty terms − M r1 − M r2 are added to the objective function to encourage movement
away from the origin toward points where r1 = r2 = 0. For those points all the modified equations reduce to those of the
original problem. Once one is at such a point, the artificial variables play no further role, and one could simply omit the
columns involving artificial variables from the tableaux from there on.
big−m.nb 2

simplex algorithm
For this linear programming problem, the initial tableau is not simple.

88x1, x2, x3, r1, r2, s, z,


In[4]:= initialtableau =

8 1, 1, 1, 1, 0, 0, 0,
"#"<,

8 2, -5, 1, 0, 1, -1, 0,
7<,

8-2, -3, 5, M, M, 0, 1,
10<,
0<<;

In[5]:= initialtableau  MatrixForm

i
j y
z
Out[5]//MatrixForm=

j
j z
z
j
j z
z
j z
x1 x2 x3 r1 r2 s z #

j
j z
z
j
j2 z
z
1 1 1 1 0 0 0 7

k -2 {
-5 1 0 1 -1 0 10
-3 5 M M 0 1 0

Note that each column involving an artificial variable can be made "simple" by an elementary operation. Doing so yields a
simple tableau:

In[6]:= %  rowadd@-M, 2, 4D  rowadd@-M, 3, 4D  MatrixForm

i
j y
z
Out[6]//MatrixForm=

j
j z
z
j
j z
z
j z
x1 x2 x3 r1 r2 s z #

j
j z
z
j
j2 z
z
1 1 1 1 0 0 0 7

k -2 - 3 M {
-5 1 0 1 -1 0 10
-3 + 4 M 5-2M 0 0 M 1 -17 M

This is our first simple tableau. Note that its simple columns are r1, r2 and z. The four other variables, x1, x2, x3 and s
can be regarded as parameters,
and one can solve for the variables r1, r2 and z in terms of these parameters. The obvious solution is the particular solution
obtained when the parameters are zero. Note that the objective function has a large negative value −17M for this solution.
Since the largest negative coefficient in the objective row (final row) is −2−3M in the x1 column, this will be our choice for
the first pivot. Forming the ratios of the # column to those in the x1 column yields (in the limit M ® +¥):

Thread@Part@Transpose@%D, 8D  Part@Transpose@%D, 1DDD


In[7]:= Map@Limit@#, M ® Infinity, Direction ® +1D &,

Out[7]= 9 €€€€€€€€ , 7, 5, €€€€€€€€ =


# 17
x1 3

The choice of pivot row is determined by the smallest positive of these ratios, the ratio 5. The pivot element is therefore the
entry 2 in the x1 column. The pivot row is divided by the pivot element:

In[8]:= %%  rowmul@1  2, 3D  MatrixForm

i
j y
z
Out[8]//MatrixForm=

j
j z
z
j
j1 z
z
j z
x1 x2 x3 r1 r2 s z #

j
j z
z
j
j z
z
j z
1 1 1 0 0 0 7

j z
k -2 - 3 M {
5 1 1 1
1 - €€€
2€ €€€
2€ 0 €€€
2€ - €€€
2€ 0 5
-3 + 4 M 5-2M 0 0 M 1 -17 M

Now the rest of the pivot column is cleared:


big−m.nb 3

In[9]:= %  rowadd@-1, 3, 2D  rowadd@2 + 3 M, 3, 4D  Expand  MatrixForm

i
j y
z
Out[9]//MatrixForm=

j
j z
z
j
j z
z
j z
x1 x2 x3 r1 r2 s z #

j
j z
z
j
j z
z
j1 z
7 1 1 1
0 €€€
2€ €€€
2€ 1 - €€€
2€ €€€
2€ 0 2
j
j z
z
j
j z
z
5 1 1 1
- €€€
€ €€€
€ 0 €€€
€ - €€€
€ 0 5
k0 10 - 2 M {
2 2 2 2
7M M 3M M
-8 - €€€€€€
2
€ 6- €€€
2
€ 0 1+ €€€€€€
2
€ -1 - €€€
2
€ 1

This tableau is simple. Its simple columns are those for r1, x1 and z. The other variables, x2, x3, r2 and s are regarded as
parameters. For the obvious solution, the objective function has value 10 − 2M, which is still large and negative when M is
large, indicating that we are not yet in the feasible region.
The largest negative coefficient in the objective row is − 8 − 7M/2, so the x2 column is chosen for the next pivot column.
Form the ratios:

Thread@Part@Transpose@%D, 8D  Part@Transpose@%D, 2DDD


In[10]:= Map@Limit@#, M ® Infinity, Direction ® +1D &,

Out[10]= 9 €€€€€€€€ , €€€€€ , -2, €€€€€ =


# 4 4
x2 7 7

(Ignore the first and last of these ratios.) In choosing the pivot row, one always ignores negative ratios, so the first ratio 4/7
is the one and only positive ratio to be considered. This determines the pivot row to the second row. The pivot element is
therefore 7/2. Divide the pivot row by that:

In[11]:= %%  rowmul@2  7, 2D  MatrixForm

i
j y
z
Out[11]//MatrixForm=

j
j z
z
j
j z
z
j z
x1 x2 x3 r1 r2 s z #

j
j z
z
j
j z
z
j1 z
1 2 1 1 4
0 1 €€€
€ €€€
€ - €€€
€ €€€
€ 0 €€€
€
j
j z
z
j z
7 7 7 7 7

j z
5 1 1 1
- €€€
€ €€€
€ 0 €€€
€ - €€€
€ 0 5
k0 10 - 2 M {
2 2 2 2
7M M 3M M
-8 - €€€€€€
2€ 6- €€€
2€ 0 1+ €€€€€€
2€ -1 - €€€
2€ 1

Clear the rest of the pivot column (here the x2 column).

In[12]:= %  rowadd@5  2, 2, 3D  rowadd@8 + 7 M  2, 2, 4D  Expand  MatrixForm

i x1
j y
z
Out[12]//MatrixForm=

j
j z
z
j
j z
z
j z
x2 x3 r1 r2 s z #

j
j z
z
j
j 45 z z
j z
1 2 1 1 4
0 1 €€€
7€ €€€
7€ - €€€
7€ €€€
7€ 0 €€€

j
j z
z
j
j z
102 z
6 5 1 1
1 0 €€€
€ €€€
€ €€€
€ - €€€
€ 0 €€€€€€
k0 7 {
7 7 7 7 7
50 16 1 1
0 €€€€€€
7
€€€€€€
7
+M - €€€
7
€ +M €€€
7
€ 1 €€€€€€€€

This tableau is simple. The simple columns are those for x2, x1 and z. The other variables x3, r1, r2 and s are parameters.
These variables are 0 for the obvious solution. Note that the objective function now does not depend on M, so we are
finally in the feasible set. Also note that r1 = r2 = 0 from here on, so that one could simply drop those columns for the rest
of the calculation. Doing so yields:

In[13]:= Transpose@Part@Transpose@%D, 81, 2, 3, 6, 7, 8<DD  MatrixForm

i
j y
z
Out[13]//MatrixForm=

j
j z
z
j
j z
z
j z
x1 x2 x3 s z #

j
j z
z
j
j z
z
j1 z
1 1 4
0 1 €€€
7€ €€€
7€ 0 €€€

j
j z
z
j
j z
102 z
6 1 45
0 €€€
7€ - €€€
7€ 0 €€€€€€
k0 {
7
50 1
0 €€€€€€
7
€€€
7
€ 1 €€€€€€€€
7

This is a simple tableau for the original problem before we introduced artificial variables, and its obvious solution is feasi−
ble. Note that the simple columns are x2, x1 and z. The other variables x3 and s are parameters. For the obvious solution,
these are zero. This obvious solution also happens to be optimal because there are no negative coefficients in the objective
row. (In general one might have to continue pivoting beyond the point that one enters the feasible set.

So the optimal solution is:


big−m.nb 4

This is a simple tableau for the original problem before we introduced artificial variables, and its obvious solution is feasi−
ble. Note that the simple columns are x2, x1 and z. The other variables x3 and s are parameters. For the obvious solution,
these are zero. This obvious solution also happens to be optimal because there are no negative coefficients in the objective
row. (In general one might have to continue pivoting beyond the point that one enters the feasible set.

So the optimal solution is:

x1 = 45/7, x2 = 4/7, x3 = 0, z = 102/7.

Vous aimerez peut-être aussi