-
Notifications
You must be signed in to change notification settings - Fork 143
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
[BUG] Bounds are not checked on variable definition #978
Comments
I believe a first step is to make the bound checker correct. default void checkIntDomainRange(String NAME, int MIN, int MAX) {
if (MIN <= Integer.MIN_VALUE || MAX >= Integer.MAX_VALUE) {
throw new SolverException(NAME + ": consider reducing the bounds to avoid unexpected results");
}
if (MAX < MIN) {
throw new SolverException(NAME + ": wrong domain definition, lower bound > upper bound");
}
} but, the first condition is only detected when the lower (resp. upper) bound is equal to Now, talking about auxiliary or decision variables is another topic, I believe. |
Yes. Could there be a setting to disable the checks because the constants are low ? |
I am not sure to follow but in my understanding, IntVar.MAX_INT_BOUND was only a help to have a good behavior by default, but should not be a hard restriction. I have many problems involving variables bigger than this value. I am fine with the current implementation of checkIntDomainRange relying on Integer.MAX_VALUE and I would not like it to be changed to IntVar.MAX_INT_BOUND. Integer.MAX_VALUE is already quite limitating, we should not decrease it even more. |
I agree that hard restriction might be too much, but at least it informs users on possible under/overflow issues.
The current checker is rather useless: it only forbids
It is limited when considering the arithmetic constraints, mainly (only?). |
Another proposal: default void checkIntDomainRange(String NAME, int MIN, int MAX) {
if (MIN == Integer.MIN_VALUE || MAX == Integer.MAX_VALUE) {
if (ref().getSettings().warnUser()) {
ref().getSolver().log().red().printf("%s : consider reducing the bounds to avoid unexpected results", NAME);
}
}
if (MAX < MIN) {
throw new SolverException(NAME + ": wrong domain definition, lower bound > upper bound");
}
} |
this looks good to me, but if it is a log and not an exception, maybe we can even use if max > IntVar.MaxIntBound. |
Describe the bug
The lower and upper bounds are not checked on variable definition.
To Reproduce
Define a variable with invalid bounds.
Expected behavior
I am unsure, but the behavior should depend on the nature of the variable : decision or auxiliary.
For now, the practical issue is that the behavior is hard to predict.
Some later checks can raise an exception, or not, when building a model with arithmetic expressions.
The text was updated successfully, but these errors were encountered: