#8 Bug in the constraint XexpYeqZ



There seems to be a bug in the consistency method of the constraint XexpYeqZ.
This happens when the domain of some variables given in argument contains the value 0.
Here's a small piece of code that can be used to reproduce the bad behaviour:

Store store = new Store();
IntVar[] vars = new IntVar[3];
IntVar v1 = new IntVar(store, "v1", 0, 0);
vars[0] = v1;
IntVar v2 = new IntVar(store, "v2", 2, 2);
vars[1] = v2;
IntVar v3 = new IntVar(store, "v3", 0, 0);
vars[2] = v3;

XexpYeqZ ex = new XexpYeqZ(v1, v2, v3);

boolean result = store.consistency();

assert result == true: "incorrect";

When executing this piece of code, the consistency method of the constraint will call the method aLog(double a, double x) with x as 0.0.
This results in a division by 0, and a load of not caught JaCoP.core.FailException will follow when calling domain.in() in consistency().


  • kris

    kris - 2011-04-19
    • status: open --> closed-works-for-me
  • kris

    kris - 2011-04-19


    I do not see the problem. I have executed your program and got the following print-out:

    $ java -ea -cp .:.. Exp
    Exception in thread "main" java.lang.AssertionError: incorrect
    at Exp.example(Exp.java:44)
    at Exp.main(Exp.java:22)

    It means that the solver found out inconsistency (there is no solution for this values) and returned false.

    Best regards,

  • kris

    kris - 2011-04-19
    • status: closed-works-for-me --> closed-accepted
  • kris

    kris - 2011-04-19


    Sorry. I was in harry and did not grasp your problem. Yes, it is wrong. You need to replace lines 127-128 with the following lines.

    if (x.max()==0 || z.min()==0)
    yMin = y.min();
    yMin = Math.max(aLog(x.max(), z.min()), y.min());
    if (x.min()==0 || z.max()==0)
    yMax = y.max();
    yMax = Math.min(aLog(x.min(), z.max()), y.max());

    I will test it a little bit more and will update the svn later.

    Thank you for your report.


  • kris

    kris - 2011-05-04
    • status: closed-accepted --> closed-fixed