simplex-basic-0.0.0.1: Very basic simplex implementation.

Linear.Simplex.Primal

Synopsis

# Documentation

simplexPrimal :: IneqStdForm -> [IneqStdForm] -> [(String, Rational)] Source

Takes an objective function, a set of constraints, and an operation mode, then returns a substitution. . Objective function should be in the form of `Ax + By + Cz + P = 0`, where `P` is the resule, and free in the constraint set.

nextRow :: [IneqSlack] -> Int -> Maybe Int Source

Finds next pivot row by the smallest ratio in each row. Note: row list should be non-empty

finds next column index from objective function

Computes coefficient ratio to constant, based on a column index. Warning: `Int` parameter must be less than the length of the primal variables.

pivot :: (Int, Int) -> Objective -> [IneqSlack] -> [IneqSlack] Source

flattens targeted row to form the identity at it's column coefficient, then reduces each non-zero row at this column, via a multiple of this flattened row. Heart of the simplex method. Also prepends `objective` back on `constrs`.

Flattens a row for further processing.

Takes the focal row, the row to affect, and the column in question to facilitate the sum-oriented part of the pivot.

Note: Must have identical occurrances of variables, and must be `EquStd`. subtracts rhs from lhs.

getSubst :: [IneqSlack] -> [(String, Rational)] Source

Extracts resulting data from tableau, excluding junk data

makeSlackVars :: MonadState Integer m => IneqStdForm -> m IneqSlack Source

Also translates `Ax >= Q` to `-Ax <= -Q`. Ie; result will exclude `GteStd`.

populate :: [IneqSlack] -> [IneqSlack] Source

Fills missing variables. List of inequalities includes objective function.