Skip to content

Commit

Permalink
add runsolver command line options
Browse files Browse the repository at this point in the history
  • Loading branch information
ozgurakgun committed Mar 25, 2024
1 parent 562ff9e commit c5a005f
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 2 deletions.
3 changes: 3 additions & 0 deletions docs/conjure-help.html
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,9 @@
<tr><td style='padding-left:2ex;'>&nbsp;<td style='padding-left:1ex; white-space:nowrap;'>--seed=INT</td><td style='padding-left:2ex;'>Random number generator seed.</td></tr>
<tr><td style='padding-left:2ex;'>&nbsp;<td style='padding-left:1ex; white-space:nowrap;'>--limit-models=INT</td><td style='padding-left:2ex;'>Maximum number of models to generate.</td></tr>
<tr><td style='padding-left:2ex;'>&nbsp;<td style='padding-left:1ex; white-space:nowrap;'>--use-existing-models=FILE</td><td style='padding-left:2ex;'>File names of Essence' models generated beforehand.<br />If given, Conjure skips the modelling phase and uses the existing models for solving.<br />The models should be inside the output directory (See -o).</td></tr>
<tr><td colspan='3'>runsolver:</td></tr>
<tr><td style='padding-left:2ex;'>&nbsp;<td style='padding-left:1ex; white-space:nowrap;'>--runsolver-cpu-time-limit=INT</td><td style='padding-left:2ex;'>Use runsolver to limit total CPU time (in seconds)</td></tr>
<tr><td style='padding-left:2ex;'>&nbsp;<td style='padding-left:1ex; white-space:nowrap;'>--runsolver-memory-limit=INT</td><td style='padding-left:2ex;'>Use runsolver to limit total memory usage (in megabytes). <br />This is the total memory usage: both RAM and swap space.</td></tr>
<tr><td colspan='3'>Options for other tools:</td></tr>
<tr><td style='padding-left:2ex;'>&nbsp;<td style='padding-left:1ex; white-space:nowrap;'>--savilerow-options=ITEM</td><td style='padding-left:2ex;'>Options passed to Savile Row.</td></tr>
<tr><td style='padding-left:2ex;'>&nbsp;<td style='padding-left:1ex; white-space:nowrap;'>--solver-options=ITEM</td><td style='padding-left:2ex;'>Options passed to the backend solver.</td></tr>
Expand Down
4 changes: 4 additions & 0 deletions docs/conjure-help.txt
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,10 @@
If given, Conjure skips the modelling phase and uses the existing models
for solving.
The models should be inside the output directory (See -o).
runsolver:
--runsolver-cpu-time-limit=INT Use runsolver to limit total CPU time (in seconds)
--runsolver-memory-limit=INT Use runsolver to limit total memory usage (in megabytes).
This is the total memory usage: both RAM and swap space.
Options for other tools:
--savilerow-options=ITEM Options passed to Savile Row.
--solver-options=ITEM Options passed to the backend solver.
Expand Down
15 changes: 15 additions & 0 deletions src/Conjure/UI.hs
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@ data UI
, responses :: String
, responsesRepresentation :: String
, solutionsInOneFile :: Bool
, runsolverCPUTimeLimit :: Maybe Int
, runsolverMemoryLimit :: Maybe Int
-- flags related to logging
, logLevel :: LogLevel
, verboseTrail :: Bool
Expand Down Expand Up @@ -739,6 +741,19 @@ ui = modes
&= explicit
&= help "Place all solutions in a single file instead of generating a separate file per solution.\n\
\Off by default."
, runsolverCPUTimeLimit
= def
&= name "runsolver-cpu-time-limit"
&= groupname "runsolver"
&= explicit
&= help "Use runsolver to limit total CPU time (in seconds)"
, runsolverMemoryLimit
= def
&= name "runsolver-memory-limit"
&= groupname "runsolver"
&= explicit
&= help "Use runsolver to limit total memory usage (in megabytes). \n\
\This is the total memory usage: both RAM and swap space."
, logLevel
= def
&= name "log-level"
Expand Down
15 changes: 13 additions & 2 deletions src/Conjure/UI/MainHelper.hs
Original file line number Diff line number Diff line change
Expand Up @@ -803,7 +803,12 @@ savileRowNoParam ui@Solve{..} (modelPath, eprimeModel) = sh $ errExit False $ do
let handler = liftIO . srStdoutHandler
(outBase, modelPath, "<no param file>", ui)
tr (1::Int)
(stdoutSR, solutions) <- partitionEithers <$> runHandle savilerowScriptName srArgs handler
let runsolverArgs = maybe [] (\ limit -> ["-C", show limit]) runsolverCPUTimeLimit ++
maybe [] (\ limit -> ["-V", show limit]) runsolverMemoryLimit
(stdoutSR, solutions) <- partitionEithers <$>
if null runsolverArgs
then runHandle savilerowScriptName srArgs handler
else runHandle "runsolver" (map stringToText runsolverArgs ++ [stringToText savilerowScriptName] ++ srArgs) handler
srCleanUp outBase ui (stringToText $ unlines stdoutSR) solutions
savileRowNoParam _ _ = bug "savileRowNoParam"

Expand Down Expand Up @@ -844,7 +849,13 @@ savileRowWithParams ui@Solve{..} (modelPath, eprimeModel) (paramPath, essencePar
let handler = liftIO . srStdoutHandler
(outBase, modelPath, paramPath, ui)
tr (1::Int)
(stdoutSR, solutions) <- partitionEithers <$> runHandle savilerowScriptName srArgs handler
let runsolverArgs = maybe [] (\ limit -> ["-C", show limit]) runsolverCPUTimeLimit ++
maybe [] (\ limit -> ["-V", show limit]) runsolverMemoryLimit
(stdoutSR, solutions) <- partitionEithers <$>
if null runsolverArgs
then runHandle savilerowScriptName srArgs handler
else runHandle "runsolver" (map stringToText runsolverArgs ++ [stringToText savilerowScriptName] ++ srArgs) handler

srCleanUp outBase ui (stringToText $ unlines stdoutSR) solutions
savileRowWithParams _ _ _ = bug "savileRowWithParams"

Expand Down

0 comments on commit c5a005f

Please sign in to comment.