summaryrefslogtreecommitdiff
path: root/packages/glpk
diff options
context:
space:
mode:
authorAlberto Ruiz <aruiz@um.es>2015-01-08 13:55:57 +0100
committerAlberto Ruiz <aruiz@um.es>2015-01-08 13:55:57 +0100
commit5eba1bc309d7845366e8d00849d85426bf8f666d (patch)
treec35efda048ec3211325f984bcabe9626810d5afd /packages/glpk
parent8878aaaf649962f4360a94109a674da756ad2202 (diff)
update other pkgs to ghc-7.10
Diffstat (limited to 'packages/glpk')
-rw-r--r--packages/glpk/hmatrix-glpk.cabal4
-rw-r--r--packages/glpk/src/Numeric/LinearProgramming.hs21
-rw-r--r--packages/glpk/src/Numeric/LinearProgramming/L1.hs2
3 files changed, 14 insertions, 13 deletions
diff --git a/packages/glpk/hmatrix-glpk.cabal b/packages/glpk/hmatrix-glpk.cabal
index cd761e0..4764bfe 100644
--- a/packages/glpk/hmatrix-glpk.cabal
+++ b/packages/glpk/hmatrix-glpk.cabal
@@ -1,5 +1,5 @@
1Name: hmatrix-glpk 1Name: hmatrix-glpk
2Version: 0.4.0.2 2Version: 0.5.0.0
3License: GPL 3License: GPL
4License-file: LICENSE 4License-file: LICENSE
5Author: Alberto Ruiz 5Author: Alberto Ruiz
@@ -22,7 +22,7 @@ extra-source-files: examples/simplex1.hs
22 examples/simplex4.hs 22 examples/simplex4.hs
23 23
24library 24library
25 Build-Depends: base <5, hmatrix >= 0.16 25 Build-Depends: base <5, hmatrix >= 0.17
26 26
27 hs-source-dirs: src 27 hs-source-dirs: src
28 28
diff --git a/packages/glpk/src/Numeric/LinearProgramming.hs b/packages/glpk/src/Numeric/LinearProgramming.hs
index b0537cc..d2e9f3c 100644
--- a/packages/glpk/src/Numeric/LinearProgramming.hs
+++ b/packages/glpk/src/Numeric/LinearProgramming.hs
@@ -75,8 +75,8 @@ module Numeric.LinearProgramming(
75 Solution(..) 75 Solution(..)
76) where 76) where
77 77
78import Data.Packed 78import Numeric.LinearAlgebra.HMatrix
79import Data.Packed.Development 79import Numeric.LinearAlgebra.Devel hiding (Dense)
80import Foreign(Ptr) 80import Foreign(Ptr)
81import System.IO.Unsafe(unsafePerformIO) 81import System.IO.Unsafe(unsafePerformIO)
82import Foreign.C.Types 82import Foreign.C.Types
@@ -135,16 +135,17 @@ simplex opt (Sparse constr) bnds = extract sg sol where
135 135
136adapt :: Optimization -> (Int, Double, [Double]) 136adapt :: Optimization -> (Int, Double, [Double])
137adapt opt = case opt of 137adapt opt = case opt of
138 Maximize x -> (size x, 1 ,x) 138 Maximize x -> (sz x, 1 ,x)
139 Minimize x -> (size x, -1, (map negate x)) 139 Minimize x -> (sz x, -1, (map negate x))
140 where size x | null x = error "simplex: objective function with zero variables" 140 where
141 | otherwise = length x 141 sz x | null x = error "simplex: objective function with zero variables"
142 | otherwise = length x
142 143
143extract :: Double -> Vector Double -> Solution 144extract :: Double -> Vector Double -> Solution
144extract sg sol = r where 145extract sg sol = r where
145 z = sg * (sol@>1) 146 z = sg * (sol!1)
146 v = toList $ subVector 2 (dim sol -2) sol 147 v = toList $ subVector 2 (size sol -2) sol
147 r = case round(sol@>0)::Int of 148 r = case round(sol!0)::Int of
148 1 -> Undefined 149 1 -> Undefined
149 2 -> Feasible (z,v) 150 2 -> Feasible (z,v)
150 3 -> Infeasible (z,v) 151 3 -> Infeasible (z,v)
@@ -209,7 +210,7 @@ mkConstrD n f b1 | ok = fromLists (ob ++ co)
209 ok = all (==n) ls 210 ok = all (==n) ls
210 den = fromLists cs 211 den = fromLists cs
211 ob = map (([0,0]++).return) f 212 ob = map (([0,0]++).return) f
212 co = [[fromIntegral i, fromIntegral j,den@@>(i-1,j-1)]| i<-[1 ..rows den], j<-[1 .. cols den]] 213 co = [[fromIntegral i, fromIntegral j,den `atIndex` (i-1,j-1)]| i<-[1 ..rows den], j<-[1 .. cols den]]
213 214
214mkConstrS :: Int -> [Double] -> [Bound [(Double, Int)]] -> Matrix Double 215mkConstrS :: Int -> [Double] -> [Bound [(Double, Int)]] -> Matrix Double
215mkConstrS n objfun b1 = fromLists (ob ++ co) where 216mkConstrS n objfun b1 = fromLists (ob ++ co) where
diff --git a/packages/glpk/src/Numeric/LinearProgramming/L1.hs b/packages/glpk/src/Numeric/LinearProgramming/L1.hs
index f55c721..d7f1258 100644
--- a/packages/glpk/src/Numeric/LinearProgramming/L1.hs
+++ b/packages/glpk/src/Numeric/LinearProgramming/L1.hs
@@ -14,7 +14,7 @@ module Numeric.LinearProgramming.L1 (
14 l1SolveU, 14 l1SolveU,
15) where 15) where
16 16
17import Numeric.LinearAlgebra 17import Numeric.LinearAlgebra.HMatrix
18import Numeric.LinearProgramming 18import Numeric.LinearProgramming
19 19
20-- | L_inf solution of overconstrained system Ax=b. 20-- | L_inf solution of overconstrained system Ax=b.