Simplex Method Calculator

Solve optimization problems using the simplex method

The calculator will solve the given optimization problem using the simplex algorithm. It will add slack, surplus and artificial variables, if needed. In case of artificial variables, the Big M method or the two-phase method is used to determine the starting solution. Steps are available.

Comma-separated.

If the calculator did not compute something or you have identified an error, or you have a suggestion/feedback, please contact us.

Your Input

Maximize Z=3x1+4x2Z = 3 x_{1} + 4 x_{2}, subject to {x1+2x28x1+x26x10x20\begin{cases} x_{1} + 2 x_{2} \leq 8 \\ x_{1} + x_{2} \leq 6 \\ x_{1} \geq 0 \\ x_{2} \geq 0 \end{cases}.

Solution

The problem in the canonical form can be written as follows:

Z=3x1+4x2maxZ = 3 x_{1} + 4 x_{2} \to max{x1+2x28x1+x26x1,x20\begin{cases} x_{1} + 2 x_{2} \leq 8 \\ x_{1} + x_{2} \leq 6 \\ x_{1}, x_{2} \geq 0 \end{cases}

Add variables (slack or surplus) to turn all the inequalities into equalities:

Z=3x1+4x2maxZ = 3 x_{1} + 4 x_{2} \to max{x1+2x2+S1=8x1+x2+S2=6x1,x2,S1,S20\begin{cases} x_{1} + 2 x_{2} + S_{1} = 8 \\ x_{1} + x_{2} + S_{2} = 6 \\ x_{1}, x_{2}, S_{1}, S_{2} \geq 0 \end{cases}

Write down the simplex tableau:

Basicx1x_{1}x2x_{2}S1S_{1}S2S_{2}Solution
ZZ3-34-4000000
S1S_{1}1122110088
S2S_{2}1111001166

The entering variable is x2x_{2}, because it has the most negative coefficient 4-4 in the Z-row.

Basicx1x_{1}x2x_{2}S1S_{1}S2S_{2}SolutionRatio
ZZ3-34-4000000
S1S_{1}112211008882=4\frac{8}{2} = 4
S2S_{2}111100116661=6\frac{6}{1} = 6

The leaving variable is S1S_{1}, because it has the smallest ratio.

Divide row 11 by 22: R1=R12R_{1} = \frac{R_{1}}{2}.

Basicx1x_{1}x2x_{2}S1S_{1}S2S_{2}Solution
ZZ3-34-4000000
x2x_{2}12\frac{1}{2}1112\frac{1}{2}0044
S2S_{2}1111001166

Add row 22 multiplied by 44 to row 11: R1=R1+4R2R_{1} = R_{1} + 4 R_{2}.

Basicx1x_{1}x2x_{2}S1S_{1}S2S_{2}Solution
ZZ1-10022001616
x2x_{2}12\frac{1}{2}1112\frac{1}{2}0044
S2S_{2}1111001166

Subtract row 22 from row 33: R3=R3R2R_{3} = R_{3} - R_{2}.

Basicx1x_{1}x2x_{2}S1S_{1}S2S_{2}Solution
ZZ1-10022001616
x2x_{2}12\frac{1}{2}1112\frac{1}{2}0044
S2S_{2}12\frac{1}{2}0012- \frac{1}{2}1122

The entering variable is x1x_{1}, because it has the most negative coefficient 1-1 in the Z-row.

Basicx1x_{1}x2x_{2}S1S_{1}S2S_{2}SolutionRatio
ZZ1-10022001616
x2x_{2}12\frac{1}{2}1112\frac{1}{2}0044412=8\frac{4}{\frac{1}{2}} = 8
S2S_{2}12\frac{1}{2}0012- \frac{1}{2}1122212=4\frac{2}{\frac{1}{2}} = 4

The leaving variable is S2S_{2}, because it has the smallest ratio.

Multiply row 22 by 22: R2=2R2R_{2} = 2 R_{2}.

Basicx1x_{1}x2x_{2}S1S_{1}S2S_{2}Solution
ZZ1-10022001616
x2x_{2}12\frac{1}{2}1112\frac{1}{2}0044
x1x_{1}11001-12244

Add row 33 to row 11: R1=R1+R3R_{1} = R_{1} + R_{3}.

Basicx1x_{1}x2x_{2}S1S_{1}S2S_{2}Solution
ZZ000011222020
x2x_{2}12\frac{1}{2}1112\frac{1}{2}0044
x1x_{1}11001-12244

Subtract row 33 multiplied by 12\frac{1}{2} from row 22: R2=R2R32R_{2} = R_{2} - \frac{R_{3}}{2}.

Basicx1x_{1}x2x_{2}S1S_{1}S2S_{2}Solution
ZZ000011222020
x2x_{2}0011111-122
x1x_{1}11001-12244

None of the Z-row coefficients are negative.

The optimum is reached.

The following solution is obtained: (x1,x2,S1,S2)=(4,2,0,0)\left(x_{1}, x_{2}, S_{1}, S_{2}\right) = \left(4, 2, 0, 0\right).

Answer

Z=20Z = 20A is achieved at (x1,x2)=(4,2)\left(x_{1}, x_{2}\right) = \left(4, 2\right)A.