在MiniZinc中如何解决此错误?

在MiniZinc中如何解决此错误?

问题描述:

在MiniZinc中,如何获取此代码进行编译而不会出现错误找不到函数或谓词并带有以下签名:'round(var float)'"?

In MiniZinc how can I get this code to compile without the error "no function or predicate with this signature found: `round(var float)'"?

var int: D = 1;
var int: F;
constraint F = round (D / 2);

该消息仅表示MiniZinc不支持带有决策变量(例如"round(var float)")的round().它仅支持"round(float)",即固定的float值. ceil()和floor()相同,仅支持固定的float值.

The message simply mean that MiniZinc don't have any support for round() with decision variables i.e. "round(var float)". It only support "round(float)" i.e. fixed float values. It's the same with ceil() and floor(), there is only support fixed float values.

MiniZinc 2.0会自动将决策变量的参数除法(/)转换为浮点除法(因此不受支持).但是,由于您使用的是var int,因此您可以尝试使用整数除法("D div 2"),它的F = 0.

MiniZinc 2.0 automatically converts the arguments division (/) to float division for the decision variables (which are thus not supported). However, since you are working with var int's you can try with integer division ("D div 2"), which give F = 0.

对于MiniZinc 2.0和支持var float的求解器(例如G12/mip,JaCoP,Gecode和ECLiPSe):如果将F定义为"var float:F",则F为0.5.请注意,G12/fd不支持var float.

For MiniZinc 2.0 together with solvers that supports var float (e.g. G12/mip, JaCoP, Gecode and ECLiPSe): If you had defined F as "var float: F" then F would be 0.5. Note that G12/fd don't support var floats.