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

"cannot determine bounds" when using abs function outside solve statement #106

Closed
Zero3 opened this Issue Jul 9, 2016 · 1 comment

Comments

Projects
None yet
2 participants
@Zero3

Zero3 commented Jul 9, 2016

I have a model with a set of of float decision variables (itemValues) that runs fine with the following solve statement:

solve minimize sum (i in Items) (abs(itemPrices[i] - itemValues[i]));

However, it breaks if I move the sum into its own variable, which should have no effect as far as I am concerned:

var float: diffs = sum (i in Items) (abs(itemPrices[i] - itemValues[i]));
solve minimize diffs;

If I remove the abs function, both work fine. So it appears to be a bug/limitation related to this function.

The error thrown is:

MiniZinc: evaluation error: 
<.mzn file path>:23:
  in variable declaration for 'diffs'
  in call 'sum'
  in array comprehension expression
    with i = 1
  in call 'abs'
C:\Program Files (x86)\MiniZinc IDE (bundled)/share/minizinc/std/builtins.mzn:321:
  in if-then-else expression
C:\Program Files (x86)\MiniZinc IDE (bundled)/share/minizinc/std/builtins.mzn:322:
  in let expression
  in call 'max'
  in call 'ub'
  cannot determine bounds
@a1880

This comment has been minimized.

a1880 commented Jul 9, 2016

Looking at the implementation of abs() in builtins.mzn, it appears that abs() requires the argument to be bounded, i.e. there has to be an upper and a lower bound for the argument imposed by some constraints.

@guidotack guidotack closed this in 2751fcf Nov 16, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment