diff options
author | Justin Bedo <cu@cua0.org> | 2014-10-28 10:19:49 +1100 |
---|---|---|
committer | Justin Bedo <cu@cua0.org> | 2014-10-28 10:33:14 +1100 |
commit | d68fb49cad1a5bba7e52c7ff464d15c867052d0f (patch) | |
tree | 5cf467953736b3c41c1cfc1a57a41f9f057b0edc /Math/LinProg/LPSolve | |
parent | 544eef53181f52423f513227e2bd98c20815b243 (diff) |
Add support for binary/integer contraints;
Change to hash maps to speed up variable LUT for large number of
variables.
Diffstat (limited to 'Math/LinProg/LPSolve')
-rw-r--r-- | Math/LinProg/LPSolve/FFI.hs | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/Math/LinProg/LPSolve/FFI.hs b/Math/LinProg/LPSolve/FFI.hs index ddc7798..ff0bc16 100644 --- a/Math/LinProg/LPSolve/FFI.hs +++ b/Math/LinProg/LPSolve/FFI.hs @@ -5,6 +5,8 @@ module Math.LinProg.LPSolve.FFI ( ,LPRec ,setConstrType ,setTimeout + ,setInt + ,setBin ,makeLP ,freeLP ,setMat @@ -52,6 +54,8 @@ foreign import ccall "solve" c_solve :: LPRec -> IO CInt foreign import ccall "get_variables" c_get_variables :: LPRec -> Ptr CDouble -> IO CChar foreign import ccall "set_constr_type" c_set_constr_type :: LPRec -> CInt -> CInt -> IO CChar foreign import ccall "set_timeout" c_set_timeout :: LPRec -> CLong -> IO () +foreign import ccall "set_int" c_set_int :: LPRec -> CInt -> CChar -> IO CChar +foreign import ccall "set_binary" c_set_binary :: LPRec -> CInt -> CChar -> IO CChar setTimeout :: LPRec -> Integer -> IO () setTimeout lp x = c_set_timeout lp (fromIntegral x) @@ -76,6 +80,12 @@ setMat a b c d = fromIntegral <$> c_set_mat a (fromIntegral b) (fromIntegral c) setRHS :: LPRec -> Int -> Double -> IO Word8 setRHS a b c = fromIntegral <$> c_set_rh a (fromIntegral b) (realToFrac c) +setInt :: LPRec -> Int -> IO Word8 +setInt m a = fromIntegral <$> c_set_int m (fromIntegral a) 1 + +setBin :: LPRec -> Int -> IO Word8 +setBin m a = fromIntegral <$> c_set_binary m (fromIntegral a) 1 + solve :: LPRec -> IO ResultCode solve lp = (lut M.!) . fromIntegral <$> c_solve lp where |