定义 |
// Solver state: |
初始化 | , ok (true) |
使用 |
在以下函数中数据成员ok被使用 |
bool Solver::simplifyLearnt_x(vec<CRef>& learnts_x); bool Solver::simplifyLearnt_core(); bool Solver::simplifyLearnt_tier2(); bool Solver::simplifyAll(); bool Solver::addClause_(vec<Lit>& ps); bool Solver::simplify(); lbool Solver::search(int& nof_conflicts){assert(ok);......} lbool Solver::solve_() model.clear(); solves++; ...... } void Solver::toDimacs(FILE* f, const vec<Lit>& assumps); |
|
simplifyAll 化简的 含义: 移除 已满足 的子句 |
simplifyAll集中使用在每次重启(实际进行了条件限定)之后,见search函数的前部。 主要进行的工作是:和simplify函数只是移除sat子句不同,是真正利用自动推理相关原理进行化简。 simplifyAll直接关联的化简函数如下: ——void Solver::simpleAnalyze(CRef confl, vec<Lit>& out_learnt, vec<CRef>& reason_clause, bool True_confl) ——void Solver::simplifyLearnt(Clause& c) ——bool Solver::simplifyLearnt_x(vec<CRef>& learnts_x) ——bool Solver::simplifyLearnt_core() ——bool Solver::simplifyLearnt_tier2()
bool Solver::simplifyAll() { //// simplified_length_record = original_length_record = 0; if (!ok || propagate() != CRef_Undef) return ok = false; //// cleanLearnts(also can delete these code), here just for analyzing //if (local_learnts_dirty) cleanLearnts(learnts_local, LOCAL); //if (tier2_learnts_dirty) cleanLearnts(learnts_tier2, TIER2); //local_learnts_dirty = tier2_learnts_dirty = false; if (!simplifyLearnt_core()) return ok = false; if (!simplifyLearnt_tier2()) return ok = false; //if (!simplifyLearnt_x(learnts_local)) return ok = false; checkGarbage(); //// // printf("c size_reduce_ratio : %4.2f%%\n", // original_length_record == 0 ? 0 :
|
赋值改变的操作体现在几个化简函数体中。主要代码段如下: return ok = (propagate() == CRef_Undef);//传播没有遇到冲突返回值为CRef_Undef
1 if (c.size() == 1){ 2 // when unit clause occur, enqueue and propagate 3 uncheckedEnqueue(c[0]); 4 if (propagate() != CRef_Undef){ 5 ok = false; 6 return false; 7 } 8 // delete the clause memory in logic 9 c.mark(1); 10 ca.free(cr); 11 //#ifdef BIN_DRUP 12 // binDRUP('d', c, drup_file); 13 //#else 14 // fprintf(drup_file, "d "); 15 // for (int i = 0; i < c.size(); i++) 16 // fprintf(drup_file, "%i ", (var(c[i]) + 1) * (-2 * sign(c[i]) + 1)); 17 // fprintf(drup_file, "0\n"); 18 //#endif 19 } 20 。。。。。。。 21 }
|
|
simplify 化简的 含义: 移除 已满足 的子句 |
【前 提】:传播的0层中已经有若干文字(bool Solver::addClause_(vec<Lit>& ps)增加子句时, 单文字子句直接进入传播的0层)
【simplify化简操作调用】: 1.在真正的CDCL开始之间已经被调用过,见派生类函数:bool SimpSolver::eliminate_()之中。 2.化简函数simplify其余的调用都在每次search函数被调用,见lbool Solver::search(int& nof_conflicts)之中。 在传播没有发现冲突阶段集中了若干操作: —— 化简操作 // Simplify the set of problem clauses: ——学习子句管理(删除) ——是否“重启”的检查
1 /*________________________________________________________________________________________ 2 | 3 | simplify : [void] -> [bool] 4 | 5 | Description: 6 | Simplify the clause database according to the current top-level assigment.
|