Skip to content

Commit

Permalink
Put the implies() method in the right place.
Browse files Browse the repository at this point in the history
  • Loading branch information
liffiton committed Sep 23, 2013
1 parent b60be3d commit f0f5100
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 31 deletions.
28 changes: 0 additions & 28 deletions core/Solver.cc
Original file line number Diff line number Diff line change
Expand Up @@ -792,34 +792,6 @@ lbool Solver::solve_()
return status;
}

bool Solver::implies(const vec<Lit>& assumps, vec<Lit>& out, bool all=false)
{
trail_lim.push(trail.size());
for (int i = 0; i < assumps.size(); i++){
Lit a = assumps[i];

if (value(a) == l_False){
cancelUntil(0);
return false;
}else if (value(a) == l_Undef)
uncheckedEnqueue(a);
}

// Adapted from similar function in MiniSat
// Added option to get all implications, including level 0 assignments.
unsigned trail_before = (all) ? 0 : trail.size();
bool ret = true;
if (propagate() == CRef_Undef){
out.clear();
for (int j = trail_before; j < trail.size(); j++)
out.push(trail[j]);
}else
ret = false;

cancelUntil(0);
return ret;
}

//=================================================================================================
// Writing CNF to DIMACS:
//
Expand Down
3 changes: 0 additions & 3 deletions core/Solver.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,6 @@ class Solver {
bool solve (Lit p, Lit q, Lit r); // Search for a model that respects three assumptions.
bool okay () const; // FALSE means solver is in a conflicting state

// Adopted from newer version of Minisat
bool implies (const vec<Lit>& assumps, vec<Lit>& out, bool all);

void toDimacs (FILE* f, const vec<Lit>& assumps); // Write CNF to file in DIMACS-format.
void toDimacs (const char *file, const vec<Lit>& assumps);
void toDimacs (FILE* f, Clause& c, vec<Var>& map, Var& max);
Expand Down
28 changes: 28 additions & 0 deletions minicard/Solver.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1089,6 +1089,34 @@ lbool Solver::solve_()
return status;
}

bool Solver::implies(const vec<Lit>& assumps, vec<Lit>& out, bool all=false)
{
trail_lim.push(trail.size());
for (int i = 0; i < assumps.size(); i++){
Lit a = assumps[i];

if (value(a) == l_False){
cancelUntil(0);
return false;
}else if (value(a) == l_Undef)
uncheckedEnqueue(a);
}

// Adapted from similar function in MiniSat
// Added option to get all implications, including level 0 assignments.
unsigned trail_before = (all) ? 0 : trail.size();
bool ret = true;
if (propagate() == CRef_Undef){
out.clear();
for (int j = trail_before; j < trail.size(); j++)
out.push(trail[j]);
}else
ret = false;

cancelUntil(0);
return ret;
}

//=================================================================================================
// Writing CNF to DIMACS:
//
Expand Down
3 changes: 3 additions & 0 deletions minicard/Solver.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ class Solver {
bool solve (Lit p, Lit q, Lit r); // Search for a model that respects three assumptions.
bool okay () const; // FALSE means solver is in a conflicting state

// Adopted from newer version of Minisat
bool implies (const vec<Lit>& assumps, vec<Lit>& out, bool all);

void toDimacs (FILE* f, const vec<Lit>& assumps); // Write CNF to file in DIMACS-format.
void toDimacs (const char *file, const vec<Lit>& assumps);
void toDimacs (FILE* f, Clause& c, vec<Var>& map, Var& max);
Expand Down

0 comments on commit f0f5100

Please sign in to comment.