return pow(y, seq);
}
+bool Solver::unitPropagate( const vec<Lit>& assumps)
+{
+ model.clear();
+ conflict.clear();
+
+ ok = true;
+
+ assert(assumptions.size() == 0);
+ assert(decisionLevel()== 0);
+
+ // None of the values should be known.
+ for (int i = 0; i < nVars(); i++)
+ {
+ assert(value(i) == l_Undef);
+ }
+
+
+ assumps.copyTo(assumptions);
+
+ while (decisionLevel() < assumptions.size())
+ {
+ // Perform user provided assumption:
+ Lit p = assumptions[decisionLevel()];
+ if (value(p) == l_True){
+ // Dummy decision level:
+ newDecisionLevel();
+ }else if (value(p) == l_False){
+ analyzeFinal(~p, conflict);
+ ok =false;
+ break;
+ }else{
+ newDecisionLevel();
+ uncheckedEnqueue(p);
+ if (propagate() != CRef_Undef)
+ {
+ ok =false;
+ break;
+ }
+ }
+ }
+
+ if (ok)
+ {
+ // Extend & copy model:
+ model.growTo(nVars());
+ for (int i = 0; i < nVars(); i++) model[i] = value(i);
+ }
+
+ cancelUntil(0);
+ assumptions.clear();
+
+ for (int i = 0; i < nVars(); i++)
+ {
+ assert(value(i) == l_Undef);
+ }
+
+ return ok;
+}
+
+
// NOTE: assumptions passed in member-variable 'assumptions'.
lbool Solver::solve_()
{
static Var mapVar(Var x, vec<Var>& map, Var& max)
{
- if (map.size() <= x || map[x] == -1){
+ if (max < x+1)
+ max =x+1;
+ return x;
+
+/*
+
+ if (map.size() <= x || map[x] == -1){
map.growTo(x+1, -1);
map[x] = max++;
}
return map[x];
+ */
}
}
+
void Solver::toDimacs(FILE* f, const vec<Lit>& assumps)
{
// Handle case when solver is in contradictory state:
uint64_t solves, starts, decisions, rnd_decisions, propagations, conflicts;
uint64_t dec_vars, clauses_literals, learnts_literals, max_literals, tot_literals;
+ bool unitPropagate( const vec<Lit>& assumps);
+
protected:
// Helper structures:
int qhead; // Head of queue (as index into the trail -- no more explicit propagation queue in MiniSat).
int simpDB_assigns; // Number of top-level assignments since last execution of 'simplify()'.
int64_t simpDB_props; // Remaining number of propagations that must be made before next execution of 'simplify()'.
+
+
vec<Lit> assumptions; // Current set of assumptions provided to solve by the user.
+
+
Heap<VarOrderLt> order_heap; // A priority queue of variables ordered with respect to the variable activity.
double progress_estimate;// Set by 'search()'.
bool remove_satisfied; // Indicates whether possibly inefficient linear scan for satisfied clauses should be performed in 'simplify'.
// does enough constant propagation to produce sensible code, and this appears to be somewhat
// fragile unfortunately.
-#define l_True (lbool((uint8_t)0)) // gcc does not do constant propagation if these are real constants.
-#define l_False (lbool((uint8_t)1))
-#define l_Undef (lbool((uint8_t)2))
+#define l_True (Minisat::lbool((uint8_t)0)) // gcc does not do constant propagation if these are real constants.
+#define l_False (Minisat::lbool((uint8_t)1))
+#define l_Undef (Minisat::lbool((uint8_t)2))
class lbool {
uint8_t value;