21 #define __STDC_LIMIT_MACROS 
   22 #define __STDC_FORMAT_MACROS 
   35 #include "../minisat/Solver.h" 
   36 #include "../minisat/SimpSolver.h" 
   61 #if EZMINISAT_SIMPSOLVER && EZMINISAT_INCREMENTAL 
   67 #if EZMINISAT_SIMPSOLVER && EZMINISAT_INCREMENTAL 
   76     idx = idx < 0 ? -idx : 
idx;
 
   97 bool ezMiniSAT::solver(
const std::vector<int> &modelExpressions, std::vector<bool> &modelValues, 
const std::vector<int> &assumptions)
 
  117     std::vector<int> extraClauses, modelIdx;
 
  119     for (
auto id : assumptions)
 
  120         extraClauses.push_back(
bind(
id));
 
  121     for (
auto id : modelExpressions)
 
  122         modelIdx.push_back(
bind(
id));
 
  129 #if EZMINISAT_INCREMENTAL 
  130     std::vector<std::vector<int>> 
cnf;
 
  133     const std::vector<std::vector<int>> &cnf = this->
cnf();
 
  139 #if EZMINISAT_SIMPSOLVER && EZMINISAT_INCREMENTAL 
  142     cnfFrozenVars.clear();
 
  145     for (
auto &clause : cnf) {
 
  147         for (
auto idx : clause) {
 
  152 #if EZMINISAT_SIMPSOLVER 
  154                 fprintf(stderr, 
"Assert in %s:%d failed! Missing call to ezsat->freeze(): %s (lit=%d)\n",
 
  169     for (
auto idx : extraClauses) {
 
  174 #if EZMINISAT_SIMPSOLVER 
  176             fprintf(stderr, 
"Assert in %s:%d failed! Missing call to ezsat->freeze(): %s\n", __FILE__, __LINE__, 
cnfLiteralInfo(idx).c_str());
 
  183     struct sigaction sig_action;
 
  184     struct sigaction old_sig_action;
 
  185     int old_alarm_timeout = 0;
 
  189         sigemptyset(&sig_action.sa_mask);
 
  190         sig_action.sa_flags = SA_RESTART;
 
  193         old_alarm_timeout = alarm(0);
 
  194         sigaction(SIGALRM, &sig_action, &old_sig_action);
 
  206         sigaction(SIGALRM, &old_sig_action, 
NULL);
 
  207         alarm(old_alarm_timeout);
 
  211     if (!foundSolution) {
 
  212 #if !EZMINISAT_INCREMENTAL 
  221     modelValues.resize(modelIdx.size());
 
  223     for (
size_t i = 0; i < modelIdx.size(); i++)
 
  225         int idx = modelIdx[i];
 
  226         bool refvalue = 
true;
 
  229             idx = -
idx, refvalue = 
false;
 
  231         using namespace Minisat;
 
  236 #if !EZMINISAT_INCREMENTAL 
const std::vector< std::vector< int > > & cnf() const 
 
std::string cnfLiteralInfo(int idx) const 
 
#define EZMINISAT_VERBOSITY
 
Lit mkLit(Var var, bool sign=false)
 
lbool modelValue(Var x) const 
 
Minisat::SimpSolver Solver
 
void setFrozen(Var v, bool b)
 
static const int CONST_FALSE
 
static std::string idx(std::string str)
 
static void alarmHandler(int)
 
std::set< int > cnfFrozenVars
 
int numCnfVariables() const 
 
static ezMiniSAT * alarmHandlerThis
 
Var newVar(lbool upol=l_Undef, bool dvar=true)
 
virtual bool eliminated(int idx)
 
bool addClause(const vec< Lit > &ps)
 
static const int CONST_TRUE
 
bool isEliminated(Var v) const 
 
virtual bool solver(const std::vector< int > &modelExpressions, std::vector< bool > &modelValues, const std::vector< int > &assumptions)
 
std::vector< int > minisatVars
 
bool mode_non_incremental() const 
 
virtual void freeze(int id)
 
bool solve(const vec< Lit > &assumps, bool do_simp=true, bool turn_off_simp=false)
 
static clock_t alarmHandlerTimeout
 
int bind(int id, bool auto_freeze=true)