In case there are no surplus variables (only slacks), the slack variables can form an inittial basis.
In case there are no surplus variables (only slacks), the slack variables can form an inittial basis.
the M-by-N constraint matrix
the M-length limit/RHS vector (input b_i negative for surplus)
the N-length cost vector
the M-by-N constraint matrix
the M-length limit/RHS vector (input b_i negative for surplus)
the N-length cost vector
the indices of the initial basis (if not available use Simple2P)
Determine whether the current solution is correct.
Determine whether the current solution is correct.
the primal solution vector x
the dual solution vector y
the minimum value of the objective function
Return the dual solution vector y (cost row (M) under the slack columns).
Find the best variable x_l to enter the basis.
Find the best variable x_l to enter the basis. Determine the index of entering variable corresponding to COLUMN l (e.g., using Dantiz's Rule or Bland's Rule). Return -1 to indicate no such column. t(M).argmaxPos (JJ) // use Dantiz's rule (index of max +ve, cycling possible) t(M).firstPos (JJ) // use Bland's rule (index of first +ve, FPE possible)
Show the flaw by printing the error message.
Show the flaw by printing the error message.
the method where the error occurred
the error message
Determine whether the current solution (x = primal) is still primal feasible.
Find the best variable x_k to leave the basis given that x_l is entering.
Find the best variable x_k to leave the basis given that x_l is entering. Determine the index of the leaving variable corresponding to ROW k using the Min-Ratio Rule. Return -1 to indicate no such row.
the entering variable (column)
Return the value of the objective function f(x) = c x.
Return the value of the objective function f(x) = c x.
the coordinate values of the current point
Pivot on entry (k, l) using Gauss-Jordan elimination to replace variable x_k with x_l in the basis.
Pivot on entry (k, l) using Gauss-Jordan elimination to replace variable x_k with x_l in the basis.
the leaving variable (row)
the entering variable (column)
Return the primal solution vector x (only the basic variables are non-zero).
Show the current tableau.
Show the current tableau.
the number of iterations do far
Run the Simplex Algorithm starting from an initial BFS and iteratively find a non-basic variable to replace a variable in the current basis so long as the objective function improves.
Run the Simplex Algorithm starting from an initial BFS and iteratively find a non-basic variable to replace a variable in the current basis so long as the objective function improves. Return the optimal vector x.
Convert the current tableau and basis to a string suitable for display.
Convert the current tableau and basis to a string suitable for display.
This class solves Linear Programming (LP) problems using a tableau based Simplex Algorithm. Given a constraint matrix 'a', limit/RHS vector 'b' and cost vector 'c', find values for the solution/decision vector 'x' that minimize the objective function f(x), while satisfying all of the constraints, i.e.,
minimize f(x) = c x subject to a x <= b, x >= 0
In case of "a_i x >= b_i", use -b_i as an indicator of a ">=" constraint. The program will flip such negative b_i back to positive as well as use a surplus variable instead of the usual slack variable, i.e., a_i x <= b_i => a_i x + s_i = b_i // use slack variable s_i with coeff 1 a_i x >= b_i => a_i x + s_i = b_i // use surplus variable s_i with coeff -1
Creates an MM-by-NN simplex tableau with -- [0..M-1, 0..N-1] = a (constraint matrix) -- [0..M-1, N..M+N-1] = s (slack/surplus variable matrix) -- [0..M-1, NN-1] = b (limit/RHS vector) -- [M, 0..NN-2] = c (cost vector)