Simplex dictionaries and pivoting #
This module sets up the dictionaries of the simplex method ([Chv83], Chapters 2 and 3) over
an arbitrary field, with the order-dependent statements over a linearly ordered field (ℚ, ℝ,
…), and proves that pivoting preserves the solution set, the objective, and feasibility, together
with the two stopping certificates: optimality and unboundedness.
Model #
The variables are indexed by a finite linearly ordered type ι. A Dictionary ι K consists of a
set basis of basic variables, and for each basic i a row expressing it through the nonbasic
variables, x i = rhs i + ∑ j ∉ basis, coeff i j * x j, together with an objective row
objConst + ∑ j ∉ basis, objCoeff j * x j. Entries of rhs, coeff and objCoeff outside these
index ranges are ignored. IsSolution D x says that x : ι → K satisfies every row (no sign
condition), and D.value x is the objective at x. The linear program described by D is to
maximize D.value x over D.feasibleSet = {x | D.IsSolution x ∧ 0 ≤ x}. Two dictionaries are
Equivalent when they have the same solutions and agree on the objective there.
The basic solution D.basicSolution sets the nonbasic variables to 0; D is Feasible when
it is nonnegative, that is 0 ≤ rhs i for every basic i.
Source mapping #
[Chv83], Chapter 2, writes a dictionary as x_i = b_i - ∑ a_ij x_j, z = v + ∑ c_j x_j;
here the sign of the coefficients is absorbed into coeff, so coeff i j = -a_ij. Pivoting
on a basic r (leaving) and a nonbasic s (entering) with coeff r s ≠ 0 solves row r for
x s and substitutes into the other rows and the objective (pivot); pivot sets the entries
outside the new index ranges to 0. The entering variable increases along the edge
D.basicSolution + t • D.ray s; the ratio test bounds t by D.ratio s r = rhs r / -coeff r s
for the rows with coeff r s < 0.
Main definitions #
Cslib.Algorithms.Lean.Simplex.Dictionary: a simplex dictionary.Dictionary.IsSolution,Dictionary.value,Dictionary.feasibleSet: the linear program it describes;Dictionary.Equivalent: equivalence of dictionaries.Dictionary.basicSolution,Dictionary.Feasible: the basic solution and feasibility.Dictionary.pivot,Dictionary.ray,Dictionary.ratio: pivoting, the edge direction of an entering variable and the ratio test.
Main results #
Dictionary.equivalent_pivot: a pivot on a nonzero coefficient yields an equivalent dictionary.Dictionary.basicSolution_pivot,Dictionary.objConst_pivot: the pivot moves the basic solution along the edge of the entering variable by the ratio of the leaving row.Dictionary.feasible_pivot,Dictionary.objConst_le_pivot: under the ratio test the pivot preserves feasibility, and with a nonnegative reduced cost it does not decrease the objective.Dictionary.isGreatest_value: if no reduced cost is positive, the basic solution of a feasible dictionary is optimal.Dictionary.not_bddAbove_value: if an entering variable has no leaving row, the objective is unbounded on the feasible set.
References #
A simplex dictionary ([Chv83], Chapter 2) on the variables ι: each basic variable
i ∈ basis is expressed as x i = rhs i + ∑ j ∉ basis, coeff i j * x j, and the objective as
objConst + ∑ j ∉ basis, objCoeff j * x j. Entries outside these index ranges are ignored.
- basis : Finset ι
The basic variables.
- rhs : ι → K
The constant term of the row of each basic variable.
- coeff : ι → ι → K
coeff i jis the coefficient of the nonbasicx jin the row of the basicx i. - objConst : K
The constant term of the objective row: the objective value of the basic solution.
- objCoeff : ι → K
The reduced costs:
objCoeff jis the coefficient of the nonbasicx jin the objective row.
Instances For
x satisfies every row of D. No sign condition is imposed.
Instances For
The objective of D at x.
Instances For
The basic solution of D: the nonbasic variables are 0, so each basic x i is
rhs i.
Instances For
D and D' describe the same linear program: they have the same solutions, and their
objectives agree on them.
- value_eq (x : ι → K) : D.IsSolution x → D.value x = D'.value x
Instances For
The pivot of D on the leaving basic variable r and the entering nonbasic variable s
([Chv83], Chapter 2): row r is solved for x s, which is substituted into the other rows
and into the objective. The new basis is insert s (D.basis.erase r). Entries outside the new
index ranges are set to 0. The result is meaningful when r ∈ D.basis, s ∉ D.basis and
D.coeff r s ≠ 0.
Instances For
The edge direction of the nonbasic variable s: increasing x s by t while keeping the
other nonbasic variables at 0 changes each basic x i by t * coeff i s.
Instances For
The ratio test: when coeff i s < 0, row i stays nonnegative along the edge of s for
step lengths up to rhs i / -coeff i s.
Instances For
A solution vanishing off the basis is the basic solution.
Pivoting #
A pivot on a nonzero coefficient preserves the solutions.
A pivot on a nonzero coefficient preserves the objective on solutions.
Pivoting yields an equivalent dictionary ([Chv83], Chapter 2): a pivot on a basic
r, a nonbasic s and a nonzero coefficient D.coeff r s preserves the solutions and the
objective.
The edge direction of an entering variable #
Moving a solution along the edge of a nonbasic variable keeps it a solution.
Along the edge of a nonbasic s the objective changes at rate objCoeff s.
The pivot on r and s moves the basic solution along the edge of s by the ratio of
row r.
The pivot on r and s changes the objective value of the basic solution by
objCoeff s * ratio s r.
D is feasible when its basic solution is nonnegative ([Chv83], Chapter 2).
Instances For
The feasible set of the linear program described by D.
Instances For
The ratio test preserves feasibility ([Chv83], Chapter 2): pivoting a feasible
dictionary on a row r with coeff r s < 0 of minimal ratio yields a feasible dictionary.
A pivot on a row r with coeff r s < 0 of a feasible dictionary, entering a variable with
nonnegative reduced cost, does not decrease the objective value of the basic solution.
Optimality certificate ([Chv83], Chapter 2): if no reduced cost of a feasible
dictionary is positive, its basic solution is optimal, with value objConst.
Unboundedness certificate ([Chv83], Chapters 2–3): if a nonbasic variable of a feasible dictionary has a positive reduced cost and no row bounds its increase, the objective is unbounded on the feasible set.
Equivalent dictionaries describe the same linear program.