Simplex algorithm

Also known as: simplex method

On this page 7

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.

StepWhat it computesPurpose
PricingReduced costs of nonbasic variablesFind a variable that improves the objective
Optimality testSign of every reduced costStop when no improving variable exists
Ratio testMinimum ratio of right-hand side to column entryFind how far the entering variable can grow
Unboundedness testWhether any column entry is positiveDetect an objective that improves without limit
Basis updateNew basis and its factorizationMove to the adjacent vertex
Steps of one simplex iteration

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 ruleSelection criterionPractical behavior
Dantzig ruleMost negative reduced costCheap per step, more iterations
Steepest edgeBest improvement per unit edge lengthFewest iterations, higher cost per step
DevexApproximation of steepest edgeGood compromise in large solvers
Bland ruleLowest index among improving variablesPrevents cycling, slow in practice
Common pivoting rules

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.

PropertySimplex methodInterior-point methodEllipsoid method
Worst-case complexityExponentialPolynomialPolynomial
Typical iterationsLinear in constraintsTens to about one hundredVery many
Solution typeExact vertex solutionNear-optimal interior pointApproximate point
Warm startExcellentWeakWeak
Practical useDefault for many LPsLarge dense or degenerate LPsTheoretical interest
Simplex method versus alternative solvers

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.

SymptomCauseRemedy
StallingDegenerate vertices with zero step lengthPerturb right-hand sides or use steepest edge
CyclingRepeated bases under degeneracyApply Bland rule or lexicographic ordering
Wrong optimumIll-conditioned basis matrixRescale the model and refactorize more often
Slow solvesDense columns or huge tableauUse revised simplex or interior point
False infeasibilityLoose tolerances or bad scalingTighten tolerances and check the model data
Typical simplex problems and remedies

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.