Skip to content

Commit f45c69c

Browse files
Merge pull request #4449 from peterschrammel/solver-resource-limits
Factor out solver resource limits capability
2 parents f8dff52 + 4896d61 commit f45c69c

File tree

4 files changed

+41
-5
lines changed

4 files changed

+41
-5
lines changed

src/goto-checker/solver_factory.cpp

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ Author: Daniel Kroening, Peter Schrammel
2727
#include <solvers/flattening/bv_dimacs.h>
2828
#include <solvers/prop/prop.h>
2929
#include <solvers/prop/prop_conv.h>
30+
#include <solvers/prop/solver_resource_limits.h>
3031
#include <solvers/refinement/bv_refinement.h>
3132
#include <solvers/sat/dimacs_cnf.h>
3233
#include <solvers/sat/satcheck.h>
@@ -79,8 +80,21 @@ void solver_factoryt::set_prop_conv_time_limit(prop_convt &prop_conv)
7980
{
8081
const int timeout_seconds =
8182
options.get_signed_int_option("solver-time-limit");
83+
8284
if(timeout_seconds > 0)
83-
prop_conv.set_time_limit_seconds(timeout_seconds);
85+
{
86+
solver_resource_limitst *solver =
87+
dynamic_cast<solver_resource_limitst *>(&prop_conv);
88+
if(solver == nullptr)
89+
{
90+
messaget log(message_handler);
91+
log.warning() << "cannot set solver time limit on "
92+
<< prop_conv.decision_procedure_text() << messaget::eom;
93+
return;
94+
}
95+
96+
solver->set_time_limit_seconds(timeout_seconds);
97+
}
8498
}
8599

86100
void solver_factoryt::solvert::set_prop_conv(std::unique_ptr<prop_convt> p)

src/solvers/prop/prop_conv.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,6 @@ class prop_convt:public decision_proceduret
4242
// returns true if an assumption is in the final conflict
4343
virtual bool is_in_conflict(literalt l) const;
4444
virtual bool has_is_in_conflict() const { return false; }
45-
46-
// Resource limits:
47-
virtual void set_time_limit_seconds(uint32_t) {}
4845
};
4946

5047
//

src/solvers/prop/prop_conv_solver.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,9 @@ Author: Daniel Kroening, kroening@kroening.com
2121
#include "literal_expr.h"
2222
#include "prop.h"
2323
#include "prop_conv.h"
24+
#include "solver_resource_limits.h"
2425

25-
class prop_conv_solvert : public prop_convt
26+
class prop_conv_solvert : public prop_convt, public solver_resource_limitst
2627
{
2728
public:
2829
prop_conv_solvert(propt &_prop, message_handlert &message_handler)
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/*******************************************************************\
2+
3+
Module: Solver capability to set resource limits
4+
5+
Author: Peter Schrammel
6+
7+
\*******************************************************************/
8+
9+
/// \file
10+
/// Solver capability to set resource limits
11+
12+
#ifndef CPROVER_SOLVERS_PROP_SOLVER_RESOURCE_LIMITS_H
13+
#define CPROVER_SOLVERS_PROP_SOLVER_RESOURCE_LIMITS_H
14+
15+
class solver_resource_limitst
16+
{
17+
public:
18+
/// Set the limit for the solver to time out in seconds
19+
virtual void set_time_limit_seconds(uint32_t) = 0;
20+
21+
virtual ~solver_resource_limitst() = default;
22+
};
23+
24+
#endif // CPROVER_SOLVERS_PROP_SOLVER_RESOURCE_LIMITS_H

0 commit comments

Comments
 (0)