question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[BUG] Bounds are not checked on variable definition

See original GitHub issue

Describe the bug The lower and upper bounds are not checked on variable definition.

To Reproduce Define a variable with invalid bounds.

m.intVar( 2 * IntVar.MIN_INT_BOUND, 2 * IntVar.MAX_INT_BOUND); 

Expected behavior

I am unsure, but the behavior should depend on the nature of the variable : decision or auxiliary.

  • One can ask the user to bound decision variables.
  • However, auxiliary variables can be assigned large values even in a small search space. It is the case for a product or power constraints, or more generally arithmetic expressions.

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.

Issue Analytics

  • State:open
  • Created 10 months ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
jgFagescommented, Nov 30, 2022

this looks good to me, but if it is a log and not an exception, maybe we can even use if max > IntVar.MaxIntBound.

0reactions
cprudhomcommented, Nov 30, 2022

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");
        }
    }
Read more comments on GitHub >

github_iconTop Results From Across the Web

Bounds checking - Wikipedia
In computer programming, bounds checking is any method of detecting whether a variable is within some bounds before it is used. It is...
Read more >
Variable bounds are not checked when the variables are not ...
@jsiirola - I'm going through old bug reports. Is this bug still present in the most recent Pyomo version?
Read more >
No out of bounds error - Stack Overflow
When you access an array index, C and C++ don't do bound checking. ... is on the stack, next to other variables, so...
Read more >
Bounds Checking - LRDE
Unchecked objects​​ Variables declared in files that are not compiled with -fbounds-checking are not normally known about by the checking library. Pointers that ......
Read more >
Instrumentation Options - GCC, the GNU Compiler Collection
This option instructs the compiler to check that the size of a variable length array is positive. -fsanitize=null. This option enables pointer checking....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found