Skip to content

Commit d6354ee

Browse files
committed
satcheck minisat2: make all solver hardness processing conditional
There is no need to run process_clause when its output wouldn't even be used.
1 parent 7993b3a commit d6354ee

File tree

3 files changed

+19
-18
lines changed

3 files changed

+19
-18
lines changed

src/solvers/sat/cnf.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,7 @@ bvt cnft::eliminate_duplicates(const bvt &bv)
412412

413413
/// filter 'true' from clause, eliminate duplicates, recognise trivially
414414
/// satisfied clauses
415-
bool cnft::process_clause(const bvt &bv, bvt &dest)
415+
bool cnft::process_clause(const bvt &bv, bvt &dest) const
416416
{
417417
dest.clear();
418418

src/solvers/sat/cnf.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ class cnft:public propt
5555

5656
size_t _no_variables;
5757

58-
bool process_clause(const bvt &bv, bvt &dest);
58+
bool process_clause(const bvt &bv, bvt &dest) const;
5959

6060
static bool is_all(const bvt &bv, literalt l)
6161
{

src/solvers/sat/satcheck_minisat2.cpp

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -140,22 +140,23 @@ void satcheck_minisat2_baset<T>::lcnf(const bvt &bv)
140140

141141
solver->addClause_(c);
142142

143-
// To map clauses to lines of program code, track clause indices in the
144-
// dimacs cnf output. Dimacs output is generated after processing clauses
145-
// to remove duplicates and clauses that are trivially true. Here, a clause
146-
// is checked to see if it can be thus eliminated. If not, add the clause
147-
// index to list of clauses in solver_hardnesst::register_clause().
148-
static size_t cnf_clause_index = 0;
149-
bvt cnf;
150-
bool clause_removed = process_clause(bv, cnf);
151-
152-
if(!clause_removed)
153-
cnf_clause_index++;
154-
155-
with_solver_hardness(
156-
[&bv, &cnf, &clause_removed](solver_hardnesst &hardness) {
157-
hardness.register_clause(bv, cnf, cnf_clause_index, !clause_removed);
158-
});
143+
with_solver_hardness([this, &bv](solver_hardnesst &hardness) {
144+
// To map clauses to lines of program code, track clause indices in the
145+
// dimacs cnf output. Dimacs output is generated after processing
146+
// clauses to remove duplicates and clauses that are trivially true.
147+
// Here, a clause is checked to see if it can be thus eliminated. If
148+
// not, add the clause index to list of clauses in
149+
// solver_hardnesst::register_clause().
150+
static size_t cnf_clause_index = 0;
151+
bvt cnf;
152+
bool clause_removed = process_clause(bv, cnf);
153+
154+
if(!clause_removed)
155+
cnf_clause_index++;
156+
157+
hardness.register_clause(bv, cnf, cnf_clause_index, !clause_removed);
158+
});
159+
159160
clause_counter++;
160161
}
161162
catch(const Minisat::OutOfMemoryException &)

0 commit comments

Comments
 (0)