问题
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);
回答1:
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 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.
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.
来源:https://stackoverflow.com/questions/28406318/in-minizinc-how-can-i-resolve-this-error