@@ -13,24 +13,14 @@ import Data.List (sort)
1313import qualified Data.Map as M
1414import GHC.Generics (Generic )
1515
16+ -- | Variable identifier used in maps and constraints.
17+ -- Conventionally this maps to x1, x2, ... in examples.
1618type Var = Int
1719
20+ -- | Numeric type used throughout simplex computations.
1821type SimplexNum = Rational
1922
20- type SystemRow = PolyConstraint
21-
22- type System = [SystemRow ]
23-
24- -- A 'Tableau' where the basic variable may be empty.
25- -- All non-empty basic vars are slack vars
26- data SystemWithSlackVarRow = SystemInStandardFormRow
27- { mSlackVar :: Maybe Var
28- -- ^ This is Nothing iff the row does not have a slack variable
29- , row :: TableauRow
30- }
31-
32- type SystemWithSlackVars = [SystemWithSlackVarRow ]
33-
23+ -- | A feasible system produced by phase one, ready for phase two optimization.
3424data FeasibleSystem = FeasibleSystem
3525 { dict :: Dict
3626 , slackVars :: [Var ]
@@ -66,6 +56,7 @@ data SimplexResult = SimplexResult
6656 }
6757 deriving (Show , Read , Eq , Generic )
6858
59+ -- | Mapping from variable id to its numeric value/coefficient.
6960type VarLitMap = M. Map Var SimplexNum
7061
7162-- | List of variables with their 'SimplexNum' coefficients.
@@ -75,7 +66,7 @@ type VarLitMap = M.Map Var SimplexNum
7566type VarLitMapSum = VarLitMap
7667
7768-- | For specifying constraints in a system.
78- -- The LHS is a 'Vars ', and the RHS, is a 'SimplexNum' number.
69+ -- The LHS is a 'VarLitMapSum ', and the RHS, is a 'SimplexNum' number.
7970-- LEQ [(1, 2), (2, 1)] 3.5 is equivalent to 2x1 + x2 <= 3.5.
8071-- Users must only provide positive integer variables.
8172--
@@ -87,25 +78,18 @@ data PolyConstraint
8778 deriving (Show , Read , Eq , Generic )
8879
8980-- | Create an objective function.
90- -- We can either 'Max'imize or 'Min'imize a 'VarTermSum '.
81+ -- We can either 'Max'imize or 'Min'imize a 'VarLitMapSum '.
9182data ObjectiveFunction = Max { objective :: VarLitMapSum } | Min { objective :: VarLitMapSum }
9283 deriving (Show , Read , Eq , Generic )
9384
94- -- | TODO: Maybe we want this type
95- -- TODO: A better/alternative name
96- data Equation = Equation
97- { lhs :: VarLitMapSum
98- , rhs :: SimplexNum
99- }
100-
10185-- | Value for 'Tableau'. lhs = rhs.
10286data TableauRow = TableauRow
10387 { lhs :: VarLitMapSum
10488 , rhs :: SimplexNum
10589 }
10690 deriving (Show , Read , Eq , Generic )
10791
108- -- | A simplex 'Tableu ' of equations.
92+ -- | A simplex 'Tableau ' of equations.
10993-- Each entry in the map is a row.
11094type Tableau = M. Map Var TableauRow
11195
@@ -126,6 +110,9 @@ data DictValue = DictValue
126110-- deriving (Show, Read, Eq, Generic)
127111type Dict = M. Map Var DictValue
128112
113+ -- | Objective row representation used during pivoting.
114+ -- 'variable' is the objective basic variable and 'function'/'constant' encode
115+ -- the objective in dictionary form.
129116data PivotObjective = PivotObjective
130117 { variable :: Var
131118 , function :: VarLitMapSum
0 commit comments