When the starting basis needs artificial variables, the two-phase method uses 2 separate simplex runs, avoiding the arbitrary constant M of the Big-M method.
Phase 1
Replace the original objective with minimizing the sum of all artificial variables. This is the same regardless of whether the original problem maximizes or minimizes; the original objective’s direction plays no role in phase 1.
Run the simplex algorithm.
If the minimum is 0, a basic feasible solution to the original problem was found; proceed to phase 2.
If the minimum is positive, the original problem is infeasible. Stop.
Phase 2
Drop the artificial variables and restore the original objective. The original direction only matters here: convert a minimization to max−z to fit the tableau convention, or use a maximization objective as is.
Use the phase 1 optimal basis as the starting basic feasible solution: keep the same basic variables and the same rows (with the artificial columns dropped) from the phase 1 final tableau, and only replace the objective row with the restored objective, priced out against those same rows.
Run the simplex algorithm to optimize the original objective.
Unbounded and alternate/infinite optimal solutions are detected in phase 2 the same way as in the ordinary simplex algorithm.
Worked Example
Same LP as the Big-M worked example: minimize z=4x1+x2 subject to 3x1+x2=3, 4x1+3x2≥6, x1+2x2≤4, x1,x2≥0. Standard form adds a surplus s2, a slack s3, and artificials a1,a2: 3x1+x2+a1=3, 4x1+3x2−s2+a2=6, x1+2x2+s3=4.
Phase 1 Tableau
Objective becomes mina1+a2, i.e. maxw with w=−a1−a2. The natural starting basis is again (a1,a2,s3)=(3,6,4).
1 /
entering column leaving row pivot element updated this step
Basic
x1
x2
s2
s3
a1
a2
RHS
Ratio
w
0
0
0
0
1
1
0
a1
3
1
0
0
1
0
3
a2
4
3
−1
0
0
1
6
s3
1
2
0
1
0
0
4
Basis (a1,a2,s3)=(3,6,4). But a1,a2 are basic with
coefficient 1 in the w row, so it isn’t canonical yet: subtract the
a1 row and the a2 row from the w row to zero them out.
Basic
x1
x2
s2
s3
a1
a2
RHS
Ratio
w
−7
−4
1
0
0
0
−9
a1
3
1
0
0
1
0
3
a2
4
3
−1
0
0
1
6
s3
1
2
0
1
0
0
4
w row after eliminating a1,a2: w=−9. Coefficients −7 and −4 are
negative, so not optimal.
Basic
x1
x2
s2
s3
a1
a2
RHS
Ratio
w
−7
−4
1
0
0
0
−9
a1
3
1
0
0
1
0
3
3/3 = 1
a2
4
3
−1
0
0
1
6
6/4 = 1.5
s3
1
2
0
1
0
0
4
4/1 = 4
Most negative is −7, so x1 enters. Minimum ratio is 1 in row a1, so
a1 leaves. Pivot element is 3.
Basic
x1
x2
s2
s3
a1
a2
RHS
Ratio
w
0
−5/3
1
0
7/3
0
−2
x1
1
1/3
0
0
1/3
0
1
1 / (1/3) = 3
a2
0
5/3
−1
0
−4/3
1
2
2 / (5/3) = 1.2
s3
0
5/3
0
1
−1/3
0
3
3 / (5/3) = 1.8
Coefficient −5/3 is negative, so x2 enters. Minimum ratio is 1.2 in row
a2, so a2 leaves. Pivot element is 5/3.
Basic
x1
x2
s2
s3
a1
a2
RHS
Ratio
w
0
0
0
0
1
1
0
x1
1
0
1/5
0
3/5
−1/5
3/5
x2
0
1
−3/5
0
−4/5
3/5
6/5
s3
0
0
1
1
1
−1
1
w=0 and all coefficients are non-negative. Both artificials are
non-basic, so (x1,x2,s3)=(3/5,6/5,1) is a basic feasible solution
of the original problem.
Step-by-step walkthrough of the simplex method on a tableau
Phase 2 Tableau
Drop columns a1,a2. Restore max−z with −z=−4x1−x2. Carry over the phase 1 final basis (x1,x2,s3)=(3/5,6/5,1), columns x1,x2,s2,s3 only.
1 /
entering column leaving row pivot element updated this step
Basic
x1
x2
s2
s3
RHS
Ratio
z
4
1
0
0
0
x1
1
0
1/5
0
3/5
x2
0
1
−3/5
0
6/5
s3
0
0
1
1
1
Basis (x1,x2,s3)=(3/5,6/5,1), carried over from the phase 1
final tableau. But x1,x2 are basic with nonzero coefficients 4 and
1 in the objective row, so it isn’t canonical yet: subtract
4×(x1 row) and 1×(x2 row) to zero
them out.
Basic
x1
x2
s2
s3
RHS
Ratio
z
0
0
−1/5
0
−18/5
x1
1
0
1/5
0
3/5
x2
0
1
−3/5
0
6/5
s3
0
0
1
1
1
Objective row after eliminating x1,x2. Coefficient −1/5 in column s2
is negative, so not optimal.
Basic
x1
x2
s2
s3
RHS
Ratio
z
0
0
−1/5
0
−18/5
x1
1
0
1/5
0
3/5
(3/5) / (1/5) = 3
x2
0
1
−3/5
0
6/5
skip (-3/5)
s3
0
0
1
1
1
1/1 = 1
s2 enters. Minimum ratio is 1 in row s3, so s3 leaves. Pivot
element is 1.
Basic
x1
x2
s2
s3
RHS
Ratio
z
0
0
0
1/5
−17/5
x1
1
0
0
−1/5
2/5
x2
0
1
0
3/5
9/5
s2
0
0
1
1
1
All objective coefficients are non-negative. Optimal at x1=2/5,
x2=9/5, so z=17/5=3.4, matching the Big-M result.
Step-by-step walkthrough of the simplex method on a tableau