diff options
author | Alberto Ruiz <aruiz@um.es> | 2010-02-23 18:22:57 +0000 |
---|---|---|
committer | Alberto Ruiz <aruiz@um.es> | 2010-02-23 18:22:57 +0000 |
commit | e0605467b60f65478d0f5cc8f82ba14a99168f7b (patch) | |
tree | 876e81ae0ee77f4cd01f5729ab35902ec9980789 /packages/glpk/examples | |
parent | 5587a094afa3e24698cd38301c805e6ee5876c73 (diff) |
error checking for simplex
Diffstat (limited to 'packages/glpk/examples')
-rw-r--r-- | packages/glpk/examples/simplex1.hs | 5 | ||||
-rw-r--r-- | packages/glpk/examples/simplex2.hs | 15 | ||||
-rw-r--r-- | packages/glpk/examples/simplex3.hs | 10 | ||||
-rw-r--r-- | packages/glpk/examples/simplex4.hs | 10 |
4 files changed, 20 insertions, 20 deletions
diff --git a/packages/glpk/examples/simplex1.hs b/packages/glpk/examples/simplex1.hs index 9639f37..ec72bdc 100644 --- a/packages/glpk/examples/simplex1.hs +++ b/packages/glpk/examples/simplex1.hs | |||
@@ -5,17 +5,16 @@ import Numeric.LinearProgramming | |||
5 | objFun = Maximize [10, 6, 4] | 5 | objFun = Maximize [10, 6, 4] |
6 | 6 | ||
7 | constr = Dense [ [1,1,1] :<: 100 | 7 | constr = Dense [ [1,1,1] :<: 100 |
8 | , [10,4,5] :<: 600 | 8 | , [10,4,5] :<: 600 |
9 | , [2,2,6] :<: 300 ] | 9 | , [2,2,6] :<: 300 ] |
10 | 10 | ||
11 | -- default bounds | 11 | -- default bounds |
12 | bnds = [ 1 :>: 0 | 12 | bnds = [ 1 :>: 0 |
13 | , 2 :>: 0 | 13 | , 2 :>: 0 |
14 | , 3 :>: 0 ] | 14 | , 3 :>: 0 ] |
15 | 15 | ||
16 | main = do | 16 | main = do |
17 | print $ simplex objFun constr [] | 17 | print $ simplex objFun constr [] |
18 | print $ simplex objFun constr bnds | 18 | print $ simplex objFun constr bnds |
19 | print $ simplex objFun constr [Free 3] | 19 | print $ simplex objFun constr [Free 3] |
20 | print $ simplex objFun constr [ 2 :<: 50 ] | 20 | print $ simplex objFun constr [ 2 :<: 50 ] |
21 | |||
diff --git a/packages/glpk/examples/simplex2.hs b/packages/glpk/examples/simplex2.hs index 40e4bbd..0b865a6 100644 --- a/packages/glpk/examples/simplex2.hs +++ b/packages/glpk/examples/simplex2.hs | |||
@@ -1,17 +1,18 @@ | |||
1 | import Numeric.LinearProgramming | 1 | import Numeric.LinearProgramming |
2 | 2 | ||
3 | prob = Maximize [4, 3, -2, 7] | 3 | prob = Maximize [4, -3, 2] |
4 | 4 | ||
5 | constr1 = Sparse [ [1#1, 1#2] :<: 10 | 5 | constr1 = Sparse [ [2#1, 1#2] :<: 10 |
6 | , [1#3, 1#4] :<: 10 | 6 | , [1#2, 5#3] :<: 20 |
7 | ] | 7 | ] |
8 | 8 | ||
9 | constr2 = Dense [ [1,1,0,0] :<: 10 | 9 | constr2 = Dense [ [2,1,0] :<: 10 |
10 | , [0,0,1,1] :<: 10 | 10 | , [0,1,5] :<: 20 |
11 | ] | 11 | ] |
12 | 12 | ||
13 | main = do | 13 | main = do |
14 | print $ simplex prob constr1 [] | 14 | print $ simplex prob constr1 [] |
15 | print $ simplex prob constr2 [ 2 :>: 1, 4 :&: (2,7)] | 15 | print $ simplex prob constr2 [] |
16 | print $ simplex prob constr2 [ Free 3 ] | 16 | print $ simplex prob constr2 [ 2 :>: 1, 3 :&: (2,7)] |
17 | print $ simplex prob constr2 [ Free 2 ] | ||
17 | 18 | ||
diff --git a/packages/glpk/examples/simplex3.hs b/packages/glpk/examples/simplex3.hs index 3a7e8e8..1df6b28 100644 --- a/packages/glpk/examples/simplex3.hs +++ b/packages/glpk/examples/simplex3.hs | |||
@@ -7,12 +7,12 @@ prob = Minimize [0.03, 0.08, 0.17, 0.12, 0.15, 0.21, 0.38] | |||
7 | 7 | ||
8 | constr = Dense | 8 | constr = Dense |
9 | [ [1,1,1,1,1,1,1] :==: 2000 | 9 | [ [1,1,1,1,1,1,1] :==: 2000 |
10 | , [0.15, 0.04, 0.02, 0.04, 0.2,0.01, 0.03] :<: 60 | 10 | , [0.15, 0.04, 0.02, 0.04, 0.2,0.01, 0.03] :<: 60 |
11 | , [0.03, 0.05, 0.08, 0.02, 0.06, 0.01, 0] :<: 100 | 11 | , [0.03, 0.05, 0.08, 0.02, 0.06, 0.01, 0] :<: 100 |
12 | , [0.02, 0.04, 0.01, 0.02, 0.02, 0, 0] :<: 40 | 12 | , [0.02, 0.04, 0.01, 0.02, 0.02, 0, 0] :<: 40 |
13 | , [0.02, 0.03, 0, 0, 0.01, 0, 0] :<: 30 | 13 | , [0.02, 0.03, 0, 0, 0.01, 0, 0] :<: 30 |
14 | , [0.7, 0.75, 0.8, 0.75, 0.8, 0.97, 0] :>: 1500 | 14 | , [0.7, 0.75, 0.8, 0.75, 0.8, 0.97, 0] :>: 1500 |
15 | , [0.02, 0.06, 0.08, 0.12, 0.02, 0.01, 0.97] :&: (250,300) | 15 | , [0.02, 0.06, 0.08, 0.12, 0.02, 0.01, 0.97] :&: (250,300) |
16 | ] | 16 | ] |
17 | 17 | ||
18 | bounds = [ 1 :&: (0,200) | 18 | bounds = [ 1 :&: (0,200) |
diff --git a/packages/glpk/examples/simplex4.hs b/packages/glpk/examples/simplex4.hs index 8496f6d..dd65002 100644 --- a/packages/glpk/examples/simplex4.hs +++ b/packages/glpk/examples/simplex4.hs | |||
@@ -7,12 +7,12 @@ prob = Minimize [0.03, 0.08, 0.17, 0.12, 0.15, 0.21, 0.38] | |||
7 | 7 | ||
8 | constr = Sparse | 8 | constr = Sparse |
9 | [ [1#1,1#2,1#3,1#4,1#5,1#6,1#7] :==: 2000 | 9 | [ [1#1,1#2,1#3,1#4,1#5,1#6,1#7] :==: 2000 |
10 | , [0.15#1, 0.04#2, 0.02#3, 0.04#4, 0.2#5,0.01#6, 0.03#7] :<: 60 | 10 | , [0.15#1, 0.04#2, 0.02#3, 0.04#4, 0.2#5,0.01#6, 0.03#7] :<: 60 |
11 | , [0.03#1, 0.05#2, 0.08#3, 0.02#4, 0.06#5, 0.01#6] :<: 100 | 11 | , [0.03#1, 0.05#2, 0.08#3, 0.02#4, 0.06#5, 0.01#6] :<: 100 |
12 | , [0.02#1, 0.04#2, 0.01#3, 0.02#4, 0.02#5] :<: 40 | 12 | , [0.02#1, 0.04#2, 0.01#3, 0.02#4, 0.02#5] :<: 40 |
13 | , [0.02#1, 0.03#2, 0.01#5] :<: 30 | 13 | , [0.02#1, 0.03#2, 0.01#5] :<: 30 |
14 | , [0.7#1, 0.75#2, 0.8#3, 0.75#4, 0.8#5, 0.97#6] :>: 1500 | 14 | , [0.7#1, 0.75#2, 0.8#3, 0.75#4, 0.8#5, 0.97#6] :>: 1500 |
15 | , [0.02#1, 0.06#2, 0.08#3, 0.12#4, 0.02#5, 0.01#6, 0.97#7] :&: (250,300) | 15 | , [0.02#1, 0.06#2, 0.08#3, 0.12#4, 0.02#5, 0.01#6, 0.97#7] :&: (250,300) |
16 | ] | 16 | ] |
17 | 17 | ||
18 | bounds = [ 1 :&: (0,200) | 18 | bounds = [ 1 :&: (0,200) |