简体   繁体   English

minizinc中的域和边界传播注释

[英]domain and bounds propagation annotation in minizinc

I wanted to know what exactly is domain and bounds propagation annotation. 我想知道什么是域和边界传播注释。 When should we select one over other? 我们什么时候应该选择一个呢? I understand domain is set of value that a variable can take and bounds are lowest and highest value a variable can take. 我了解域是变量可以采用的一组值,并且边界是变量可以采用的最低值和最高值。

The MiniZinc language doesn't tell the solver what consistency level it has to use for its various constraints. MiniZinc语言不会告诉求解器其各种约束必须使用何种一致性级别。 For example Gecode will use value consistency by default for the alldifferent predicate. 例如,默认情况下, alldifferent谓词使用值一致性。 There are many different kinds of consistencies and it's up to the solver to determine a sensible default. 一致性有许多种,由求解器确定合理的默认值。

This default is not always correct for your purpose. 此默认值并不总是符合您的目的。 This is why MiniZinc offers an option to annotate a constraint to hint a solver to which consistency to use. 这就是为什么MiniZinc提供一个选项来注释约束以提示求解器要使用哪种一致性。

  • constraint alldifferent(x) ::bounds; will propagate alldifferent with bounds consistency. 将以边界一致性传播所有alldifferent
  • constraint alldifferent(x) ::domain; will propagate alldifferent with domain consistency. 将以域一致性传播所有alldifferent内容。

Note that these annotations might be ignored; 请注意,这些注释可能会被忽略; for example when no domain consistent propagator is available in the solver. 例如,当求解器中没有可用的域一致性传播器时。 Some solvers, like MIP solvers, won't even propagate as such and will thus also not be influenced by these annotations. 某些求解器(例如MIP求解器)甚至不会照此传播,因此也不会受到这些注释的影响。

It is worth emphasising that the difference between bounds consistency and domain consistency is whether to spend extra time pruning non-solutions (at least in the case of CP solvers, the technology I have experience with); 值得强调的是,边界一致性和域一致性之间的区别在于是否要花费额外的时间修剪非解决方案(至少对于CP求解器而言,这是我有经验的技术); bounds will be faster for many constraints, but will leave more non-solutions in the domains of the constrained variables. 对于许多约束,边界将更快,但在约束变量的域中将留下更多的非解。

I'd like to augment Dekker's answer by adding that whether to use domain or bounds consistency depends a lot on your model and on the constraint in question (as well as the solver technology). 我想补充一下Dekker的答案,他补充说是否使用域一致性或边界一致性在很大程度上取决于您的模型和所考虑的约束(以及求解器技术)。 In some cases, spending the extra effort enforcing a higher level of consistency might be entirely wasted, while in others it might pay off, either because your have few variables or they have small domains, or because pruning them tightly causes a lot of inference (that is, further removal of values not participating in a solution) on other variables. 在某些情况下,花费额外的精力来实现更高级别的一致性可能会完全浪费,而在另一些情况下,这可能会有所收获,或者是因为您的变量很少或它们的域很小,或者因为严格修剪它们会导致大量推断(也就是说,进一步移除其他变量上不参与解决方案的值)。

The only way to know for sure is to experiment and see what works! 唯一可以确定的方法就是尝试一下,看看有什么用!

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

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