glpk-hs-0.2.0: Comprehensive GLPK linear programming bindings



Contains sufficient tools to represent linear programming problems in Haskell. In the future, if linkings to other linear programming libraries are made, this will be common to them all.



data Constraint v c Source

Representation of a linear constraint on the variables, possibly labeled. The function may be bounded both above and below.


Constr (Maybe String) (LinFunc v c) (Bounds c) 


Functor (Constraint v) 
(Read v, Ord v, Read c, Ord c, Num c) => Read (Constraint v c) 
(Show v, Num c, Ord c) => Show (Constraint v c) 

type VarTypes v = Map v VarKindSource

A mapping from variables to their types. Variables not mentioned are assumed to be continuous,

type ObjectiveFunc = LinFuncSource

An objective function for a linear program.

type VarBounds v c = Map v (Bounds c)Source

A mapping from variables to their boundaries. Variables not mentioned are assumed to be free.

data LP v c Source

The specification of a linear programming problem with variables in v and coefficients/constants in c. Note: the Read and Show implementations do not correspond to any particular linear program specification format.




Functor (LP v) 
(Num c, Ord v, Ord c, Read v, Read c) => Read (LP v c) 
(Num c, Ord c, Show v) => Show (LP v c) 

mapVars :: (Ord v', Ord c, Group c) => (v -> v') -> LP v c -> LP v' cSource

Applies the specified function to the variables in the linear program. If multiple variables in the original program are mapped to the same variable in the new program, in general, we set those variables to all be equal, as follows.

  • In linear functions, including the objective function and the constraints, coefficients will be added together. For instance, if v1,v2 are mapped to the same variable v', then a linear function of the form c1 *& v1 ^+^ c2 *& v2 will be mapped to (c1 ^+^ c2) *& v'.
  • In variable bounds, bounds will be combined. An error will be thrown if the bounds are mutually contradictory.
  • In variable kinds, the most restrictive kind will be retained.

mapVals :: (c -> c') -> LP v c -> LP v c'Source

Applies the specified function to the constants in the linear program. This is only safe for a monotonic function.

data Bounds a Source


LBound a 
UBound a 
Equ a 
Bound a a 


Functor Bounds 
Eq a => Eq (Bounds a) 
Read a => Read (Bounds a) 
Show a => Show (Bounds a) 
Ord a => Monoid (Bounds a)