libminizinc icon indicating copy to clipboard operation
libminizinc copied to clipboard

Gecode 6.3.0: multiple problems with floats

Open matsc-at-sics-se opened this issue 10 months ago • 2 comments

var float: x;
var float: y;
constraint x != y;
bash-3.2$ minizinc --solver gecode bugs.mzn 
Error: Registry: Constraint float_lin_ne not found
var -4.9 .. 5.1: x;
var 2..3: r = floor(x);
solve :: float_search([x], 0.01, input_order, indomain_reverse_split) maximize x;
output ["x = \(x), r = \(r);\n"];
bash-3.2$ minizinc --solver gecode bugs.mzn 
x = 4.0, r = 4;

r = 4 is outside the domain.

var -4.9 .. 5.1: x;
var int: r = ceil(x);
solve :: int_search([r], input_order, indomain_max) maximize r;
output ["x = \(x), r = \(r);\n"];
bash-3.2$ minizinc --solver gecode bugs.mzn 
x = 5.0, r = 5;

There is a solution with r = 6.

var -4.9 .. 5.1: x;
var 2..3: r = ceil(x);
solve :: int_search([r], input_order, indomain_min) minimize r;
output ["x = \(x), r = \(r);\n"];
bash-3.2$ minizinc --solver gecode bugs.mzn 
x = 1.0, r = 1;

r = 1 is outside the domain.

var float: a;
var float: b = sin(a);
% var float: b = cos(a);
% var float: b = tan(a);
% var float: b = asin(a);
% var float: b = acos(a);
% var float: b = atan(a);
% var float: b = sinh(a);
% var float: b = cosh(a);
% var float: b = tanh(a);
% var float: b = asinh(a);
% var float: b = acosh(a);
% var float: b = atanh(a);
% var float: b = ln(a);
% var float: b = log2(a);
% var float: b = log10(a);
% var float: b = exp(a);
% var float: b = pow(a,2.0);
bash-3.2$ minizinc --solver gecode bugs.mzn 
Error: Registry: Constraint float_sin not found

and similarly for all the other transcendentals.

matsc-at-sics-se avatar Apr 04 '24 06:04 matsc-at-sics-se

For the transcendentals, it depends on if Gecode is compiled with MPFR-support or not, and it appears that this is not included in the included version of Gecode. This can be checked by running fzn-gecode with the help flag.

$ X /Applications/MiniZincIDE.app/Contents/Resources/bin/fzn-gecode --help
Gecode FlatZinc interpreter
 - Supported FlatZinc version: 1.6

Gecode configuration information:
 - Version: 6.3.0
 - Variable types: BoolVar IntVar SetVar FloatVar 
 - Trigonometric and transcendental float constraints: disabled
 - Thread support: enabled (10 processing units)
 - Gist support: enabled
 - CPProfiler support: enabled
...

Will check on the erroneous cases. On initial inspection I am unclear on how the translation into FlatZinc is done.

zayenz avatar Apr 05 '24 13:04 zayenz

Found another case when Gecode has problems with floats. On the example from the docs it prints "UNSATISFIABLE" while CBC finds the solution (I'm using version 2.8.4)

SYury avatar May 20 '24 12:05 SYury