从零开始编写SAT求解器(三)
核心算法:DPLL
#include "DPLL.h"
bool DPLL::check_sat() {
std::unordered_map<int,int> atomStatus;
int clause_num = phi.clauses.size();
int atomNum = phi.num_variable;
for(int i=1;i<=atomNum;i++)
result.insert(std::make_pair(i,true));
int* nodeStatus = new int[atomNum];
for(int i=0;i<atomNum;i++)
nodeStatus[i]=0;
int ptr = 0;
while(true){
if(nodeStatus[ptr]==2)
break;
else if(nodeStatus[ptr]==0) {
nodeStatus[ptr]++;
result[ptr + 1] = false;
}
else {
nodeStatus[ptr]++;
result[ptr + 1] = true;
}
int solveStatus = 2;
bool wholeValue