1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
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
]
constr3 = General [ [1#1, 1#1, 1#2] :<=: 10
, [1#2, 5#3] :<=: 20
]
main = do
print $ simplex prob constr1 []
print $ simplex prob constr2 []
print $ simplex prob constr3 []
print $ simplex prob constr2 [ 2 :>=: 1, 3 :&: (2,7)]
print $ simplex prob constr2 [ Free 2 ]
|