• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

msakai / haskell-MIP / 351

04 Jan 2026 10:32PM UTC coverage: 77.291% (+0.005%) from 77.286%
351

push

github

msakai
update ChangeLog for v0.2.0.1

1518 of 1964 relevant lines covered (77.29%)

0.77 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

80.56
/MIP/src/Numeric/Optimization/MIP/Solver/SCIP.hs
1
{-# OPTIONS_GHC -Wall #-}
2
{-# OPTIONS_HADDOCK show-extensions #-}
3
{-# LANGUAGE MultiParamTypeClasses #-}
4
-----------------------------------------------------------------------------
5
-- |
6
-- Module      :  Numeric.Optimization.MIP.Solver.SCIP
7
-- Copyright   :  (c) Masahiro Sakai 2017
8
-- License     :  BSD-style
9
--
10
-- Maintainer  :  masahiro.sakai@gmail.com
11
-- Stability   :  provisional
12
-- Portability :  non-portable
13
--
14
-----------------------------------------------------------------------------
15
module Numeric.Optimization.MIP.Solver.SCIP
16
  ( SCIP (..)
17
  , scip
18
  ) where
19

20
import Data.Default.Class
21
import qualified Data.Text.Lazy.IO as TLIO
22
import System.Exit
23
import System.IO
24
import System.IO.Temp
25
import qualified Numeric.Optimization.MIP.LPFile as LPFile
26
import qualified Numeric.Optimization.MIP.Base as MIP
27
import Numeric.Optimization.MIP.Solver.Base
28
import qualified Numeric.Optimization.MIP.Solution.SCIP as ScipSol
29
import Numeric.Optimization.MIP.Internal.ProcessUtil (runProcessWithOutputCallback)
30

31
-- | A solver instance for calling @scip@ command from [SCIP Optimization Suite](https://www.scipopt.org/).
32
--
33
-- Use 'scip' and record update syntax to modify its field.
34
data SCIP
35
  = SCIP
36
  { scipPath :: String
1✔
37
  , scipArgs :: [String]
1✔
38
  , scipCommands :: [String]
1✔
39
  }
40

41
instance Default SCIP where
42
  def = scip
×
43

44
-- | Default value of t'SCIP'
45
scip :: SCIP
46
scip = SCIP "scip" [] []
1✔
47

48
instance IsSolver SCIP IO where
1✔
49
  solve' solver opt prob = do
1✔
50
    case LPFile.render def prob of
×
51
      Left err -> ioError $ userError err
×
52
      Right lp -> do
1✔
53
        withSystemTempFile "scip.lp" $ \fname1 h1 -> do
1✔
54
          TLIO.hPutStr h1 lp
1✔
55
          hClose h1
1✔
56
          withSystemTempFile "scip.sol" $ \fname2 h2 -> do
1✔
57
            hClose h2
1✔
58
            let commands = 
1✔
59
                  [ "read " ++ show fname1 ] ++
1✔
60
                  (case solveTimeLimit opt of
1✔
61
                     Nothing -> []
1✔
62
                     Just sec -> ["set limits time " ++ show sec]) ++
×
63
                  (case solveTol opt of
1✔
64
                     Nothing -> []
1✔
65
                     Just tol ->
66
                       [ "set numeric feastol " ++ show (MIP.feasibilityTol tol)
1✔
67
                       , "set numeric dualfeastol " ++ show (MIP.optimalityTol tol)
1✔
68
                       , -- https://listserv.zib.de/pipermail/scip/2010-September/000552.html
69
                         "set numeric epsilon " ++ show (MIP.integralityTol tol)
1✔
70
                       ]
71
                  ) ++
72
                  scipCommands solver ++
1✔
73
                  [ "optimize"
1✔
74
                  , "write solution " ++ show fname2
1✔
75
                  , "quit"
1✔
76
                  ]
77
                args = scipArgs solver ++ concat [["-c", cmd] | cmd <- commands]
1✔
78
                onGetLine = solveLogger opt
1✔
79
                onGetErrorLine = solveErrorLogger opt
×
80
            exitcode <- runProcessWithOutputCallback (scipPath solver) args Nothing "" onGetLine onGetErrorLine
×
81
            case exitcode of
1✔
82
              ExitFailure n -> ioError $ userError $ "exit with " ++ show n
×
83
              ExitSuccess -> ScipSol.readFile fname2
1✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc