Skip to content

Commit 25afc73

Browse files
committed
Use the same code to update SMT options on retries
1 parent 2483a57 commit 25afc73

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

booster/library/Booster/SMT/Interface.hs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,10 @@ swapSmtOptions smtOptions = do
134134
SMT $ put ctxt{options = smtOptions}
135135
runCmd_ $ SetTimeout smtOptions.timeout
136136

137+
-- | This function defines the strategy to increment the timeout when retrying a solver query
138+
updateOptionsOnRetry :: SMTOptions -> SMTOptions
139+
updateOptionsOnRetry opts = opts{timeout = 2 * opts.timeout, retryLimit = ((-) 1) <$> opts.retryLimit}
140+
137141
-- | Stop the solver, initialise a new one and put in the @SMTContext@
138142
hardResetSolver :: forall io. Log.LoggerMIO io => SMTOptions -> SMT io ()
139143
hardResetSolver smtOptions = do
@@ -234,8 +238,7 @@ getModelFor ctxt ps subst
234238
Unknown{} -> do
235239
case opts.retryLimit of
236240
Just x | x > 0 -> do
237-
let newOpts = opts{timeout = 2 * opts.timeout, retryLimit = Just $ x - 1}
238-
lift $ hardResetSolver newOpts
241+
lift $ hardResetSolver (updateOptionsOnRetry opts)
239242
solve smtAsserts transState
240243
_ -> pure . Left $ response
241244
_ -> pure . Left $ response
@@ -418,8 +421,7 @@ checkPredicates ctxt givenPs givenSubst psToCheck
418421
opts <- lift . SMT $ gets (.options)
419422
case opts.retryLimit of
420423
Just x | x > 0 -> do
421-
let newOpts = opts{timeout = 2 * opts.timeout, retryLimit = Just $ x - 1}
422-
lift $ hardResetSolver newOpts
424+
lift $ hardResetSolver (updateOptionsOnRetry opts)
423425
solve smtGiven sexprsToCheck transState
424426
_ -> failBecauseUnknown reasonUnknown
425427

@@ -548,8 +550,7 @@ isSat ctxt psToCheck
548550
opts <- lift . SMT $ gets (.options)
549551
case opts.retryLimit of
550552
Just x | x > 0 -> do
551-
let newOpts = opts{timeout = 2 * opts.timeout, retryLimit = Just $ x - 1}
552-
lift $ hardResetSolver newOpts
553+
lift $ hardResetSolver (updateOptionsOnRetry opts)
553554
Log.logMessage ("Retrying with higher timeout" :: Text)
554555
solve'
555556
_ -> failBecauseUnknown

0 commit comments

Comments
 (0)