Skip to content

Commit d2f0dbe

Browse files
Add protected do_prop_solve for overriding
This will allow us to count solver invocations without repeating the code in each propt implementation.
1 parent 6ff9ca4 commit d2f0dbe

23 files changed

+51
-34
lines changed

src/solvers/prop/prop.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,8 @@ bvt propt::new_variables(std::size_t width)
2525
result[i]=new_variable();
2626
return result;
2727
}
28+
29+
propt::resultt propt::prop_solve()
30+
{
31+
return do_prop_solve();
32+
}

src/solvers/prop/prop.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ class propt
9595
// solving
9696
virtual const std::string solver_text()=0;
9797
enum class resultt { P_SATISFIABLE, P_UNSATISFIABLE, P_ERROR };
98-
virtual resultt prop_solve()=0;
98+
resultt prop_solve();
9999

100100
// satisfying assignment
101101
virtual tvt l_get(literalt a) const=0;
@@ -118,6 +118,8 @@ class propt
118118
}
119119

120120
protected:
121+
virtual resultt do_prop_solve() = 0;
122+
121123
// to avoid a temporary for lcnf(...)
122124
bvt lcnf_bv;
123125

src/solvers/sat/cnf_clause_list.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,6 @@ class cnf_clause_listt:public cnft
3636
return tvt::unknown();
3737
}
3838

39-
resultt prop_solve() override
40-
{
41-
return resultt::P_ERROR;
42-
}
43-
4439
size_t no_clauses() const override
4540
{
4641
return clauses.size();
@@ -79,6 +74,11 @@ class cnf_clause_listt:public cnft
7974
}
8075

8176
protected:
77+
resultt do_prop_solve() override
78+
{
79+
return resultt::P_ERROR;
80+
}
81+
8282
clausest clauses;
8383
};
8484

src/solvers/sat/dimacs_cnf.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,6 @@ class dimacs_cnf_dumpt:public cnft
5353

5454
void lcnf(const bvt &bv) override;
5555

56-
resultt prop_solve() override
57-
{
58-
return resultt::P_ERROR;
59-
}
60-
6156
tvt l_get(literalt) const override
6257
{
6358
return tvt::unknown();
@@ -69,6 +64,11 @@ class dimacs_cnf_dumpt:public cnft
6964
}
7065

7166
protected:
67+
resultt do_prop_solve() override
68+
{
69+
return resultt::P_ERROR;
70+
}
71+
7272
std::ostream &out;
7373
};
7474

src/solvers/sat/pbs_dimacs_cnf.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ bool pbs_dimacs_cnft::pbs_solve()
205205
return satisfied;
206206
}
207207

208-
propt::resultt pbs_dimacs_cnft::prop_solve()
208+
propt::resultt pbs_dimacs_cnft::do_prop_solve()
209209
{
210210
std::ofstream file("temp.cnf");
211211

src/solvers/sat/pbs_dimacs_cnf.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,6 @@ class pbs_dimacs_cnft:public dimacs_cnft
4747

4848
bool pbs_solve();
4949

50-
resultt prop_solve() override;
51-
5250
tvt l_get(literalt a) const override;
5351

5452
// dummy functions
@@ -59,6 +57,8 @@ class pbs_dimacs_cnft:public dimacs_cnft
5957
}
6058

6159
protected:
60+
resultt do_prop_solve() override;
61+
6262
std::set<int> assigned;
6363
};
6464

src/solvers/sat/satcheck_booleforce.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ void satcheck_booleforce_baset::lcnf(const bvt &bv)
7979
clause_counter++;
8080
}
8181

82-
propt::resultt satcheck_booleforce_baset::prop_solve()
82+
propt::resultt satcheck_booleforce_baset::do_prop_solve()
8383
{
8484
PRECONDITION(status == SAT || status == INIT);
8585

src/solvers/sat/satcheck_booleforce.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,12 @@ class satcheck_booleforce_baset:public cnf_solvert
2121
virtual ~satcheck_booleforce_baset();
2222

2323
const std::string solver_text() override;
24-
resultt prop_solve() override;
2524
tvt l_get(literalt a) const override;
2625

2726
void lcnf(const bvt &bv) override;
27+
28+
protected:
29+
resultt do_prop_solve() override;
2830
};
2931

3032
class satcheck_booleforcet:public satcheck_booleforce_baset

src/solvers/sat/satcheck_cadical.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ void satcheck_cadicalt::lcnf(const bvt &bv)
6565
clause_counter++;
6666
}
6767

68-
propt::resultt satcheck_cadicalt::prop_solve()
68+
propt::resultt satcheck_cadicalt::do_prop_solve()
6969
{
7070
INVARIANT(status != statust::ERROR, "there cannot be an error");
7171

src/solvers/sat/satcheck_cadical.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ class satcheck_cadicalt:public cnf_solvert
2424
virtual ~satcheck_cadicalt();
2525

2626
const std::string solver_text() override;
27-
resultt prop_solve() override;
2827
tvt l_get(literalt a) const override;
2928

3029
void lcnf(const bvt &bv) override;
@@ -42,6 +41,8 @@ class satcheck_cadicalt:public cnf_solvert
4241
bool is_in_conflict(literalt a) const override;
4342

4443
protected:
44+
resultt do_prop_solve() override;
45+
4546
// NOLINTNEXTLINE(readability/identifiers)
4647
CaDiCaL::Solver * solver;
4748
};

src/solvers/sat/satcheck_glucose.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,8 @@ void satcheck_glucose_baset<T>::lcnf(const bvt &bv)
131131
}
132132
}
133133

134-
template<typename T>
135-
propt::resultt satcheck_glucose_baset<T>::prop_solve()
134+
template <typename T>
135+
propt::resultt satcheck_glucose_baset<T>::do_prop_solve()
136136
{
137137
PRECONDITION(status != statust::ERROR);
138138

src/solvers/sat/satcheck_glucose.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ class satcheck_glucose_baset:public cnf_solvert
3030
explicit satcheck_glucose_baset(T *);
3131
virtual ~satcheck_glucose_baset();
3232

33-
resultt prop_solve() override;
3433
tvt l_get(literalt a) const override;
3534

3635
void lcnf(const bvt &bv) override;
@@ -53,6 +52,8 @@ class satcheck_glucose_baset:public cnf_solvert
5352
}
5453

5554
protected:
55+
resultt do_prop_solve() override;
56+
5657
T *solver;
5758

5859
void add_variables();

src/solvers/sat/satcheck_ipasir.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ void satcheck_ipasirt::lcnf(const bvt &bv)
9393
clause_counter++;
9494
}
9595

96-
propt::resultt satcheck_ipasirt::prop_solve()
96+
propt::resultt satcheck_ipasirt::do_prop_solve()
9797
{
9898
INVARIANT(status!=statust::ERROR, "there cannot be an error");
9999

src/solvers/sat/satcheck_ipasir.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@ class satcheck_ipasirt:public cnf_solvert
2424
/// This method returns the description produced by the linked SAT solver
2525
const std::string solver_text() override;
2626

27-
resultt prop_solve() override;
28-
2927
/// This method returns the truth value for a literal of the current SAT model
3028
tvt l_get(literalt a) const override final;
3129

@@ -47,6 +45,8 @@ class satcheck_ipasirt:public cnf_solvert
4745
}
4846

4947
protected:
48+
resultt do_prop_solve() override;
49+
5050
void *solver;
5151

5252
bvt assumptions;

src/solvers/sat/satcheck_lingeling.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ void satcheck_lingelingt::lcnf(const bvt &bv)
6363
clause_counter++;
6464
}
6565

66-
propt::resultt satcheck_lingelingt::prop_solve()
66+
propt::resultt satcheck_lingelingt::do_prop_solve()
6767
{
6868
PRECONDITION(status != ERROR);
6969

src/solvers/sat/satcheck_lingeling.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ class satcheck_lingelingt:public cnf_solvert
2222
virtual ~satcheck_lingelingt();
2323

2424
const std::string solver_text() override;
25-
resultt prop_solve() override;
2625
tvt l_get(literalt a) const override;
2726

2827
void lcnf(const bvt &bv) override;
@@ -41,6 +40,8 @@ class satcheck_lingelingt:public cnf_solvert
4140
void set_frozen(literalt a) override;
4241

4342
protected:
43+
resultt do_prop_solve() override;
44+
4445
// NOLINTNEXTLINE(readability/identifiers)
4546
struct LGL * solver;
4647
bvt assumptions;

src/solvers/sat/satcheck_minisat.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ class satcheck_minisat1_baset:public cnf_solvert
2525
virtual ~satcheck_minisat1_baset();
2626

2727
const std::string solver_text() override;
28-
resultt prop_solve() override;
2928
tvt l_get(literalt a) const override;
3029

3130
void lcnf(const bvt &bv) final;
@@ -48,6 +47,8 @@ class satcheck_minisat1_baset:public cnf_solvert
4847
bool is_in_conflict(literalt l) const override;
4948

5049
protected:
50+
resultt do_prop_solve() override;
51+
5152
// NOLINTNEXTLINE(readability/identifiers)
5253
class Solver *solver;
5354
void add_variables();

src/solvers/sat/satcheck_minisat2.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,8 +162,8 @@ static void interrupt_solver(int signum)
162162

163163
#endif
164164

165-
template<typename T>
166-
propt::resultt satcheck_minisat2_baset<T>::prop_solve()
165+
template <typename T>
166+
propt::resultt satcheck_minisat2_baset<T>::do_prop_solve()
167167
{
168168
PRECONDITION(status != statust::ERROR);
169169

src/solvers/sat/satcheck_minisat2.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ class satcheck_minisat2_baset:public cnf_solvert
3030
explicit satcheck_minisat2_baset(T *);
3131
virtual ~satcheck_minisat2_baset();
3232

33-
resultt prop_solve() override;
3433
tvt l_get(literalt a) const override final;
3534

3635
void lcnf(const bvt &bv) override final;
@@ -64,6 +63,8 @@ class satcheck_minisat2_baset:public cnf_solvert
6463
}
6564

6665
protected:
66+
resultt do_prop_solve() override;
67+
6768
T *solver;
6869
uint32_t time_limit_seconds;
6970

src/solvers/sat/satcheck_picosat.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ class satcheck_picosatt:public cnf_solvert
2222
~satcheck_picosatt();
2323

2424
const std::string solver_text() override;
25-
resultt prop_solve() override;
2625
tvt l_get(literalt a) const override;
2726

2827
void lcnf(const bvt &bv) override;
@@ -40,6 +39,8 @@ class satcheck_picosatt:public cnf_solvert
4039
}
4140

4241
protected:
42+
resultt do_prop_solve() override;
43+
4344
bvt assumptions;
4445

4546
private:

src/solvers/sat/satcheck_zchaff.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ class satcheck_zchaff_baset:public cnf_clause_listt
2525
virtual ~satcheck_zchaff_baset();
2626

2727
const std::string solver_text() override;
28-
resultt prop_solve() override;
2928
tvt l_get(literalt a) const override;
3029
void set_assignment(literalt a, bool value) override;
3130
virtual void copy_cnf();
@@ -36,6 +35,8 @@ class satcheck_zchaff_baset:public cnf_clause_listt
3635
}
3736

3837
protected:
38+
resultt do_prop_solve() override;
39+
3940
CSolver *solver;
4041

4142
enum statust { INIT, SAT, UNSAT, ERROR };

src/solvers/sat/satcheck_zcore.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ class satcheck_zcoret:public dimacs_cnft
2121
virtual ~satcheck_zcoret();
2222

2323
const std::string solver_text() override;
24-
resultt prop_solve() override;
2524
tvt l_get(literalt a) const override;
2625

2726
bool is_in_core(literalt l) const
@@ -30,6 +29,8 @@ class satcheck_zcoret:public dimacs_cnft
3029
}
3130

3231
protected:
32+
resultt do_prop_solve() override;
33+
3334
std::set<unsigned> in_core;
3435
};
3536

unit/solvers/bdd/miniBDD/miniBDD.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ class bdd_propt : public propt
147147
return "BDDs";
148148
}
149149

150-
resultt prop_solve() override
150+
resultt do_prop_solve() override
151151
{
152152
UNREACHABLE;
153153
return {};

0 commit comments

Comments
 (0)