简体   繁体   English

半具体化的谓词是否被视为标准的一部分?

[英]Are half-reified predicates considered part of the standard?

The FlatZinc documentation says that only non-standard predicates must be declared at the top of a FlatZinc model: FlatZinc 文档说只有非标准谓词必须在 FlatZinc model 的顶部声明:

Predicates used in the model that are not standard FlatZinc must be declared at the top of a FlatZinc model, before any other lexical items. model 中使用的非标准 FlatZinc 的谓词必须在 FlatZinc model 的顶部声明,在任何其他词汇项之前。 Predicate declarations take the form谓词声明的形式

<predicate-item>::= "predicate" <identifier> "(" [ <pred-param-type>: <identifier> ","... ] ")" ";"

source: link来源: 链接

Apparently, the mzn2fzn compiler adds half-reified predicate declarations at the top of compiled files (see: this github issue ):显然,mzn2fzn 编译器在编译文件的顶部添加了半具体化的谓词声明(请参阅: 此 github 问题):

predicate int_eq_imp(var int: a, var int: b, var bool: r);

I find this behavior somewhat confusing, because half-reified predicates appear to be part of the standard .我觉得这种行为有点令人困惑,因为半具体化的谓词似乎是标准的一部分。

Q:问:

  • Isn't this a bug, since only non-standard predicates should be declared at the top of the file?这不是一个错误,因为只有非标准谓词应该在文件顶部声明?
  • Is there a way to suppress such declarations?有没有办法压制这样的声明?

The definition of "non-standard" might not be well-defined in the current version of the documentation. “非标准”的定义在当前版本的文档中可能没有明确定义。 The meaning is that all predicates that are not FlatZinc Builtins will be declared at the top of the FlatZinc model.意思是所有不是FlatZinc Builtins的谓词都将声明在 FlatZinc model 的顶部。

As MiniZinc was originally designed for constraint programming solvers, the idea was that even FlatZinc could in some cases be compatible with different solvers.由于 MiniZinc 最初是为约束规划求解器设计的,其想法是即使 FlatZinc 在某些情况下也可以与不同的求解器兼容。 The assumption being that all solvers would support at least all required FlatZinc builtins and then the solver can quickly check the declarations to see if it supports all other predicates used in the FlatZinc model.假设所有求解器都至少支持所有必需的 FlatZinc 内置函数,然后求解器可以快速检查声明以查看它是否支持 FlatZinc model 中使用的所有其他谓词。

These days, this is far from the truth.如今,这与事实相去甚远。 Many of the MiniZinc solvers do not support the FlatZinc builtins directly, but instead give redefinitions.许多 MiniZinc 求解器不直接支持 FlatZinc 内置函数,而是重新定义。 Even the packaged CP solvers like Gecode and Chuffed do not actually use the declarations in the MiniZinc model, but process the constraints against their internal registry throwing an error when they encounter usage of an unknown predicate.即使像 Gecode 和 Chuffed 这样的打包 CP 求解器实际上也没有使用 MiniZinc model 中的声明,而是在遇到使用未知谓词时针对其内部注册表处理约束并抛出错误。

If the FlatZinc standard was ever to change, then I think that it would either provide the declarations of all predicates used in the FlatZinc model or it would include any declarations.如果 FlatZinc 标准要改变,那么我认为它要么提供 FlatZinc model 中使用的所有谓词的声明,要么包括任何声明。 The latter might be more likely as we should not assume that FlatZinc models can be reused for different solvers, so the declaration offer little practical use.后者可能更有可能,因为我们不应该假设 FlatZinc 模型可以用于不同的求解器,因此该声明几乎没有实际用途。

To summarise and answer your questions directly.总结并直接回答您的问题。 This is not a bug, even though int_eq_imp might seem standard, it is not part of the FlatZinc builtins.这不是错误,尽管int_eq_imp看起来很标准,但它不是 FlatZinc 内置函数的一部分。 There is currently not way to suppress these declarations, but a solver can simply ignore all lines that contain predicate declarations and handle unknown predicates when processing constraints.目前没有办法抑制这些声明,但求解器可以简单地忽略所有包含谓词声明的行,并在处理约束时处理未知谓词。

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

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