MathLabs

Applied and computational mathematics

Linear programming

Optimizing a linear objective subject to linear constraints, solved efficiently by the simplex method.

IntuitionSqueezing the most profit out of limited resources

Imagine a small factory that makes two products using shared machine time and raw material. Each product earns a different profit per unit, and each constraint — machine hours, material, storage space — limits how much can be made. Linear programming asks: how much of each product should be made to maximize total profit without breaking any constraint? Because the profit function and every constraint are straight lines (or flat hyperplanes in higher dimensions), the set of feasible production plans forms a convex polyhedron, and the best plan always sits at one of its corners.

Interactive 3D polyhedron that can be exploded apart to reveal its vertices, edges, and faces, representing the feasible region of a linear program.
Exploding a polyhedron into its vertices: for a linear program, the feasible region is exactly such a polyhedron, and the fundamental theorem of linear programming guarantees an optimal solution sits at one of these corner points.

SchoolStandard form

Definition: Standard form of a linear program

A linear program in standard form chooses a vector of decision variables xx to maximize a linear objective cTxc^{\mathsf{T}}x subject to linear inequality constraints Ax≤bAx\le b and non-negativity x≥0x\ge 0. Here cc is the vector of per-unit profits, AA is the matrix of resource usage coefficients, and bb is the vector of resource limits.

max⁡x  cTxsubject toAx≤b,  x≥0\max_{x} \; c^{\mathsf{T}} x \quad \text{subject to} \quad Ax \le b, \; x \ge 0

Each row of Ax≤bAx\le b represents one limited resource: the left-hand side is how much of that resource a production plan xx consumes, and the right-hand side bb is how much is available. Adding a slack variable s≥0s\ge 0 for each row turns every inequality into an equality, Ax+s=bAx+s=b, which is the form the simplex method actually works with.

Ax+s=b,s≥0Ax + s = b, \qquad s \ge 0
Comparing methods for solving a linear program
MethodHow it searchesScales to how many variables?Worst-case complexity
Graphical methodPlots the feasible polygon and slides the objective line across itOnly 2 variables (3 with a 3D plot)Not applicable (visual method)
Simplex methodWalks from vertex to adjacent vertex, always improving the objectiveHundreds to thousands of variables in practiceExponential in theory, fast in practice
Interior-point methodMoves through the interior of the polyhedron toward the optimumVery large problems (millions of variables)Polynomial time

UndergraduateThe fundamental theorem and the simplex method

Let the feasible region P={x:Ax≤b,x≥0}P=\{x : Ax\le b, x\ge 0\} be nonempty and bounded. If the linear program max⁡x∈PcTx\max_{x\in P} c^{\mathsf{T}}x has an optimal value, then that optimal value is attained at a vertex (extreme point) of PP.

Why is it true?

The objective is linear, so its level sets are parallel hyperplanes; sliding such a hyperplane across a convex polyhedron, the last point it touches before leaving the region is always a corner, never a point in the interior of a face, because interior points can always be pushed further in the direction that improves the objective.

Proof

Since PP is a bounded polyhedron defined by finitely many linear inequalities, it has finitely many vertices v1,…,vkv_1,\ldots,v_k, and a classical fact about polytopes (Minkowski's theorem) states that every point of PP is a convex combination of these vertices: x=∑i=1kλivix=\sum_{i=1}^{k}\lambda_i v_i, where λi≥0\lambda_i\ge 0 and ∑iλi=1\sum_i \lambda_i=1.

Because the objective cTxc^{\mathsf{T}}x is linear, evaluating it on such a convex combination gives cTx=∑iλi(cTvi)≤(max⁡icTvi)∑iλi=max⁡icTvic^{\mathsf{T}}x=\sum_i \lambda_i\left(c^{\mathsf{T}}v_i\right)\le \left(\max_i c^{\mathsf{T}}v_i\right)\sum_i\lambda_i=\max_i c^{\mathsf{T}}v_i, since each λi≥0\lambda_i\ge 0 and they sum to 11.

This shows every feasible xx has objective value no larger than the best vertex value max⁡icTvi\max_i c^{\mathsf{T}}v_i. But that best vertex, call it vi∗v_{i^*}, is itself a feasible point of PP, so it actually attains this upper bound: cTvi∗=max⁡x∈PcTxc^{\mathsf{T}}v_{i^*}=\max_{x\in P} c^{\mathsf{T}}x. Hence the optimum of the linear program is achieved at the vertex vi∗v_{i^*}, proving the claim.

The fundamental theorem justifies restricting the search for an optimum to the finitely many vertices of PP, but checking every vertex directly is too slow when there are many constraints. The simplex method instead starts at one vertex and repeatedly moves to an adjacent vertex along an edge that strictly increases the objective, stopping only when no neighboring vertex is better — at that point, every reduced cost is non-negative and the current vertex is provably optimal.

For the primal program max⁡{cTx:Ax≤b,x≥0}\max\{c^{\mathsf{T}}x : Ax\le b, x\ge 0\}, define the dual program min⁡{bTy:ATy≥c,y≥0}\min\{b^{\mathsf{T}}y : A^{\mathsf{T}}y\ge c, y\ge 0\}. Then (weak duality) cTx≤bTyc^{\mathsf{T}}x\le b^{\mathsf{T}}y for every primal-feasible xx and dual-feasible yy, and (strong duality) if the primal has an optimal solution x∗x^{*}, the dual has an optimal solution y∗y^{*} with cTx∗=bTy∗c^{\mathsf{T}}x^{*}=b^{\mathsf{T}}y^{*}.

Why is it true?

Duality says the primal maximization and the dual minimization are two views of the same number: the dual variables yy act as prices on the resources, and weak duality says no feasible production plan can ever earn more than the value of the resources it uses at any valid pricing, while strong duality says that at the optimum, the best production plan and the cheapest valid pricing agree exactly.

Proof

(Weak duality.) Let xx be any primal-feasible point (Ax≤bAx\le b, x≥0x\ge 0) and yy any dual-feasible point (ATy≥cA^{\mathsf{T}}y\ge c, y≥0y\ge 0). Since x≥0x\ge 0 and ATy≥cA^{\mathsf{T}}y\ge c, multiplying the inequality by the nonnegative vector xx preserves it: cTx≤(ATy)Tx=yTAxc^{\mathsf{T}}x\le \left(A^{\mathsf{T}}y\right)^{\mathsf{T}}x=y^{\mathsf{T}}Ax. Since y≥0y\ge 0 and Ax≤bAx\le b, the same argument gives yTAx≤yTb=bTyy^{\mathsf{T}}Ax\le y^{\mathsf{T}}b=b^{\mathsf{T}}y. Chaining the two inequalities, cTx≤bTyc^{\mathsf{T}}x\le b^{\mathsf{T}}y for every feasible pair, which is weak duality.

(Strong duality.) Run the simplex method on the primal until it terminates at an optimal basic feasible solution x∗x^{*} with optimal basis matrix BB, so that xB∗=B−1bx^{*}_B=B^{-1}b and the reduced costs of every non-basic variable are non-negative — this termination condition is equivalent to defining y∗T=cBTB−1y^{*\mathsf{T}}=c_B^{\mathsf{T}}B^{-1}, which one can check satisfies ATy∗≥cA^{\mathsf{T}}y^{*}\ge c and y∗≥0y^{*}\ge 0, i.e. y∗y^{*} is dual-feasible.

Substituting, the primal optimal value is cTx∗=cBTxB∗=cBTB−1b=y∗Tb=bTy∗c^{\mathsf{T}}x^{*}=c_B^{\mathsf{T}}x^{*}_B=c_B^{\mathsf{T}}B^{-1}b=y^{*\mathsf{T}}b=b^{\mathsf{T}}y^{*}. Combined with weak duality (cTx∗≤bTy∗c^{\mathsf{T}}x^{*}\le b^{\mathsf{T}}y^{*} always), equality here forces y∗y^{*} to be dual-optimal as well, so cTx∗=bTy∗c^{\mathsf{T}}x^{*}=b^{\mathsf{T}}y^{*}, proving strong duality.

UndergraduateReal-World Applications and Worked Examples

Linear programming underlies decision-making software across industries: airlines solve crew-scheduling and fleet-assignment LPs with millions of variables, oil refineries blend crude inputs to meet product specifications at minimum cost, telecom companies route network traffic to maximize throughput, and portfolio managers allocate capital across assets subject to risk limits — all as instances of maximizing or minimizing a linear objective under linear constraints.

Example: Maximizing profit with two products

A factory makes two products, xx and yy units per week, earning profit z=3x+5yz=3x+5y. Production is limited by x≤4x\le 4, 2y≤122y\le 12, and 3x+2y≤183x+2y\le 18, with x,y≥0x,y\ge 0. Find the values of xx and yy that maximize zz.

Solution

The constraint x≤4x\le 4 bounds xx directly, 2y≤122y\le 12 means y≤6y\le 6, and 3x+2y≤183x+2y\le 18 is the binding resource constraint; together with x,y≥0x,y\ge 0 these four lines cut out a pentagon with vertices (0,0)(0,0), (4,0)(4,0), (4,3)(4,3), (2,6)(2,6), and (0,6)(0,6).

By the fundamental theorem, the maximum of the linear objective z=3x+5yz=3x+5y over this bounded feasible polygon occurs at one of these five vertices, so it suffices to evaluate zz at each: z(0,0)=0z(0,0)=0, z(4,0)=12z(4,0)=12, z(4,3)=3(4)+5(3)=27z(4,3)=3(4)+5(3)=27, z(2,6)=3(2)+5(6)=36z(2,6)=3(2)+5(6)=36, and z(0,6)=30z(0,6)=30.

The largest value is z=36z=36, attained at the vertex (x,y)=(2,6)(x,y)=(2,6), which is exactly the point where the constraints 2y≤122y\le 12 and 3x+2y≤183x+2y\le 18 meet, confirming both resources are fully used at the optimum.

Example: Reading resource prices from the dual problem

For the factory in the previous example, suppose management wants to know the marginal value of one more unit of the resource in constraint 3x+2y≤183x+2y\le 18 — that is, how much extra profit one more unit of that resource would be worth. Using the dual problem, find this marginal value (the shadow price) without re-solving the whole linear program from scratch.

Solution

The dual of maximizing z=3x+5yz=3x+5y subject to x≤4x\le 4, 2y≤122y\le 12, 3x+2y≤183x+2y\le 18, x,y≥0x,y\ge 0 is the minimization min⁡ w=4y1+12y2+18y3\min\, w=4y_1+12y_2+18y_3 subject to y1+3y3≥3y_1+3y_3\ge 3, 2y2+2y3≥52y_2+2y_3\ge 5, and y1,y2,y3≥0y_1,y_2,y_3\ge 0, where y1,y2,y3y_1,y_2,y_3 are the dual prices attached to constraints x≤4x\le 4, 2y≤122y\le 12, 3x+2y≤183x+2y\le 18 respectively.

By strong duality, the dual optimal value equals the primal optimal value found earlier, w∗=z∗=36w^{*}=z^{*}=36. At the optimal vertex (x,y)=(2,6)(x,y)=(2,6), only the constraints 2y≤122y\le 12 and 3x+2y≤183x+2y\le 18 are binding (the constraint x≤4x\le 4 is slack since x=2<4x=2<4), so complementary slackness forces the dual price on the slack constraint to be zero: y1=0y_1=0.

With y1=0y_1=0, the remaining dual constraints become 3y3≥33y_3\ge 3 and 2y2+2y3≥52y_2+2y_3\ge 5, and solving the two binding dual equalities 3y3=3 and 2y2+2y3=53y_3=3 \text{ and } 2y_2+2y_3=5 gives y3=1 and y2=1.5y_3=1 \text{ and } y_2=1.5: the shadow price of the constraint 3x+2y≤183x+2y\le 18 is y3=1y_3=1, meaning one more unit of that resource would raise the maximum profit by approximately 11.

In the factory example with objective z=3x+5yz=3x+5y and feasible vertices (0,0)(0,0), (4,0)(4,0), (4,3)(4,3), (2,6)(2,6), (0,6)(0,6), which vertex gives the maximum value of zz?

According to the fundamental theorem of linear programming, if a linear program with a bounded, nonempty feasible region has an optimal solution, where can that optimum always be found?

What does weak duality guarantee about a primal maximization LP and its dual minimization LP?

An airline needs to assign the cheapest combination of crews to flights while satisfying staffing rules and duty-hour limits. Which technique is this problem a typical instance of?

References

  1. George B. Dantzig (1963). Linear Programming and Extensions
  2. Dimitris Bertsimas, John N. Tsitsiklis (1997). Introduction to Linear Optimization