simplex-basic-0.0.0.1: Very basic simplex implementation.

Safe HaskellSafe
LanguageHaskell2010

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

nextColumn :: IneqSlack -> Maybe Int Source

finds next column index from objective function

coeffRatio :: IneqSlack -> Int -> Maybe Rational Source

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.

flatten :: IneqSlack -> Int -> IneqSlack Source

Flattens a row for further processing.

compensate :: IneqSlack -> IneqSlack -> Int -> IneqSlack Source

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

diffZip :: IneqSlack -> IneqSlack -> IneqSlack Source

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.