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

Wrong result for ceil, floor and round constraints #657

Closed
krzku opened this issue Mar 31, 2023 · 1 comment
Closed

Wrong result for ceil, floor and round constraints #657

krzku opened this issue Mar 31, 2023 · 1 comment
Labels
bug resolved Issue is resolved and the feature or fix will be part of next release

Comments

@krzku
Copy link

krzku commented Mar 31, 2023

The following model that uses new defined ceil, floor and round constraints gives a wrong answer with gecode.

var -1.75..1.75: p;
var -2..2: f;
var -2..2: c;
var -2..2: r;

constraint
f = floor(p) /\ c = ceil(p) /\ r = round(p)
/
f = -2 /\ c = 0
;
solve satisfy;
output ["p = (p)\nf = (f)\nc = (c)\nr = (r)"]

The gecode answer is

p = -1.0
f = -2
c = 0
r = -1

The difference between ceil and floor values should not be greater than one but it is two here.

@krzku
Copy link
Author

krzku commented Mar 31, 2023

I think, the definitions in redefinitions-2.7.1.mzn are incorrect for float_ceil and float_floor. They should be

predicate float_ceil(var float: x, var int: y) =
y - 1 < x /\ x <= y;

predicate float_floor(var float: x, var int: y) =
y <= x /\ x < y + 1;

@Dekker1 Dekker1 added the bug label Apr 1, 2023
@cyderize cyderize added the resolved Issue is resolved and the feature or fix will be part of next release label Apr 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug resolved Issue is resolved and the feature or fix will be part of next release
Projects
None yet
Development

No branches or pull requests

3 participants