Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gecode 6.3.0: multiple problems with floats #801

Open
matsc-at-sics-se opened this issue Apr 4, 2024 · 2 comments
Open

Gecode 6.3.0: multiple problems with floats #801

matsc-at-sics-se opened this issue Apr 4, 2024 · 2 comments

Comments

@matsc-at-sics-se
Copy link

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.

@zayenz
Copy link
Contributor

zayenz commented Apr 5, 2024

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.

@SYury
Copy link

SYury commented May 20, 2024

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants