Exported SimplexTableaux Functions and their Docstrings
SimplexTableaux.Tableau — Type
Tableau(A::Matrix, b::Vector, c::Vector, canonical::Bool=false)If the LP is in standard form, minimize $c'x$ s.t. $Ax = b, x ≥ 0$, use Tableau(A, b, c).
If the LP is in canonical form, minimize $c'x$ subject to $Ax ≥ b, x ≥ 0$, use Tableau(A, b, c, false).
SimplexTableaux.basic_vector — Method
basic_vector(T::Tableau)Return the basic vector for T. This is the vector in which all nonbasic variables are 0.
SimplexTableaux.big_M_solve! — Function
big_M_solve!(T::Tableau, M::Int=100, verbose::Bool=true)Solve the LP T using the big-M method.
SimplexTableaux.big_M_tableau — Function
big_M_tableau(T::Tableau, M::Int=100)Form a new tableau from T by adding m artificial variables and add the terms +M*x_i (for each artificial variable x_i) to the objective function. Then set the basis to the columns for the artifical variables.
SimplexTableaux.check_basis — Method
check_basis(T::Tableau, vars::Vector{Int})::BoolSee if the list of column indices vars forms a basis (feasible or not) for T.
SimplexTableaux.dual — Method
dual(T::Tableau)Create a tableau that is dual to T.
Caveats:
Tshould have been created from canonical data (not standard). [Standard LPs TBW.]- The returned tableau is set up as a minimization problem so the value of the solved LP is negative the desired value. However, the basic feasible vector is correct.
SimplexTableaux.dual_basic_vector — Method
dual_basic_vector(T::Tableau)Return the dual basic vector for T.
SimplexTableaux.find_a_basis — Function
find_a_basis(T::Tableau, verbose::Bool=true)Return a feasible basis for the LP in T or nothing if none exists.
SimplexTableaux.find_all_bases — Method
find_all_bases(T::Tableau)Return a list of all feasible bases for T.
SimplexTableaux.find_pivot — Method
find_pivot(T::Tableau, j::Int)Find a valid pivot in column j. Returns (i,j) showing where to pivot.
SimplexTableaux.find_pivot — Method
find_pivot(T::Tableau)Find a valid pivot for T or return (0,0) if none exists.
SimplexTableaux.find_pivot_column — Method
find_pivot_column(T::Tableau)Find a column with the most negative reduced cost (i.e., the most positive value in the top row of the tableau).
SimplexTableaux.get_Abc — Method
get_Abc(T::Tableau)Returns a 3-tuple containing copies of the matrix A and the vectors b and c used to create T.
SimplexTableaux.get_basis — Method
get_basis(T::Tableau)Return the current basis (indices of basic variables).
SimplexTableaux.header — Method
header(T::Tableau)Return the header (negative reduced costs) of T.
Example
For this Tableau
┌──────────┬───┬─────┬─────┬─────┬─────┬─────┬─────┐
│ │ z │ x_1 │ x_2 │ x_3 │ x_4 │ x_5 │ RHS │
│ Obj Func │ 1 │ -2 │ -4 │ -2 │ -1 │ 1 │ 0 │
├──────────┼───┼─────┼─────┼─────┼─────┼─────┼─────┤
│ Cons 1 │ 0 │ 2 │ 1 │ 0 │ 9 │ -1 │ 9 │
│ Cons 2 │ 0 │ 1 │ 1 │ -1 │ 5 │ 1 │ 7 │
└──────────┴───┴─────┴─────┴─────┴─────┴─────┴─────┘header(T) returns the vector [-2, -4, -2, -1, 1].
SimplexTableaux.in_dual_feasible_state — Method
in_dual_feasible_state(T::Tableau)::BoolDetermine if the header of T is entirely nonpositive.
SimplexTableaux.in_feasible_state — Method
in_feasible_state(T::Tableau)::BoolReturn true is the current state of T is at a feasible vector.
SimplexTableaux.in_optimal_state — Method
in_optimal_state(T::Tableau)::BoolDetermine if T has been pivoted to a global minimum state.
SimplexTableaux.infer_basis! — Method
infer_basis!(T::Tableau, x::Vector)When x is a basic feasbile vector for T, determine a basis of columns to that effect.
SimplexTableaux.infer_basis! — Method
infer_basis!(T::Tableau)Find the columns that form an elementary basis in T and assign that basis to T
SimplexTableaux.is_canonical — Method
is_canonical(T::Tableau)::BoolReturn true if T was created from a canonical LP and return false if it was created from a standard LP.
SimplexTableaux.is_infeasible — Method
is_infeasible(T::Tableau)::BoolReturn true if the tableau represents an infeasible linear program (i.e., the feasible region is empty).
SimplexTableaux.is_unbounded — Method
is_unbounded(T::Tableau)::BoolReturn true is the linear program is unbounded (below).
SimplexTableaux.lp_solve — Function
lp_solve(T::Tableau, verbose::Bool=true)Use a standard linear programming solver [HiGHS by defaut] to find the optimal solution to the LP in T. Returns the values of the variables.
With verbose set to true [default], the value of the objective function is printed. Set verbose to false to supress this.
SimplexTableaux.phase_one_tableau — Method
phase_one_tableau(T::Tableau)Create a tableau with additional slack variables from which it is easy to extract a basis for T or determine that T is infeasible.
SimplexTableaux.pivot! — Method
pivot!(T::Tableau, i::Int, j::Int)Modify T by doing a pivot operation at constraint i and variable x_j.
SimplexTableaux.ratios — Method
ratios(T::Tableau, col::Int)Display a table for determining a valid pivot for T in column col.
SimplexTableaux.restore! — Method
restore!(T::Tableau)Restore a Tableau based on the original data used to create it.
SimplexTableaux.rhs — Method
rhs(T::Tableau)Return the right-hand column of the T.
Example
For this Tableau
┌──────────┬───┬─────┬─────┬─────┬─────┬─────┬─────┐
│ │ z │ x_1 │ x_2 │ x_3 │ x_4 │ x_5 │ RHS │
│ Obj Func │ 1 │ -2 │ -4 │ -2 │ -1 │ 1 │ 0 │
├──────────┼───┼─────┼─────┼─────┼─────┼─────┼─────┤
│ Cons 1 │ 0 │ 2 │ 1 │ 0 │ 9 │ -1 │ 9 │
│ Cons 2 │ 0 │ 1 │ 1 │ -1 │ 5 │ 1 │ 7 │
└──────────┴───┴─────┴─────┴─────┴─────┴─────┴─────┘rhs(T) returns the vector [9,7].
SimplexTableaux.scale_row! — Method
scale_row!(T::Tableau, i::Int, m::_Exact)Modify T by multiplying row i (the i-th constraint) by m.
SimplexTableaux.set_basis! — Method
set_basis!(T::Tableau, vars::Vector{Int})Pivot T so that the variables specified in vars are the basic variables.
SimplexTableaux.set_basis! — Method
set_basis!(T::Tableau)Invoke find_a_basis(T) and use the result to establish a basis for T. Silently fail if no basis is found.
SimplexTableaux.simplex_solve! — Function
simplex_solve!(T::Tableau, verbose::Bool=true)Solve T using the simplex method.
SimplexTableaux.status — Method
status(T::Tableau)::SymbolReturn an indicator for the status of the tableau T being one of:
:no_basis– no basis has been established for this tableau:feasible– the tableau is in a feasible state, but not optimal (rhs is nonnegative).:infeasible– the tableau is in an infeasible state (rhs contains negative values).:optimal– the tableau has reached a global minimization point.:unbounded– no pivots are possible; objective function can be arbitrarily negative.
SimplexTableaux.swap_rows! — Method
swap_rows!(T::Tableau, i::Int, j::Int)Swap constraint rows i and j in the tableau T.
SimplexTableaux.value — Method
value(T::Tableau, x::Vector)Return the value of the LP in T at the point x.
This can also be invoked as T(x).
SimplexTableaux.value — Method
value(T::Tableau)Return the value of the LP at the current basic vector.