From 5eba1bc309d7845366e8d00849d85426bf8f666d Mon Sep 17 00:00:00 2001 From: Alberto Ruiz Date: Thu, 8 Jan 2015 13:55:57 +0100 Subject: update other pkgs to ghc-7.10 --- packages/glpk/src/Numeric/LinearProgramming.hs | 21 +++++++++++---------- packages/glpk/src/Numeric/LinearProgramming/L1.hs | 2 +- 2 files changed, 12 insertions(+), 11 deletions(-) (limited to 'packages/glpk/src') 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( Solution(..) ) where -import Data.Packed -import Data.Packed.Development +import Numeric.LinearAlgebra.HMatrix +import Numeric.LinearAlgebra.Devel hiding (Dense) import Foreign(Ptr) import System.IO.Unsafe(unsafePerformIO) import Foreign.C.Types @@ -135,16 +135,17 @@ simplex opt (Sparse constr) bnds = extract sg sol where adapt :: Optimization -> (Int, Double, [Double]) adapt opt = case opt of - Maximize x -> (size x, 1 ,x) - Minimize x -> (size x, -1, (map negate x)) - where size x | null x = error "simplex: objective function with zero variables" - | otherwise = length x + Maximize x -> (sz x, 1 ,x) + Minimize x -> (sz x, -1, (map negate x)) + where + sz x | null x = error "simplex: objective function with zero variables" + | otherwise = length x extract :: Double -> Vector Double -> Solution extract sg sol = r where - z = sg * (sol@>1) - v = toList $ subVector 2 (dim sol -2) sol - r = case round(sol@>0)::Int of + z = sg * (sol!1) + v = toList $ subVector 2 (size sol -2) sol + r = case round(sol!0)::Int of 1 -> Undefined 2 -> Feasible (z,v) 3 -> Infeasible (z,v) @@ -209,7 +210,7 @@ mkConstrD n f b1 | ok = fromLists (ob ++ co) ok = all (==n) ls den = fromLists cs ob = map (([0,0]++).return) f - co = [[fromIntegral i, fromIntegral j,den@@>(i-1,j-1)]| i<-[1 ..rows den], j<-[1 .. cols den]] + co = [[fromIntegral i, fromIntegral j,den `atIndex` (i-1,j-1)]| i<-[1 ..rows den], j<-[1 .. cols den]] mkConstrS :: Int -> [Double] -> [Bound [(Double, Int)]] -> Matrix Double mkConstrS 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 ( l1SolveU, ) where -import Numeric.LinearAlgebra +import Numeric.LinearAlgebra.HMatrix import Numeric.LinearProgramming -- | L_inf solution of overconstrained system Ax=b. -- cgit v1.2.3