Linear Programming and the Simplex Method
When both what you're optimizing and every constraint you must respect are straight lines (or flat planes), the best answer always sits at a corner of the feasible region — and the simplex method is the classic algorithm that walks from corner to corner until it finds it.
Prerequisites: Convex Sets and Convex Functions, Gradients and Directional Derivatives
Suppose you're allocating capital across a handful of trades, each with a fixed expected return, subject to hard limits: total capital, a maximum position per name, a sector exposure cap. Every piece of this — the objective (total expected return) and every constraint — is a straight-line (linear) relationship in the position sizes. This is a linear program, and it has a remarkable structural fact going for it: the optimal allocation is never some interior blend that uses every constraint a little; it always sits exactly at a corner where several constraints bind simultaneously. The simplex method is the classical algorithm that exploits this fact directly, hopping from corner to corner of the feasible region until it can prove no neighboring corner is better.
The analogy: a diamond-shaped room and a flashlight
Picture the set of all allowed allocations as a many-sided polyhedral room — every wall is a constraint, and any point inside or on the walls is feasible. Now shine a flashlight from one direction representing "more objective value" and ask: where does the room get brightest? Because every wall is flat (no curved walls, since everything is linear), the brightest point is always exactly at a corner or edge, never floating in the middle of a flat wall or deep in the room's interior. The simplex method starts at one corner of this room and repeatedly checks: is there an adjacent corner, connected by an edge, that's brighter? If yes, walk there; if no, you've proven you're at the best corner in the whole room.
The mechanics, one symbol at a time
A linear program in standard form is
where is the vector of decision variables (position sizes), gives each variable's contribution to the objective, and encodes every linear constraint at once. In words: choose position sizes to maximize a weighted sum of returns, without violating any capital, exposure, or position-limit constraint, and without taking negative positions.
The simplex method starts at a vertex (corner) of the feasible region and, at each step, checks whether moving along any edge to a neighboring vertex increases the objective. If some neighbor is strictly better, it moves there; if no neighboring vertex improves the objective, the current vertex is provably optimal — because of the flat-walled, corner-optimal structure, checking local neighbors is enough to prove global optimality, something that's emphatically not true for curved (nonlinear) optimization problems.
Worked example 1: a two-trade allocation by hand
Maximize (expected profit, in $thousands, from two trades) subject to (capital limit) and (a per-name cap), with . The feasible region's corners are , , , and . Evaluating the objective at each: ; ; ; . The best corner is , value $260,000 — using the full per-name cap on trade 1 and whatever capital remains on trade 2. Simplex would reach this by starting at, say, , moving to a better adjacent corner, and repeating until no neighbor beats .
Worked example 2: reading off a binding constraint
At the optimal corner above, note both constraints are exactly binding: (the cap) and (full capital used). This is the general pattern — with 2 variables, an optimal corner is defined by exactly 2 binding constraints. If instead the capital limit were raised to , the new corners would shift, and it's worth checking: the corner would now give , an improvement — showing directly how loosening one constraint moves the whole optimal corner, not just nudges the objective value.
Treat this as a stand-in for the boundary of a feasible region — imagine it as one wall of a many-sided flat-walled room; a genuine LP's feasible region is bounded by several such flat pieces, and the optimum sits where several of them meet at a corner.
What this means in practice
Linear programming is the workhorse behind capital allocation with hard exposure limits, index-tracking with turnover and transaction-cost caps expressed linearly, and any risk-limit problem where the objective and every constraint are genuinely linear. It's also the simplest member of a family — quadratic programming, second-order cone programming, semidefinite programming — that handles progressively more general (curved) objectives and constraints, each solved with algorithms that borrow directly from LP intuition, especially the interior-point approach that largely displaced pure simplex for large problems.
In a linear program, the optimum always occurs at a vertex (corner) of the flat-walled feasible region; the simplex method exploits this by moving from corner to corner, improving the objective each step, until no neighboring corner is better — at which point that corner is provably globally optimal.
The classic mistake is applying corner-optimal, simplex-style intuition to a problem that isn't actually linear — for instance, a portfolio objective with a genuine risk term like variance (which is quadratic, not linear). In that curved-objective case the optimum can sit in the interior of the feasible region, not at a corner, and running an LP solver on a quadratic problem (by ignoring the curvature, or crudely linearizing it) will produce a plausible-looking but wrong answer. Always confirm both the objective and every constraint are genuinely linear before reaching for simplex.
Related concepts
Practice in interviews
Further reading
- Bertsimas & Tsitsiklis, Introduction to Linear Optimization, ch. 2–3
- Boyd & Vandenberghe, Convex Optimization, ch. 4