3

I want to solve the following linear programming problem:

$$\min (5y_1-10y_2+7y_3-3y_4) \\ y_1+y_2+7y_3+2y_4=3 \\ -2y_1-y_2+3y_3+3y_4=2 \\ 2y_1+2y_2+8y_3+y_4=4 \\ y_i \geq 0, i \in \{ 1, \dots, 4 \}$$

$\begin{bmatrix} 1 & 1 & 7 & 2 & | & 3\\ -2 & -1 & 3 & 3 & | & 2\\ 2 & 2 & 8 & 1 & | & 4 \end{bmatrix} \to \begin{bmatrix} 1 & 1 & 7 & 2 & | & 3\\ 0 & 1 & 17 & 7 & | & 8\\ 0 & 0 & 6 & 3 & | & 2 \end{bmatrix}$

So the problem is written equivalently as follows:

$$-\max (-5y_1+10y_2-7y_3+3y_4) \\ y_1+y_2+7y_3+2y_4=3 \\ y_2+17y_3+7y_4=8 \\ 6y_3+3y_4=2 \\ y_i \geq 0, i \in \{ 1, \dots, 4 \}$$

But we want the $3 \times 3$ identity matrix to appear at the matrix that represents the linear programming problem, right?

So we solve the following problem, right?

$$-\max (-5y_1+10y_2-7y_3+3y_4) \\ y_1+y_2+7y_3+2y_4=3 \\ y_2+17y_3+7y_4+y_5=8 \\ 6y_3+3y_4+y_6=2 \\ y_i \geq 0, i \in \{ 1, \dots,6 \}$$

Then:

$\begin{matrix} B & c_B & b & P_1 & P_2 & P_3 & P_4 & P_5 & P_5 & \theta & \\ P_1 & -5 & 3 & 1 & 1 & 7 & 2 & 0 & 0 & \frac{3}{7} &L_1 \\ P_5 & 0 & 8 & 0 & 1 & 17 & 7 & 1 & 0 & \frac{8}{17} & L_2\\ P_6 & 0 & 2 & 0 & 0 & 6 & 3 & 0 &1 & \frac{1}{3} &L_3 \\ & z & 0 & -5 & 10 & -7 & 3 & 0 & 0 & & L_4 \end{matrix}$

$|-7|> |-5|$ so $P_3$ gets in the basis and $P_6$ gets out of the basis.

Then we get the following tableau:

$\begin{matrix} B & c_B & b & P_1 & P_2 & P_3 & P_4 & P_5 & P_5 & \theta & \\ P_1 & -5 & \frac{2}{3} & 1 & 1 & 0 & -\frac{3}{2} & 0 & -\frac{7}{6} & &L_1'=L_1-7L_3' \\ P_5 & 0 & \frac{7}{3} & 0 & 1 & 0 & -\frac{3}{2} & 1 & -\frac{17}{6} & & L_2'=L_2-17L_3'\\ P_3 & -7 & \frac{1}{3} & 0 & 0 & 1 & \frac{1}{2} & 0 &\frac{1}{6} & &L_3'=\frac{L_3}{6} \\ & z & \frac{7}{3} & -5 & 10 & 0 & \frac{13}{2} & 0 & \frac76 & & L_4'=L_4+7L_3' \end{matrix}$

Have I maybe done something wrong? Because from the last tableau we get that $P_1$ gets out of the basis and $P_1$ gets in the basis...

EDIT: We could introduce the artificial variables as follows:

$$- \max (-5x_1+10x_2-7x_3+3x_4) \\ x_1+x_2+7x_3+2x_4+x_5=3 \\ -2x_1-x_2+3x_3+3x_4+x_6=2 \\ 2x_1+2x_2+8x_3+x_4+x_7=4 \\ x_i \geq 0, i=1,2, \dots, 7$$

At the first phase, we solve the linear programming problem $\min (x_5+x_6+x_7)$ under the new restrictions and at the second phase the initial problem, for which we will have found from the first phase a basic feasible solution.

The problem of the first phase can be written as follows:

$$ -\max (-x_5-x_6-x_7) \\ x_1+x_2+7x_3+2x_4+x_5=3 \\ -2x_1-x_2+3x_3+3x_4+x_6=2 \\ 2x_1+2x_2+8x_3+x_4+x_7=4 \\ x_i \geq 0, i=1,2, \dots, 7$$

Then I thought the simplex tableau would be the following:

$\begin{matrix} B & c_B & b & P_1 & P_2 & P_3 & P_4 & P_5 & P_6 & P_7 & \theta & \\ P_5 & -1 & 3 & 1 & 1 & 7 & 2 & 1 & 0 & 0 & & L_1\\ P_6 & -1 & 2 & -2 & -1 & 3 & 3 & 0 & 1 & 0 & & L_2\\ P_7 & -1 & 4 & 2 & 2 & 8 & 1 & 0 & 0 & 1 & & L_3\\ & z & 0 & 0 & 0 & 0 & 0 & 1 & 1 & 1 & & L_4 \end{matrix}$

But I found that it is this one:

enter image description here

How do we find the $z_k-c_k$- values?

EDIT 2: I get the following tableaus:

$\begin{matrix} B & c_B & b & P_1 & P_2 & P_3 & P_4 & P_5 & P_6 & P_7 & \theta & \\ P_1 & -1 & 3 & 1& 1&7 & 2 & 1 & 0 & 0 & \frac{3}{7} & L_1 \\ P_5 & -1 & 2 & -2 & -1 & 3 & 3 & 0& 1 & 0 &\frac{2}{3} &L_2\\ P_6 & -1 & 4 & 2 & 2 & 8 & 1 & 0 & 0 & 1 &\frac12 &L_3\\ & z & -9& -1 & -2 & -18 & -6& 0& 0 & 0 & & \end{matrix}$

$$$$

$ \begin{matrix} B & c_B & b & P_1 & P_2 & P_3 & P_4 & P_5 & P_6 & P_7 & \theta & \\ P_3 & 0 & \frac{3}{7} & \frac{1}{7}& \frac{1}{7}&1 & \frac{2}{7}& \frac{1}{7} & 0 & 0 & \frac{3}{2} & L_1'=\frac{L_1}{7} \\ P_6 & -1 & \frac{11}{7} & \frac{-17}{7} & -\frac{10}{7} & 0 & \frac{15}{7} & -\frac{3}{7}& 1 & 0 &\frac{11}{15} &L_2'=L_2-3L_1'\\ P_7 & -1 & \frac{4}{7} & \frac{6}{7} & \frac{6}{7} & 0 & -\frac{9}{7} & -\frac{8}{7} & 0 & 1 &- &L_3'=L_3-8L_1'\\ & z & \frac{-9}{7}& \frac{11}{7} & \frac{4}{7} & 0 & \frac{-6}{7}& \frac{18}{17}& 0 & 0 & & L_4'=L_4+18 L_1' \end{matrix}$

$ \begin{matrix} B & c_B & b & P_1 & P_2 & P_3 & P_4 & P_5 & P_6 & P_7 & \theta & \\ P_3 & 0 & \frac{23}{105} & \frac{7}{15}& \frac{1}{3}&1 & 0& \frac{1}{5} & -\frac{2}{15} & 0 & & L_1''=L_1'-\frac{2}{7}L_2'' \\ P_4 & 0 & \frac{11}{15} & \frac{-17}{15} & -\frac{2}{3} & 0 & 1 & -\frac{1}{5}& \frac{7}{15} & 0 & &L_2''=\frac{7}{15} L_2'\\ P_7 & -1 & \frac{17}{5} & -\frac{123}{35} & 0 & 0 & 0 & -\frac{7}{15} & \frac{9}{15} & 1 & &L_3''=L_3'+\frac{9}{7}L_2''\\ & z & \frac{3}{5}& \frac{3}{5} & 0 & 0 & 0& \frac{12}{5}& \frac{6}{15} & 0 & & L_4''=L_4'+\frac{6}{7} L_2'' \end{matrix}$

$$$$

But according to my textbook it should be as follows:

enter image description here

Have I done something wrong at the calculations?

Evinda
  • 1,460

1 Answers1

4

The original minimization problem

\begin{align} \min z = 5y_1-10y_2+7y_3-3y_4 & \\ y_1+y_2+7y_3+2y_4 &= 3 \\ y_2+17y_3+7y_4 &= 8 \\ 6y_3+3y_4 &= 2 \\ y_i &\geq 0, i \in \{ 1, \dots, 4 \} \end{align}

We try to find a basic feasible solution to the original LPP by the two-phase method. Add the artificial variables $y_5,y_6 \ge 0$ into the LPP.

\begin{align} \min z = y_5+y_6 & \\ y_1+y_2+7y_3+2y_4 &= 3 \\ y_2+17y_3+7y_4+y_5 &= 8 \\ 6y_3+3y_4+y_6 &= 2 \\ y_i &\geq 0, i \in \{ 1, \dots, 6 \} \end{align}

We write the objective function as $z-y_5-y_6=0$. Since the coefficient of $z$ is always one, we omit it in the simplex tableaux to save ink.

\begin{equation*} \begin{array}{rrrrrrr|r} & y_1 & y_2 & y_3 & y_4 & y_5 & y_6 & \\ \hline y_1 & 1 & 1 & 7 & 2 & 0 & 0 & 3 \\ y_5 & 0 & 1 & 17 & 7 & 1 & 0 & 8 \\ y_6 & 0 & 0 & 6 & 3 & 0 & 1 & 2 \\ \hline z & 0 & 0 & 0 & 0 & -1 & -1 & 0 \end{array} \end{equation*}

Make it a simplex tableau.

\begin{equation*} \begin{array}{rrrrrrr|r} & y_1 & y_2 & y_3 & y_4 & y_5 & y_6 & \\ \hline y_1 & 1 & 1 & 7 & 2 & 0 & 0 & 3 \\ y_5 & 0 & 1 & 17 & 7 & 1 & 0 & 8 \\ y_6 & 0 & 0 & 6 & 3 & 0 & 1 & 2 \\ \hline z & 0 & 1 & 23 & 10 & 0 & 0 & 10 \end{array} \end{equation*}

Since it's minimization, we choose $y_j$ with the biggest $z_j - c_j$ as the entering variable.

\begin{equation*} \begin{array}{rrrrrrr|rr} & y_1 & y_2 & y_3 & y_4 & y_5 & y_6 & & \theta \\ \hline y_1 & 1 & 1 & 7 & 2 & 0 & 0 & 3 & \frac{3}{7} \\ y_5 & 0 & 1 & 17 & 7 & 1 & 0 & 8 & \frac{8}{17} \\ y_6 & 0 & 0 & 6^* & 3 & 0 & 1 & 2 & \frac{1}{3} \\ \hline z & 0 & 1 & 23 & 10 & 0 & 0 & 10 & \end{array} \tag{*} \label{min} \end{equation*}

\begin{equation*} \begin{array}{rrrrrrr|rr} & y_1 & y_2 & y_3 & y_4 & y_5 & y_6 & & \theta \\ \hline y_1 & 1 & 1^* & 0 & -\frac{3}{2} & 0 & -\frac{7}{6} & \frac{2}{3} & \frac{2}{3} \\ y_5 & 0 & 1 & 0 & -\frac{3}{2} & 1 & -\frac{17}{6} & \frac{7}{3} & \frac{7}{3} \\ y_3 & 0 & 0 & 1 & \frac{1}{2} & 0 & \frac{1}{6} & \frac{1}{3} & \\ \hline z & 0 & 1 & 0 & -\frac{3}{2} & 0 & -\frac{23}{6} & \frac{7}{3} & \end{array} \end{equation*}

Choose $y_2$ as the entering variable, $y_1$ as the leaving variable.

\begin{equation*} \begin{array}{rrrrrrr|r} & y_1 & y_2 & y_3 & y_4 & y_5 & y_6 & \\ \hline y_2 & 1 & 1 & 0 & -\frac{3}{2} & 0 & -\frac{7}{6} & \frac{2}{3} \\ y_5 & -1 & 0 & 0 & 0 & 1 & -\frac{5}{3} & \frac{5}{3} \\ y_3 & 0 & 0 & 1 & \frac{1}{2} & 0 & \frac{1}{6} & \frac{1}{3} \\ \hline z & -1 & 0 & 0 & 0 & 0 & -\frac{8}{3} & \frac{5}{3} \end{array} \end{equation*}

Since we still have the artificial variable $y_5$ in the basis in the optimal tableau, we conclude that this problem is not feasible.

I tried phase one in GNU Octave. You may run the following code online.

A=[1 1 7 2 0 0; 0 1 17 7 1 0; 0 0 6 3 0 1];
b = [3 8 2]'; c=[0 0 0 0 1 1]';
[x_min z_min] = glpk(c,A,b,zeros(6,1),[],"SSS","CCCCCC")

Results

x_min =

   0.00000
   1.66667
   0.00000
   0.66667
   1.66667
   0.00000

z_min =  1.6667

I also tried directly solving the original LPP, and the program returned NA.

A = [1 1 7 2; -2 -1 3 3; 2 2 8 1]; b = [3 2 4]'; c = [5 -10 7 -3]';
[x_min,z_min] = glpk(c,A,b,zeros(4,1),[],"SSS","CCCC")

Result

glp_simplex: unable to recover undefined or non-optimal solution
x_min =

    NA
    NA
    NA
    NA

z_min = NA

To get $z_j - c_j$, you may simply calculate $c_B^T B^{-1} a_j$. For the derivation, you may see my answer for another question about the regeneration of optimal simplex tableau from the optimal BFS. To actually calculate this number, compute $c_B^T y_j$, where $y_j$ is the column for $P_j$ in the current simplex tableau. For example, in the given tableau, $c_B = (-1,-1,-1)^T$.

\begin{align} z_1 - c_1 &= (-1,-1,-1)(1,-2,2)^T = -1 \\ z_2 - c_2 &= (-1,-1,-1)(1,-1,2)^T = -2 \\ z_3 - c_3 &= (-1,-1,-1)(7,3,8)^T = -18 \text{, etc} \end{align}

We want the artificial variables $x_5,x_6,x_7 = 0$, so we $\min x_5 + x_6 + x_7$, which is equivalent to $\mathbf{\max -x_5 - x_6 - x_7}$ (what you see in your book). That's why you see $-9$ in the $z$-row, $b$-column in the given simplex tableau.

Question: In simplex tableau $\eqref{min}$, the entering variable has $z_j - c_j > 0$. This seems contradictory to what you've learnt.
Answer: See my answer another question for detailed explanation.

  • In a maximisation problem, the entering variable has $z_j - c_j \le 0$.
  • In a minimisation problem, the entering variable has $z_j - c_j \ge 0$.

\begin{array}{r|r|r|rrrrrrr|r|l} & & & 0 & 0 & 0 & 0 & -1 & -1 & -1 & & \\ \hline B & c_B & b & P_1 & P_2 & P_3 & P_4 & P_5 & P_6 & P_7 & \theta & \\ \hline \hline P_5 & -1 & 3 & 1 & 1 & 7 & 2 & 1 & 0 & 0 & & L_1 \\ P_6 & -1 & 2 & -2 & -1 & 3 & 3 & 0 & 1 & 0 & & L_2 \\ P_7 & -1 & 4 & 2 & 2 & 8 & 1 & 0 & 0 & 1 & & L_3 \\ \hline & z & 0 & 0 & 0 & 0 & 0 & 1 & 1 & 1 & & L_4 \\ \hline \hline P_5 & -1 & 3 & 1 & 1 & 7^* & 2 & 1 & 0 & 0 & 3/7^* & L_1' = L_1 \\ P_6 & -1 & 2 & -2 & -1 & 3 & 3 & 0 & 1 & 0 & 2/3 & L_2' = L_2 \\ P_7 & -1 & 4 & 2 & 2 & 8 & 1 & 0 & 0 & 1 & 4/8 & L_3' = L_3 \\ \hline & z & -9 & -1 & -2 & -18^* & -6 & 0 & 0 & 0 & & L_4' = -L_1 - L_2 - L_3 + L_4 \\ \hline \hline P_3 & 0 & 3/7 & 1/7 & 1/7 & 1 & 2/7 & 1/7 & 0 & 0 & 3/2 & L_1'' = \frac17 L_1' \\ P_6 & -1 & 5/7 & -17/7 & -10/7 & 0 & 15/7^* & -3/7 & 1 & 0 & 5/15^* & L_2'' = L_2' - \frac37 L_1' \\ P_7 & -1 & 4/7 & 6/7 & 6/7 & 0 & -9/7 & -8/7 & 0 & 1 & - & L_3'' = L_3' - \frac87 L_1' \\ \hline & z & -9/7 & 11/7 & 4/7 & 0 & -6/7^* & 18/7 & 0 & 0 & & L_4'' = L_4' + \frac{18}{7} L_1' \\ \hline \hline P_3 & 0 & 1/3 & 7/15 & 1/3 & 1 & 0 & 1/5 & -2/15 & 0 & & L_1''' = L_1'' - \frac{2}{15} L_2'' \\ P_4 & 0 & 1/3 & -17/15 & -2/3 & 0 & 1 & -1/5 & 7/15 & 0 & & L_2''' = \frac{7}{15} L_2'' \\ P_7 & -1 & 1 & -3/5 & 0 & 0 & 0 & -7/5 & 3/5 & 1 & & L_3''' = L_3'' + \frac{3}{5} L_2'' \\ \hline & z & -1 & 3/5 & 0 & 0 & 0 & 12/5 & 2/5 & 0 & & L_4''' = L_4'' + \frac{2}{5} L_2'' \end{array}

Since artificial variable $P_7$ is still in the basis, this LPP has no feasible solution.

  • To use the simplex method we firstly write the linear programming problem in its canonical form , so $\min z=y_5+y_6$ becommes $- \max (-z=-y_5-y_6)$. $$$$ $-1$ is the smallest value at the last row, so do deduce that $P_5$ gets in the basis and $P_6$ gets out of the basis. This can't be true. $$$$ Or am I wrong? – Evinda Jan 05 '16 at 23:48
  • @Evinda You may see the following table my answer for another question for a detailed description.

    \begin{array}{rr|l} & \text{a non-basic variable} & \text{RHS} \ \hline \text{a basic variable} & \heartsuit > 0 & \spadesuit \ge 0 \ \hline z & \clubsuit & \text{obj. fct. val.} \end{array}

    After each pivot operation, you have

    \begin{equation} \text{new obj. fct. val.} = \text{obj. fct. val.} - \frac{\spadesuit\clubsuit}{\heartsuit} \end{equation}

    – GNUSupporter 8964民主女神 地下教會 Jan 06 '16 at 06:11
  • @Evinda "$-1$ is smallest, so $P_5$ gets out of the basis" is true when (1) we are doing a max-type LPP, and (2) it is a simplex tableau

    The problem is, in the first tableau of my answer, it is not a simplex tableau. The two $-1$ in the last row is in the column $P_5$ and $P_6$, which is in the basis. Therefore, to make it a simplex tableau, we do some row operations.

    – GNUSupporter 8964民主女神 地下教會 Jan 06 '16 at 06:16
  • Directly using $\min z = y_5+y_6$ and remembering to choose the largest $z_j - c_j$ instead of converting it to a max-type and choosing the smallest $z_j - c_j$ LPP saves you one step. – GNUSupporter 8964民主女神 地下教會 Jan 06 '16 at 06:44
  • I edited my post. Could you take a look at it? – Evinda Jan 07 '16 at 22:15
  • @Evinda I've edited my answer in response to your edit. – GNUSupporter 8964民主女神 地下教會 Jan 08 '16 at 12:42
  • I think that $L_4'=L_1+L_2+L_3+L_4$ isn't true, otherwise it should hold that $z_5'-c_5=2$. Or am I wrong? $$$$ Also could you explain me further how we get -9? Do we find the sum of the elements of the b-row and then take the minus of that? If so why do we do it like that? – Evinda Jan 09 '16 at 22:05
  • Also I added my post since I do not get the same tableaus and thus the same solution as in my textbook. Have I done something wrong at the calculations? – Evinda Jan 09 '16 at 23:49
  • @Evinda Sorry. I've made 3 mistakes: (1) $L_4'=-L_1-L_2-L_3+L_4$ to ensure that if $P_j$ is a basic variable, $z_j - c_j$ must be zero. This step is very important. (2) In the 3rd and 4th (i.e. last) objective function values $z$, I made a mistake. I've corrected them. Your book is correct. However, I don't think that these mistakes will affect the conclusion that the LPP is infeasible because (1) the rightmost column $L_1 = \dots$ is *unnecessary*, especially in test/exams. Without that column, everyone still knows what you're doing. (pivot operation) – GNUSupporter 8964民主女神 地下教會 Jan 10 '16 at 06:54
  • @Evinda (2) The optimality only depends on the $z_j - c_j$ of decision variables $P_j$, while the feasibility only depends on whether the entries in the $b$ column in the constraints row is non-negative. (i.e. whether $B^{-1} b \ge 0$) Neither the optimality nor the feasibility has anything to do with the value of $z$. We deduce that the LPP is infeasible from the entries in the $z$ row and in the $b$ column but excluding the objective function value, so that doesn't hurt. – GNUSupporter 8964民主女神 地下教會 Jan 10 '16 at 07:03
  • @Evinda Btw, your book's tableau format is very clumsy. You may use a better format with fewer to save time in tests/exams. \begin{array}{crrrrrrr|l} & x_1 & x_2 & x_3 & x_4 & x_5 & x_6 & x_7 & \ \hline x_4 & 0 & -3 & 7 & 1 & 0 & 0 & 2 & 2M -4 \ x_5 & 0 & -9 & 0 & 0 & 1 & 0 & -1 & -M -3 \ x_6 & 0 & 6 & -1 & 0 & 0 & 1 & -4^* & -4M +8 \ x_1 & 1 & 0 & 1 & 0 & 0 & 0 & 1 & M \ \hline & 0 & 1 & 1 & 0 & 0 & 0 & 2 & 2M \ \end{array} – GNUSupporter 8964民主女神 地下教會 Jan 10 '16 at 07:05
  • @Evinda That is, you don't need to write the coefficients of $c_B$ in each step. You can just do pivot operations normally to calculate the value of $z$. Therefore, I get $-9$ in the second step (out of four steps) by $0 - 3 - 2 - 4$.

    The above tableau is for the dual simplex algorithm, but I hope you know what I mean.

    – GNUSupporter 8964民主女神 地下教會 Jan 10 '16 at 07:10
  • Shouldn't it be $L_2''=L_2'-3L_1''$ ? – Evinda Jan 10 '16 at 08:37
  • Since $L_1'' = \frac17 L_1'$, $L_2'' = L_2' - \frac37 L_1' = L_2' - 3L_1''$. Anyways, this can omitted. – GNUSupporter 8964民主女神 地下教會 Jan 10 '16 at 10:02
  • We have the tableau: $\begin{matrix} B & c_B & b & P_1 & P_2 & P_3 & P_4 & P_5 & P_6 & P_7 & \theta & \ P_5 & -1 & 3 & 1 & 1 & 7 & 2 & 1 & 0 & 0 & \frac{3}{7}&C_1\ P_6 & -1 & 2 & -2 & -1 & 3 & 3 & 0 & 1 & 0 & \frac{2}{3}&C_2\ P_7 & -1 & 4 & 2 & 2 & 8 & 1 & 0 & 0 & 1 & \frac{1}{2}&C_3\ & z & -9 & -1 & -2 & -18 & -6 & 0 & 0 & 0 & & \end{matrix}$

    $$$$

    We deduce that $P_3$ gets in the basis , $P_5$ gets out of the basis and the pivot is $7$. So $C_1'=\frac{C_1}{7}, C_2'=C_2-3C_1', C_3'=C_3-8C_1', C_4'=C_4+18C_1'$.$$$$ At which point am I wrong?

    – Evinda Jan 10 '16 at 10:11
  • At the first edit part, aren't tha values of $z_j-c_j$ wrong? Since we have $z_k-c_k=1, k=5,6,7$ and all these values should be equal to zero. – Evinda Jan 10 '16 at 10:39
  • Could I also ask you something else about the simplex method? – Evinda Jan 29 '16 at 21:53
  • I have verified it... But thank you!!! Are you maybe also familiar with dynamic programming? – Evinda Jan 31 '16 at 14:54
  • @Evinda I'm sorry that I don't know dynamic programming – GNUSupporter 8964民主女神 地下教會 Jan 31 '16 at 15:02
  • A ok... no problem... with non-linear programming? I have also there a question. – Evinda Jan 31 '16 at 15:03
  • @Evinda I confess that I only know linear programming. As you can see on my user card (which pops up after you hover your mouse on my user icon), I spend a few time on math outside class. You may start another post so that others can upvote it and give you reputation. – GNUSupporter 8964民主女神 地下教會 Jan 31 '16 at 15:11
  • Ok... no problem... thanks :) – Evinda Jan 31 '16 at 15:17