minisat_types.cpp

Go to the documentation of this file.
00001 /*****************************************************************************/
00002 /*!
00003  *\file minisat_types.cpp
00004  *\brief MiniSat internal types
00005  *
00006  * Author: Alexander Fuchs
00007  *
00008  * Created: Fri Sep 08 11:04:00 2006
00009  *
00010  * <hr>
00011  *
00012  * License to use, copy, modify, sell and/or distribute this software
00013  * and its documentation for any purpose is hereby granted without
00014  * royalty, subject to the terms and conditions defined in the \ref
00015  * LICENSE file provided with this distribution.
00016  * 
00017  * <hr>
00018  */
00019 /*****************************************************************************/
00020 
00021 
00022 
00023 #include "minisat_types.h"
00024 
00025 using namespace std;
00026 
00027 namespace MiniSat {
00028 
00029   // static class members
00030   Clause* Clause::s_decision = NULL;
00031   Clause* Clause::s_theoryImplication = NULL;
00032 
00033   Clause* Clause_new(const vector<Lit>& ps, int id) {
00034     DebugAssert(sizeof(Lit)   == sizeof(uint), "MiniSat::Types::Clause_new Lit");
00035     DebugAssert(sizeof(float) == sizeof(uint), "MiniSat::Types::Clause_new float");
00036     DebugAssert(sizeof(id)    == sizeof(uint), "MiniSat::Types::Clause_new id");
00037 
00038     //   size_learnt
00039     // + literals
00040     // + id
00041     void* mem = xmalloc<char>(sizeof(uint)*(ps.size() + 2));
00042     return new (mem) Clause(false, ps, id);
00043   }
00044 
00045   Clause* Lemma_new(const vector<Lit>& ps, int id, int pushID) {
00046     DebugAssert(sizeof(Lit)      == sizeof(uint), "MiniSat::Types::Lemma_new Lit");
00047     DebugAssert(sizeof(float)    == sizeof(uint), "MiniSat::Types::Lemma_new float");
00048     DebugAssert(sizeof(id)       == sizeof(uint), "MiniSat::Types::Lemma_new id");
00049 
00050     //   size_learnt
00051     // + literals
00052     // + id
00053     // + pushID
00054     // + activity
00055     void* mem = xmalloc<char>(sizeof(uint)*(ps.size() + 4));
00056     Clause* clause = new (mem) Clause(true, ps, id);
00057     clause->pushID() = pushID;
00058     return clause;
00059   }
00060 
00061   Clause* Clause::Decision() {
00062     if (s_decision == NULL) {
00063       vector<Lit> lits;
00064       s_decision = Clause_new(lits, -1);
00065     }
00066     
00067     return s_decision;
00068   }
00069   
00070   Clause* Clause::TheoryImplication() {
00071     if (s_theoryImplication == NULL) {
00072       vector<Lit> lits;
00073       s_theoryImplication = Clause_new(lits, -2);
00074     }
00075     
00076     return s_theoryImplication;
00077   }
00078 
00079   void Clause::toLit(vector<Lit>& literals) const {
00080     for (int i = 0; i < size(); ++i) {
00081       literals.push_back(data[i]);
00082     }
00083   }
00084 
00085 }

Generated on Tue Jul 3 14:33:38 2007 for CVC3 by  doxygen 1.5.1