Feasible region

Tableau

◆ The Blueprint
Standard form

A linear program (LP) in standard form minimizes \(c^\top x\) subject to \(Ax = b\) and \(x \ge 0\). A maximization becomes a minimization by negating \(c\), and each \(\le\) constraint becomes an equation by adding a slack variable that is 0 when the constraint is tight.

Basic feasible solutions

With \(m\), the number of constraints, pick \(m\) linearly independent columns of \(A\) as the basis \(B\). Setting the other variables to 0 gives \(x_B = B^{-1}b\). If \(x_B \ge 0\), the point is a basic feasible solution, which is a corner of the feasible region. If an LP has an optimum, some corner is optimal, so the method searches only corners.

The reduced cost

Raise nonbasic \(x_j\) by one unit and hold the other nonbasic variables at 0. To keep \(Ax = b\), the basic variables change by \(-B^{-1}A_j\), so the objective changes by the reduced cost below, where \(c_B\) holds the objective coefficients of the basic variables.

$$\bar c_j = c_j - c_B^\top B^{-1}A_j .$$

The tableau stores \(B^{-1}A\) in its rows and \(\bar c\) in its bottom row. If every \(\bar c_j \ge 0\), no direction from the corner lowers \(z\), and because the region is convex and \(z\) is linear, the corner is optimal.

Pivot rules

Dantzig's rule enters the most negative \(\bar c_j\). The ratio test leaves the basic variable with the smallest \(\text{RHS}_i/a_{ij}\) over \(a_{ij} > 0\), the first to reach 0. A pivot divides the pivot row by \(a_{ij}\) and subtracts multiples of it from every other row, so column \(j\) becomes a column of the identity. When a basic variable is already 0, a pivot can change the basis without moving (a degenerate pivot), and Dantzig's rule can then cycle; Bland's rule (enter and leave by lowest index) never cycles.

Starting when the origin is not a corner

A \(\ge\) or \(=\) constraint has no slack that can start the basis. The Big-M method adds an artificial variable with a large cost \(M\) (here 1,000) and starts from it; the two-phase method first minimizes the sum of the artificial variables. Either way, an artificial variable still positive at the end means the constraints have no common point.

Reference

Bertsimas and Tsitsiklis, Introduction to Linear Optimization (1997), chapter 3. In R, part 1 of The Script repeats every pivot by hand and checks the optimum with lpSolve::lp().

Edges from the corner

Edges

◆ The Blueprint
Corners

With \(n\) decision variables, a corner of the region is a feasible point where \(n\) independent constraints are tight. In standard form it is a basic feasible solution: the nonbasic variables are 0 and \(x_B = B^{-1}b \ge 0\).

Basic directions

For nonbasic \(x_j\), the basic direction \(d\) has

$$d_j = 1, \qquad d_k = 0 \text{ for the other nonbasic } k, \qquad d_B = -B^{-1}A_j ,$$

so \(A d = A_j - B B^{-1} A_j = 0\) and \(x + \theta d\) still satisfies \(Ax = b\). The objective changes at rate \(c^\top d = c_j - c_B^\top B^{-1}A_j = \bar c_j\) per unit of \(\theta\). In two dimensions each basic direction runs along an edge of the region.

The step length
$$\theta^* = \min_{i:\; d_{B(i)} < 0} \frac{x_{B(i)}}{-d_{B(i)}}$$

keeps every basic variable nonnegative, and \(x + \theta^* d\) is the adjacent corner. If no \(d_{B(i)}\) is negative, \(\theta^* = \infty\); with \(\bar c_j < 0\) the LP is then unbounded. If some \(x_{B(i)} = 0\) with \(d_{B(i)} < 0\), \(\theta^* = 0\) and the corner is degenerate.

Why a corner with no improving edge is optimal

Every feasible direction from a corner is a nonnegative combination of its basic directions, so if each has \(\bar c_j \ge 0\), every feasible direction has \(c^\top d \ge 0\). A linear objective that cannot fall in any feasible direction from a point of a convex region is at its minimum there.

Reference

Bertsimas and Tsitsiklis (1997), sections 3.1 and 3.2. Part 2 of The Script prints the directions from the tableau.

The plan: products

The dual: prices

Best profit as the right-hand side changes

Shadow prices
Complementary slackness
Allowable ranges
◆ The Blueprint
The dual problem

For the primal \(\max\, c^\top x\) subject to \(Ax \le b\), \(x \ge 0\), the dual is

$$\min\; b^\top p \quad \text{subject to} \quad A^\top p \ge c, \;\; p \ge 0 .$$

In the minimization form the tableau uses (min \(c^\top x\), \(Ax = b\)), the dual is \(\max\, p^\top b\) subject to \(p^\top A \le c^\top\), and the simplex method's prices are \(p^\top = c_B^\top B^{-1}\). Then \(\bar c_j = c_j - p^\top A_j\), so "every \(\bar c_j \ge 0\)" is the statement that \(p\) is dual feasible.

Weak and strong duality

For any feasible plan \(x\) and feasible prices \(p\) of the max problem, \(c^\top x \le (A^\top p)^\top x = p^\top A x \le p^\top b\): every feasible dual point bounds the best profit from above. At the optimum the two are equal. At every pivot, \(p^\top b = c_B^\top B^{-1} b = c_B^\top x_B\), the current objective; the prices become feasible only at the last pivot.

Complementary slackness

At the optimum, \(x_j \bar c_j = 0\) for every variable, slacks included. A slack's reduced cost is its constraint's price, so a constraint with slack has price 0, and a positive variable has \(\bar c_j = 0\): the resources it uses are worth exactly its profit.

Allowable ranges

Changing \(b_i\) by \(\delta\) changes the basic values to \(x_B + \delta\, B^{-1} e_i\). The basis, and so the price \(p_i\), stays optimal while every basic value stays nonnegative; the first one to reach 0 ends the range. Changing a profit coefficient \(c_j\) changes the reduced costs instead, and the plan stays optimal while every reduced cost stays nonnegative. At the ends of a range the optimal corner changes and the price jumps: the best profit is a piecewise linear, concave function of \(b_i\). When more than one plan is optimal, another basis can take over with the same price, so a price can apply past the end of its basis's range: the factory's budget price of 1 applies up to 42, past the basis's 30. The ranges on the tab are where each price applies, found by re-solving.

Reference

Bertsimas and Tsitsiklis (1997), chapter 4 and section 5.1. Part 3 of The Script gets every price and range from lp(..., compute.sens = TRUE).

Network

Data

◆ The Blueprint
Whole-number answers without integer constraints

A matrix is totally unimodular when every square submatrix has determinant 0, 1, or −1. If \(A\) is totally unimodular and \(b\) is a vector of whole numbers, every corner of \(\{x : Ax = b,\ x \ge 0\}\) has whole-number coordinates (Cramer's rule divides by a determinant of ±1). The simplex method stops at a corner, so it returns whole numbers.

The constraint matrix of a transportation or assignment problem is the incidence matrix of a bipartite graph: each column has one 1 in a supplier (or worker) row and one 1 in a customer (or task) row. Such a matrix is totally unimodular (Heller and Tompkins, 1956), and so is the node-arc matrix of a max-flow problem (one row per node, one column per arc, with +1 where the arc enters the node and −1 where it leaves). Integer programs are hard in general, and these problems are solved as plain linear programs because of their structure.

Transportation prices

Supplies and demands both total 75, so the six equations have rank 5 and the prices are unique only up to a shift: adding \(k\) to every \(u_i\) and subtracting \(k\) from every \(v_j\) changes nothing. Here \(u_1\) is fixed at 0, as the modified distribution (MODI) method, a hand method for these prices, also does. The shift-free quantity is \(u_i + v_j\), the cost change when supplier \(i\) ships one more unit and customer \(j\) takes it. On every route in use, \(u_i + v_j = c_{ij}\) (complementary slackness), and on every route, \(u_i + v_j \le c_{ij}\) (dual feasibility).

Max-flow min-cut

A cut splits the nodes into a set holding the source and a set holding the sink; its capacity is the total capacity of arcs from the first set to the second. Every unit of flow crosses every cut, so no flow exceeds any cut's capacity. The dual of the max-flow LP is a minimum-cut problem, and strong duality makes the maximum flow equal the minimum cut's capacity (Ford and Fulkerson, 1956). The capacity rows with shadow price 1 are the arcs of a minimum cut.

Blending

The blending problem's shadow prices are in dollars per unit of feed per percentage point of the requirement. Each requirement is written as stated (protein at least 18%), and its price is the cost change when that requirement rises by one point.

In R

lp.transport(), lp.assign(), and lp() in lpSolve solve all four. Part 4 of The Script solves each one and repeats the best change in each task.

lpSolve, function by function
CallWhat it returns
lp("max", obj, A, dir, rhs)The optimum of a linear program with rows A %*% x dir rhs and every x ≥ 0. $status is 0 when solved, 2 when infeasible, and 3 when unbounded.
$solution, $objvalThe optimal plan and its objective.
lp(..., compute.sens = TRUE)Adds $duals (the constraints' shadow prices, then the variables' reduced costs), $duals.from and $duals.to (each binding constraint's allowable range of right-hand sides), and $sens.coef.from and $sens.coef.to (each objective coefficient's range).
lp.transport(costs, "min", ...)A transportation problem from its cost matrix, supplies, and demands; $solution is the shipment matrix.
lp.assign(costs)An assignment problem from its cost matrix; $solution is the 0-1 assignment matrix.
lp_in_R.R