comfort-glpk

Linear Programming using GLPK and comfort-array

LTS Haskell 22.18:0.1@rev:1
Stackage Nightly 2024-04-27:0.1@rev:1
Latest on Hackage:0.1@rev:1

See all snapshots comfort-glpk appears in

BSD-3-Clause licensed and maintained by Henning Thielemann
This version can be pinned in stack with:comfort-glpk-0.1@sha256:b8c2b8256d6e3c87309f310543973b907442c2256ab66ae8f1d34d64f489a441,2829

Module documentation for 0.1

Simple interface to linear programming functions provided by GLPK using the flexible Array shape framework from comfort-array.

E.g. you can use Shape.Tuple to convert safely between nested tuples and arrays with the same number of elements.

type X = Shape.Element
type PairShape = Shape.NestedTuple Shape.TupleIndex (X,X)

case Shape.indexTupleFromShape (Shape.static :: PairShape) of
  (posIx,negIx) ->
    case mapSnd (mapSnd Array.toTuple) <$>
         LP.simplex [] [[1.*posIx, (-1).*negIx] ==. 314]
           (LP.Minimize,
            Array.fromTuple (23,42) :: Array PairShape Double)
      of
        (Right (LP.Optimal, (absol, (pos, neg)))) ->
          printf "absol %f,  pos %f, neg %f\n" absol pos neg
        _ -> fail "GLPK solver failed"

Alternatives: coinor-clp, hmatrix-glpk, glpk-hs