The simplex algorithm, also called the simplex method, is an iterative procedure that solves a linear program by moving from one vertex of the feasible region to an adjacent vertex with a better objective value until no improving move remains. In optimization for artificial intelligence, operations research and data science, it is one of the two dominant ways to solve linear programming problems, alongside the interior-point method.
George Dantzig published the method in 1947, and it remains a core engine inside commercial and open-source solvers. Its practical value rests on a paradox: the worst-case running time is exponential, yet on real problems the method usually finishes in a number of steps that grows roughly linearly with the number of constraints.
How the simplex algorithm walks the polytope
The simplex algorithm exploits a geometric fact: if a linear program has a finite optimum, at least one optimal solution lies at a vertex of the feasible polytope. The method therefore searches only vertices, called basic feasible solutions, instead of the whole continuous region.
The problem is first written in standard form: maximize or minimize a linear objective subject to equality constraints Ax = b and nonnegative variables. Inequalities become equalities by adding slack variables. A basic feasible solution selects m basic variables (one per constraint) and sets the remaining nonbasic variables to zero.
Each iteration, called a pivot, performs the same short sequence of steps. The table below lists them in order with the quantity each step computes.
| Step | What it computes | Purpose |
|---|---|---|
| Pricing | Reduced costs of nonbasic variables | Find a variable that improves the objective |
| Optimality test | Sign of every reduced cost | Stop when no improving variable exists |
| Ratio test | Minimum ratio of right-hand side to column entry | Find how far the entering variable can grow |
| Unboundedness test | Whether any column entry is positive | Detect an objective that improves without limit |
| Basis update | New basis and its factorization | Move to the adjacent vertex |
The variable chosen in pricing is the entering variable; the constraint that becomes tight first in the ratio test identifies the leaving variable. Geometrically, the method slides along one edge of the polytope until it hits the next vertex.
Phases, pivoting rules and variants
A simplex run needs a starting vertex, and finding one can be as hard as the optimization itself. Phase I solves an auxiliary problem with artificial variables whose optimum is zero exactly when the original problem is feasible; Phase II then optimizes the real objective. The Big-M method merges both phases by penalizing artificial variables with a large constant.
The choice of entering variable, known as the pivoting rule, strongly affects the number of iterations. The following table compares the most common rules.
| Pivoting rule | Selection criterion | Practical behavior |
|---|---|---|
| Dantzig rule | Most negative reduced cost | Cheap per step, more iterations |
| Steepest edge | Best improvement per unit edge length | Fewest iterations, higher cost per step |
| Devex | Approximation of steepest edge | Good compromise in large solvers |
| Bland rule | Lowest index among improving variables | Prevents cycling, slow in practice |
Several algorithmic variants exist. The revised simplex method keeps an LU factorization of the basis matrix instead of a full tableau, which makes it suitable for large sparse problems. The dual simplex method maintains optimality of the dual while restoring primal feasibility, and it is the preferred tool for reoptimization after adding constraints, a step that branch and bound performs thousands of times.
Simplex compared with other linear programming methods
The simplex algorithm competes mainly with interior-point methods, which cross the interior of the feasible region along a central path and reach a solution in a polynomial number of iterations. Neither approach dominates; the right choice depends on problem structure and on what happens after the first solve.
| Property | Simplex method | Interior-point method | Ellipsoid method |
|---|---|---|---|
| Worst-case complexity | Exponential | Polynomial | Polynomial |
| Typical iterations | Linear in constraints | Tens to about one hundred | Very many |
| Solution type | Exact vertex solution | Near-optimal interior point | Approximate point |
| Warm start | Excellent | Weak | Weak |
| Practical use | Default for many LPs | Large dense or degenerate LPs | Theoretical interest |
The Klee-Minty cube of 1972 shows that the Dantzig rule can visit all 2 to the power n vertices of a distorted cube. Smoothed analysis, introduced by Spielman and Teng, explains why such cases are rare: small random perturbations of the input yield polynomial expected running time.
Where the simplex method appears in AI and data work
In machine learning, the simplex method usually works inside a solver, not in user code. Libraries such as HiGHS, GLPK and commercial packages call it when a model is expressed as a linear program or as the relaxation of an integer program.
- Mixed-integer linear programming: branch and bound solves thousands of LP relaxations, and the dual simplex method warm-starts each one.
- Optimal transport between discrete distributions is a linear program; network simplex variants compute exact Wasserstein distance for small problems.
- L1-regularized regression and least absolute deviation fitting can be rewritten as linear programs.
- Resource allocation for compute scheduling, ad budgets and supply planning feeds simplex-based solvers.
- Sensitivity analysis uses the final basis to report shadow prices and reduced costs.
A final simplex basis also yields the dual solution for free. The dual values, or shadow prices, tell an analyst how much the objective would change if a constraint were relaxed by one unit, which is often more useful than the primal answer itself.
Limitations and numerical pitfalls
The simplex algorithm handles only linear objectives and linear constraints. Convex quadratic problems require extensions such as the Wolfe method or an active-set solver, and non-convex problems lie outside its scope entirely.
Production implementations must also cope with finite-precision arithmetic. The table below summarizes the most frequent problems, their causes and the usual remedies.
| Symptom | Cause | Remedy |
|---|---|---|
| Stalling | Degenerate vertices with zero step length | Perturb right-hand sides or use steepest edge |
| Cycling | Repeated bases under degeneracy | Apply Bland rule or lexicographic ordering |
| Wrong optimum | Ill-conditioned basis matrix | Rescale the model and refactorize more often |
| Slow solves | Dense columns or huge tableau | Use revised simplex or interior point |
| False infeasibility | Loose tolerances or bad scaling | Tighten tolerances and check the model data |
A common misconception holds that the simplex method is obsolete because interior-point methods have better complexity. In practice, modern solvers run both in parallel, and the simplex method frequently wins on medium-sized sparse models and on every repeated reoptimization task.
In simple terms
Imagine a field shaped like a polygon with straight fences. The best spot is always at a corner. The simplex algorithm walks from corner to corner. At each corner it checks whether a neighboring corner is better.
If a better neighbor exists, it moves there. If none is better, it stops. That corner is the best possible answer. The method never wastes time in the middle of the field. This is why it is fast on most real problems.
A practical example
A cloud team must place 400 nightly training jobs on GPU clusters in three regions. Each job needs a known number of GPU hours, each region has a capacity limit, and prices differ by region. The planners write the task as a linear program with about 1,200 variables and 450 constraints that minimizes total cost.
The solver runs the dual simplex method and reaches an optimal vertex in a few hundred pivots, well under one second. When a region loses 15 percent of its capacity the next day, the team adds one constraint and warm-starts from the previous basis. The new plan arrives in a few dozen pivots, and the shadow prices show that one extra GPU hour in the tightest region would save more than in any other.