简体   繁体   English

如何最好地在 C++ 中实现 DPLL?

[英]How to best implement DPLL in C++?

I am trying to implement DPLL algorithm in C++, I am wondering what kind of data structure would be best for solving this type of recursion problem.我正在尝试用 C++ 实现DPLL算法,我想知道哪种数据结构最适合解决此类递归问题。 Right now I am using vectors, but the code is long and ugly.现在我正在使用向量,但代码又长又丑。 Are there any suggestions?有什么建议吗?

function DPLL(Φ)
   if Φ is a consistent set of literals
       then return true;
   if Φ contains an empty clause
       then return false;
   for every unit clause l in Φ
      Φ ← unit-propagate(l, Φ);
   for every literal l that occurs pure in Φ
      Φ ← pure-literal-assign(l, Φ);
   l ← choose-literal(Φ);
   return DPLL(ΦΛl) or DPLL(ΦΛnot(l));

An array is good for representing the current assignment, as it provides random access to any of the propositions.数组非常适合表示当前的赋值,因为它提供对任何命题的随机访问。 To represent clauses, one can use STL's sets of the proposition indices.为了表示子句,可以使用 STL 的命题索引集。

To implement a very efficient SAT solver you will need some more data structures (for storing watched literals and explanations).要实现非常高效的 SAT 求解器,您将需要更多数据结构(用于存储观察到的文字和解释)。 A very readable introduction to these concepts can be found at http://poincare.matf.bg.ac.rs/~filip/phd/sat-tutorial.pdf .可以在http://poincare.matf.bg.ac.rs/~filip/phd/sat-tutorial.pdf 中找到对这些概念的非常易读的介绍。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM