The simplex method for linear programs in matrix form #
This module connects the simplex method on dictionaries
(CslibFrontier.Algorithms.Lean.Simplex.Bland) with linear programs given by matrices over a
linearly ordered field, and reads off an optimal dual solution from the final dictionary.
Model #
A dictionary D on variables ι represents the program max c ⬝ᵥ x subject to x ≥ 0,
A *ᵥ x = b (the equational form of [MG07]) when the solutions of D are the
solutions of A *ᵥ x = b and its objective agrees with c ⬝ᵥ x on them (Represents).
Representation is invariant under equivalence of dictionaries, hence under pivoting.
For the program max c ⬝ᵥ x subject to x ≥ 0, A *ᵥ x ≤ b with A : Matrix (Fin m) (Fin n) K,
the slack dictionary (slackDictionary, [Chv83], Chapter 2) has the variables
Fin (n + m): the original variables Fin.castAdd m j and one slack variable Fin.natAdd n i
per row, initially basic with x (natAdd n i) = b i - ∑ j, A i j * x (castAdd m j). It represents
the equational form with the matrix [A | 1] (slackMatrix), and it is feasible when b ≥ 0.
The feasible sets are written {x | 0 ≤ x ∧ A *ᵥ x ≤ b} and {y | 0 ≤ y ∧ c ≤ y ᵥ* A}, as in
Matrix.exists_isGreatest_isLeast_dotProduct_of_nonneg.
Main definitions #
Cslib.Algorithms.Lean.Simplex.Dictionary.Represents: a dictionary represents a linear program in equational form.Cslib.Algorithms.Lean.Simplex.slackDictionary,Cslib.Algorithms.Lean.Simplex.slackMatrix,Cslib.Algorithms.Lean.Simplex.withSlack: the slack dictionary ofA *ᵥ x ≤ b, its equational-form matrix[A | 1], and a point extended by its slacks.Cslib.Algorithms.Lean.Simplex.Dictionary.slackDual: the negated reduced costs of the slack variables of a dictionary, the dual solution read off the final dictionary.
Main results #
Dictionary.simplex_spec_of_represents: the simplex method with Bland's rule, started from a feasible dictionary representingmax c ⬝ᵥ xsubject tox ≥ 0,A *ᵥ x = b, returns an optimal basic feasible solution or proves the program unbounded.Dictionary.Represents.eq_zero_of_mulVec_eq_zero: the basic columns ofAare linearly independent (no nonzero kernel vector ofAis supported on the basis), so the basic solution of a representing dictionary is a basic solution ofA *ᵥ x = b.simplex_slackDictionary_spec: the simplex method solvesmax c ⬝ᵥ xsubject tox ≥ 0,A *ᵥ x ≤ bwhenb ≥ 0.slackDual_nonneg,le_slackDual_vecMul,slackDual_dotProduct,isLeast_dotProduct_slackDual: when the simplex method on the slack dictionary stops at an optimal dictionaryD,D.slackDualis a feasible solution of the dual programmin y ⬝ᵥ bsubject toy ≥ 0,c ≤ y ᵥ* Awhose value is the primal optimumD.objConst, hence (by weak duality) an optimal one ([Chv83], Chapter 5).
Limitations #
Only programs with a feasible starting dictionary are covered: for A *ᵥ x ≤ b, x ≥ 0 this is
the hypothesis b ≥ 0. Phase I is not formalized. Strong duality itself is already in
CslibFrontier.Foundations.LinearAlgebra.Matrix.LinearProgramming, whose weak duality is used here;
the dual solution slackDual is the explicit by-product of the simplex method.
References #
The dictionary D represents the linear program max c ⬝ᵥ x subject to x ≥ 0,
A *ᵥ x = b: its solutions are exactly the solutions of A *ᵥ x = b, and its objective agrees with
c ⬝ᵥ x on them.
Instances For
The basic columns of A are linearly independent: no nonzero vector of the kernel of A is
supported on the basis of a representing dictionary, so the basic solution of the dictionary is a
basic solution of A *ᵥ x = b.
The simplex method with Bland's rule for max c ⬝ᵥ x subject to x ≥ 0, A *ᵥ x = b,
started from a feasible dictionary D representing the program: it returns a dictionary D'
representing the same program whose basic solution is an optimal basic feasible solution, or it
proves the objective unbounded on the feasible set.
The slack dictionary of max c ⬝ᵥ x subject to x ≥ 0, A *ᵥ x ≤ b #
The slack dictionary of max c ⬝ᵥ x subject to x ≥ 0, A *ᵥ x ≤ b
([Chv83], Chapter 2): the variables are Fin (n + m), with the original variable j at
Fin.castAdd m j and the slack variable of row i at Fin.natAdd n i; the slack variables are
basic, with x (natAdd n i) = b i - ∑ j, A i j * x (castAdd m j), and the objective is
∑ j, c j * x (castAdd m j).
Instances For
The slack dictionary represents the equational form [A | 1] *ᵥ z = b, z ≥ 0 of
A *ᵥ x ≤ b, x ≥ 0, with the objective c extended by zeros.
The slack dictionary is feasible exactly when b ≥ 0.
Every solution of the slack dictionary is a point extended by its slacks.
The slack dictionary describes the program max c ⬝ᵥ x subject to x ≥ 0, A *ᵥ x ≤ b.
The simplex method with Bland's rule for max c ⬝ᵥ x subject to x ≥ 0, A *ᵥ x ≤ b
with b ≥ 0, started from the slack dictionary: it finds an optimal solution, read off the
first n coordinates of the final basic solution, or proves the objective unbounded.
The dual solution read off a dictionary on the variables of a slack dictionary: the
negated reduced cost of the slack variable of each row, and 0 when that slack variable is basic.
For the final dictionary of the simplex method on slackDictionary A b c this is an optimal
solution of the dual program (isLeast_dotProduct_slackDual).
Instances For
The dual solution read off the final dictionary is nonnegative ([Chv83], Chapter 5): the reduced costs of the final dictionary are nonpositive.
The dual solution read off the final dictionary satisfies the dual constraints
c ≤ y ᵥ* A ([Chv83], Chapter 5).
The dual solution read off the final dictionary has value D.objConst, the primal
optimum ([Chv83], Chapter 5).
The final dictionary certifies dual optimality ([Chv83], Chapter 5). When the simplex
method on the slack dictionary stops at an optimal dictionary D, D.slackDual is a feasible
solution of the dual program min y ⬝ᵥ b subject to y ≥ 0, c ≤ y ᵥ* A, and D.objConst is
the least dual value: by weak duality
(Matrix.dotProduct_le_dotProduct_of_nonneg_of_mulVec_le) no dual solution is below the primal
optimum D.objConst, which D.slackDual attains.