{
//############################################################
//############################################################
- void DeleteClauseList(ClauseList *cllp)
+
+ void CNFMgr::DeleteClauseList(ClauseList cllp)
{
- ClauseList::const_iterator iend = cllp->end();
- for (ClauseList::const_iterator i = cllp->begin(); i < iend; i++)
+ ClauseList::const_iterator iend = cllp.end();
+ for (ClauseList::const_iterator i = cllp.begin(); i < iend; i++)
{
delete *i;
}
- delete cllp;
+ cllp.clear();
} //End of DeleteClauseList
+
bool CNFMgr::isAtom(const ASTNode& varphi)
{
bool result;
void CNFMgr::DELETE(ClauseList* varphi)
{
- ClauseList::const_iterator it = varphi->begin();
- for (; it != varphi->end(); it++)
- {
- delete *it;
- }
-
+ DeleteClauseList(*varphi);
delete varphi;
} //End of DELETE()
ClauseList* ReturnXorClauses(void);
- void DELETE(ClauseList* varphi);
+ // Destructors that need to be explicitly called...(yuck).
+ // One deletes the thing passed into it.
+ static void DeleteClauseList(ClauseList varphi);
+ static void DELETE(ClauseList* varphi);
void PrintClauseList(ostream& os, ClauseList& cll);
}; // end of CNFMgr class
// -*- c++ -*-
/********************************************************************
- * AUTHORS: Vijay Ganesh
+ * AUTHORS: Vijay Ganesh, Trevor Hansen
*
* BEGIN DATE: November, 2005
*
bool isTseitinVariable(const ASTNode& n) {
if (n.GetKind() == SYMBOL && n.GetType() == BOOLEAN_TYPE) {
const char * zz = n.GetName();
- //if the variables ARE cnf variables then dont make them
- // decision variables.
if (0 == strncmp("cnf", zz, 3))
{
return true;
{
bm->PrintStats(newSolver);
bm->GetRunTimes()->stop(RunTimes::SendingToSAT);
+ CNFMgr::DeleteClauseList(cll);
return false;
}
} // End of For-loop adding the clauses
+ // Free the clause list before SAT solving.
+ CNFMgr::DeleteClauseList(cll);
+
bm->GetRunTimes()->stop(RunTimes::SendingToSAT);
bm->GetRunTimes()->start(RunTimes::Solving);
newSolver.solve();
{
cl_size = CLAUSAL_BUCKET_LIMIT;
}
-// else
-// {
-// cl_size = CLAUSAL_BUCKET_LIMIT-1;
-// }
//If no clauses of size cl_size have been seen, then create a
//bucket for that size
for(int count=1;it!=itend;it++, count++)
{
ClauseList *cl = (*it).second;
-// if(CLAUSAL_BUCKET_LIMIT == count)
-// {
-// sat = toSATandSolve(SatSolver,*cl, false, true);
-// }
-// else
- {
sat = toSATandSolve(SatSolver,*cl);
- }
+
if(!sat)
{
return sat;
bm->ASTNodeStats("after bitblasting: ", BBFormula);
bm->GetRunTimes()->stop(RunTimes::BitBlasting);
- CNFMgr* cm = new CNFMgr(bm);
- ClauseList* cl = cm->convertToCNF(BBFormula);
+ CNFMgr cm(bm);
+ ClauseList* cl = cm.convertToCNF(BBFormula);
- ClauseList* xorcl = cm->ReturnXorClauses();
+ ClauseList* xorcl = cm.ReturnXorClauses();
ClauseBuckets * cb = Sort_ClauseList_IntoBuckets(cl);
+ cl->clear(); // clause buckets now point to the clauses.
+ delete cl;
bool sat = CallSAT_On_ClauseBuckets(SatSolver, cb);
- //bool sat = toSATandSolve(SatSolver, *cl);
for (ClauseBuckets::iterator it = cb->begin(); it != cb->end(); it++)
delete it->second;
if(!sat)
{
- cm->DELETE(cl);
- cm->DELETE(xorcl);
- delete cm;
+ CNFMgr::DeleteClauseList(*xorcl);
+ delete xorcl;
return sat;
}
#endif
- cm->DELETE(cl);
- cm->DELETE(xorcl);
- delete cm;
+ delete xorcl;
return sat;
}