packages feed

hmatrix-glpk 0.1.0 → 0.2.0

raw patch · 6 files changed

+41/−41 lines, 6 filesdep ~hmatrixPVP ok

version bump matches the API change (PVP)

Dependency ranges changed: hmatrix

API changes (from Hackage documentation)

- Numeric.LinearProgramming: (:<:) :: x -> Double -> Bound x
- Numeric.LinearProgramming: (:>:) :: x -> Double -> Bound x
+ Numeric.LinearProgramming: (:<=:) :: x -> Double -> Bound x
+ Numeric.LinearProgramming: (:=>:) :: x -> Double -> Bound x

Files

examples/simplex1.hs view
@@ -4,17 +4,17 @@  objFun = Maximize [10, 6, 4] -constr = Dense [ [1,1,1]  :<: 100-               , [10,4,5] :<: 600-               , [2,2,6]  :<: 300 ]+constr = Dense [ [1,1,1]  :<=: 100+               , [10,4,5] :<=: 600+               , [2,2,6]  :<=: 300 ]  -- default bounds-bnds = [ 1 :>: 0-       , 2 :>: 0-       , 3 :>: 0 ]+bnds = [ 1 :=>: 0+       , 2 :=>: 0+       , 3 :=>: 0 ]  main = do     print $ simplex objFun constr []     print $ simplex objFun constr bnds     print $ simplex objFun constr [Free 3]-    print $ simplex objFun constr [ 2 :<: 50 ]+    print $ simplex objFun constr [ 2 :<=: 50 ]
examples/simplex2.hs view
@@ -2,17 +2,17 @@  prob = Maximize [4, -3, 2] -constr1 = Sparse [ [2#1, 1#2] :<: 10-                 , [1#2, 5#3] :<: 20+constr1 = Sparse [ [2#1, 1#2] :<=: 10+                 , [1#2, 5#3] :<=: 20                  ] -constr2 = Dense [ [2,1,0] :<: 10-                , [0,1,5] :<: 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 [ 2 :=>: 1, 3 :&: (2,7)]     print $ simplex prob constr2 [ Free 2 ] 
examples/simplex3.hs view
@@ -7,11 +7,11 @@  constr = Dense     [ [1,1,1,1,1,1,1]                           :==: 2000-    , [0.15, 0.04, 0.02, 0.04, 0.2,0.01, 0.03]   :<:  60-    , [0.03, 0.05, 0.08, 0.02, 0.06, 0.01, 0]    :<:  100-    , [0.02, 0.04, 0.01, 0.02, 0.02, 0,    0]    :<:  40-    , [0.02, 0.03, 0,    0,    0.01, 0,    0]    :<:  30-    , [0.7,  0.75, 0.8,  0.75, 0.8,  0.97,  0]   :>:  1500+    , [0.15, 0.04, 0.02, 0.04, 0.2,0.01, 0.03]   :<=:  60+    , [0.03, 0.05, 0.08, 0.02, 0.06, 0.01, 0]    :<=:  100+    , [0.02, 0.04, 0.01, 0.02, 0.02, 0,    0]    :<=:  40+    , [0.02, 0.03, 0,    0,    0.01, 0,    0]    :<=:  30+    , [0.7,  0.75, 0.8,  0.75, 0.8,  0.97,  0]   :=>:  1500     , [0.02, 0.06, 0.08, 0.12, 0.02, 0.01, 0.97] :&: (250,300)     ] 
examples/simplex4.hs view
@@ -7,11 +7,11 @@  constr = Sparse     [ [1#1,1#2,1#3,1#4,1#5,1#6,1#7]                          :==: 2000-    , [0.15#1, 0.04#2, 0.02#3, 0.04#4, 0.2#5,0.01#6, 0.03#7] :<: 60-    , [0.03#1, 0.05#2, 0.08#3, 0.02#4, 0.06#5, 0.01#6]       :<: 100-    , [0.02#1, 0.04#2, 0.01#3, 0.02#4, 0.02#5]               :<:  40-    , [0.02#1, 0.03#2, 0.01#5]                               :<:  30-    , [0.7#1,  0.75#2, 0.8#3,  0.75#4, 0.8#5,  0.97#6]       :>:  1500+    , [0.15#1, 0.04#2, 0.02#3, 0.04#4, 0.2#5,0.01#6, 0.03#7] :<=: 60+    , [0.03#1, 0.05#2, 0.08#3, 0.02#4, 0.06#5, 0.01#6]       :<=: 100+    , [0.02#1, 0.04#2, 0.01#3, 0.02#4, 0.02#5]               :<=:  40+    , [0.02#1, 0.03#2, 0.01#5]                               :<=:  30+    , [0.7#1,  0.75#2, 0.8#3,  0.75#4, 0.8#5,  0.97#6]       :=>:  1500     , [0.02#1, 0.06#2, 0.08#3, 0.12#4, 0.02#5, 0.01#6, 0.97#7] :&: (250,300)     ] 
hmatrix-glpk.cabal view
@@ -1,5 +1,5 @@ Name:               hmatrix-glpk-Version:            0.1.0+Version:            0.2.0 License:            GPL License-file:       LICENSE Author:             Alberto Ruiz@@ -22,7 +22,7 @@                         examples/simplex4.hs  library-    Build-Depends:      base >= 3 && < 5, hmatrix >= 0.8.3 && < 0.9+    Build-Depends:      base >= 3 && < 5, hmatrix >= 0.8.3 && < 0.10      hs-source-dirs:     lib 
lib/Numeric/LinearProgramming.hs view
@@ -28,8 +28,8 @@  prob = Maximize [4, -3, 2] -constr1 = Sparse [ [2\#1, 1\#2] :<: 10-                 , [1\#2, 5\#3] :<: 20+constr1 = Sparse [ [2\#1, 1\#2] :<=: 10+                 , [1\#2, 5\#3] :<=: 20                  ]  \> simplex prob constr1 []@@ -37,14 +37,14 @@  The coefficients of the constraint matrix can also be given in dense format: -@constr2 = Dense [ [2,1,0] :<: 10-                , [0,1,5] :<: 20+@constr2 = Dense [ [2,1,0] :<=: 10+                , [0,1,5] :<=: 20                 ]@  By default all variables are bounded as @x_i >= 0@, but this can be changed: -@\> simplex prob constr2 [ 2 :>: 1, 3 :&: (2,7)]+@\> simplex prob constr2 [ 2 :=>: 1, 3 :&: (2,7)] Optimal (22.6,[4.5,1.0,3.8])  \> simplex prob constr2 [Free 2]@@ -53,7 +53,7 @@ The given bound for a variable completely replaces the default, so @0 <= x_i <= b@ must be explicitly given as @i :&: (0,b)@. Multiple bounds for a variable are not allowed, instead of-@[i :>: a, i:<: b]@ use @i :&: (a,b)@.+@[i :=>: a, i:<=: b]@ use @i :&: (a,b)@.  -} @@ -84,8 +84,8 @@ infixl 5 # (#) = (,) -data Bound x =  x :<: Double-             |  x :>: Double+data Bound x =  x :<=: Double+             |  x :=>: Double              |  x :&: (Double,Double)              |  x :==: Double              |  Free x@@ -147,29 +147,29 @@ -----------------------------------------------------  obj :: Bound t -> t-obj (x :<: _)  = x-obj (x :>: _)  = x+obj (x :<=: _)  = x+obj (x :=>: _)  = x obj (x :&: _)  = x obj (x :==: _) = x obj (Free x)   = x  tb :: Bound t -> Double-tb (_ :<: _)  = glpUP-tb (_ :>: _)  = glpLO+tb (_ :<=: _)  = glpUP+tb (_ :=>: _)  = glpLO tb (_ :&: _)  = glpDB tb (_ :==: _) = glpFX tb (Free _)   = glpFR  lb :: Bound t -> Double-lb (_ :<: _)     = 0-lb (_ :>: a)     = a+lb (_ :<=: _)     = 0+lb (_ :=>: a)     = a lb (_ :&: (a,_)) = a lb (_ :==: a)    = a lb (Free _)      = 0  ub :: Bound t -> Double-ub (_ :<: a)     = a-ub (_ :>: _)     = 0+ub (_ :<=: a)     = a+ub (_ :=>: _)     = 0 ub (_ :&: (_,a)) = a ub (_ :==: a)    = a ub (Free _)      = 0@@ -187,7 +187,7 @@        | otherwise = error $ "simplex: duplicate bounds for vars " ++ show (gv'\\nub gv')     rv | null gv || minimum gv >= 0 && maximum gv <= n = [1..n] \\ gv        | otherwise = error $ "simplex: bounds: variables "++show gv++" not in 1.."++show n-    vb = map snd $ sortBy (compare `on` fst) $ map (mkBound2 . (:>: 0)) rv ++ map mkBound2 b2+    vb = map snd $ sortBy (compare `on` fst) $ map (mkBound2 . (:=>: 0)) rv ++ map mkBound2 b2     cb = map mkBound1 b1  mkConstrD :: Int -> [Double] -> [Bound [Double]] -> Matrix Double