简体   繁体   English

ECLIPSe-CLP 中不可控的自动传播行为是什么?

[英]What is the uncontrollable automatic propagation behavior in ECLIPSe-CLP?

I am trying to research, evaluate, and compare some searching methods in ECLIPSe-CLP.我正在尝试研究、评估和比较 ECLIPSe-CLP 中的一些搜索方法。 The key method of evaluating complexity and the efficacy of a method in said system is counting backtracks, implemented with the predicate search/6 from lib(ic_search).评估所述系统中方法的复杂性和有效性的关键方法是计算回溯,使用来自 lib(ic_search) 的谓词 search/6 实现。 However, in my testing, I noticed that the Eclipse software applies some process similar to domain propagation automatically before entering the search, which I have no way of controlling, which apparently solves certain problems without any backtracks.但是,在我的测试中,我注意到Eclipse软件在进入搜索之前自动应用了一些类似于域传播的过程,我无法控制,这显然解决了某些问题而没有任何回溯。 This hinders my evaluation of search methods as I have no control over the domains and/or problem statement when it passes into search.这阻碍了我对搜索方法的评估,因为当它进入搜索时,我无法控制域和/或问题陈述。 I would like to know what the process employed is, and whether it can be disabled or if I can work around it.我想知道所采用的流程是什么,以及是否可以禁用它或者我是否可以解决它。 Attached below is a very primitive sample code and its tracing.下面附上一个非常原始的示例代码及其跟踪。 Problems such as SEND + MORE = MONEY and the Australian Map coloring problems can be similarly solved with 0 backtracks. SEND + MORE = MONEY 和澳大利亚的 Map 着色问题等问题可以类似地用 0 回溯解决。

Thanks in advance!提前致谢!

Eclipse code Eclipse代码

:- lib(ic), lib(ic_global), lib(ic_search).
    
go :-
    simpleproblem(Vars).

simpleproblem(Vars) :-
    Vars = [A,B],
    Vars :: [0..1],
    A + B #= 2,
    search(Vars,0,input_order,indomain,complete,[backtrack(Backtracks)]),
    writeln(backtracks:Backtracks),
    writeln(Vars).

Tracing log跟踪日志

(1) 1 CALL  go
(2) 2 CALL  simpleproblem(_598)
(3) 3 CALL  ... = ...
(3) 3 EXIT  ... = ...
(4) 3 CALL  '::_body'([_1028, _1030], [0 .. 1], eclipse)
(4) 3 EXIT  '::_body'([_1476{[0, ...]}, _1490{[...]}], [0 .. 1], eclipse)
(5) 3 CALL  _1490{[0, ...]} + _1476{[0, ...]} #= 2
(9) 4 CALL  wake
(6) 5 RESUME<2>  0 #= 0
(6) 5 EXIT<2>  0 #= 0
(9) 4 EXIT  wake
(5) 3 EXIT  1 + 1 #= 2
(10) 3 CALL  search_body([1, 1], 0, input_order, indomain, complete, [backtrack(_3046)], eclipse)

The very reason for the effectiveness of Constraint Programming is the principle of interleaving propagation with search.约束编程的有效性的真正原因是交错传播与搜索的原理。 Because this is really the essence of CP, I am not sure it makes much sense for you to look at search methods in isolation.因为这确实是 CP 的精髓,所以我不确定你孤立地看待搜索方法是否有意义。

交错传播和搜索

Propagation is performed in a data-driven way by the implementation of each individual constraint: whenever a variable domain changes, eg during the initial constraint setup or by a search decision, the constraint will try to propagate the consequences.通过实施每个单独的约束以数据驱动的方式执行传播:每当变量域发生变化时,例如在初始约束设置期间或通过搜索决策,约束将尝试传播结果。 This may lead to more domain changes, which cause further propagation, and so on, until a fixpoint is reached.这可能会导致更多的域更改,从而导致进一步的传播,等等,直到达到一个固定点。

Once no further propagation is possible, the search control takes over again, looks at the the constraint network and current variable domains, and decides on the next guess.一旦没有进一步的传播是可能的,搜索控制再次接管,查看约束网络和当前变量域,并决定下一个猜测。 When a guess is made (in the form of a variable instantiation, domain splitting, etc), propagation is triggered again.当进行猜测时(以变量实例化、域拆分等形式),再次触发传播。

Implementation-wise, there is a clear separation: propagation is done by the individual constraints (in your example #=/2 only), while the search control algorithm is in the search/6 predicate.在实现方面,有一个明确的分离:传播是由各个约束完成的(仅在您的示例中#=/2 ),而搜索控制算法在search/6谓词中。 However, there is a strong interdependency between them, because they communicate back-and-forth via the constraint network.但是,它们之间存在很强的相互依赖性,因为它们通过约束网络来回通信。

Note that most search techniques, such as the popular first-fail heuristics, heavily rely on the result of propagation, otherwise they could not make their informed guesses.请注意,大多数搜索技术,例如流行的首次失败启发式算法,严重依赖于传播结果,否则他们无法做出明智的猜测。 While in principle it would be possible for you to use non-propagating implementations for all constraints (eg wait for all their variables to be instantiated, and only then test for satisfaction), this would make many search options pointless, and you would not learn much by counting backtracks.虽然原则上您可以对所有约束使用非传播实现(例如,等待它们的所有变量都被实例化,然后才测试是否满意),但这会使许多搜索选项毫无意义,并且您不会学习通过计算回溯。

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

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