backtracking - How to implement non chronological backtracking
问题描述
I'm working on a CDCL SAT-Solver. I don't know how to implement non-chronological backtracking. Is this even possible with recursion or is it only possible in a iterative approach.
Actually what i have done jet is implemented a DPLL Solver which works with recursion. The great differnece from DPLL and CDCL ist that the backracking in the tree is not chronological. Is it even possible to implement something like this with recursion. In my opionion i have two choices in the node of the binary-decision-tree if one of to path leads i a conlict:
- I try the other path -> but then it would be the same like the DPLL, means a chronological backtracking
- I return: But then i will never come back to this node.
So am i missing here something. Could it be that the only option is to implement it iterativly?
解决方案
可以在使用递归进行变量分配的求解器中实现非按时间顺序的回溯(或通常称为回跳)。在支持非本地 goto 的语言中,您通常会使用该方法。例如,在 C 语言中,您将使用 setjmp() 记录堆栈中的一个点,并使用 longjmp() 回跳到该点。C# 有 try-catch 块,Lispy 语言可能有 catch-throw,等等。
如果该语言不支持非本地 goto,那么您可以在代码中实现替代。不是 dpll() 返回 FALSE,而是让它返回一个包含 FALSE 和需要回溯的级别数的元组。上游调用者递减元组中的计数器并返回它,直到返回零。
推荐阅读
- django - 如何在不覆盖以前数据的情况下将选定数据从一个表临时保存到另一个表?
- nativescript - Nativescript UI 未更新
- scala - 在像 scala 这样的函数式编程语言中,停止迭代集合的方法是什么?例如; 如果给定包含 0,则返回 true
- python - 如何在 Flask SQLAlchemy 中递归获取孩子?
- sql - 带有名称和 empID 的 Oracle Case 语句
- java - 在Java中打印小数点后1位
- eclipse - 如何判断eclipse项目的成熟度
- ios - MacOS - iOS 模拟器:如何禁用模拟器上的新工具栏?[包含图片]
- visual-studio-code - 出现错误 - ASL CLI 不起作用 - 未知选项“-l”
- ios - 如何设置 UICollectionViewCell 的内容