summaryrefslogtreecommitdiff
path: root/packages/glpk/examples/simplex2.hs
blob: e9e88593a932ecf9d482260449d481044f0145a5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
import Numeric.LinearProgramming

prob = Maximize [4, -3, 2]

constr1 = Sparse [ [2#1, 1#2] :<=: 10
                 , [1#2, 5#3] :<=: 20
                 ]

constr2 = Dense [ [2,1,0] :<=: 10
                , [0,1,5] :<=: 20
                ]

main = do
    print $ simplex prob constr1 []
    print $ simplex prob constr2 []
    print $ simplex prob constr2 [ 2 :>=: 1, 3 :&: (2,7)]
    print $ simplex prob constr2 [ Free 2 ]