You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The following code snippet showcases an example where jacop's element constraint yields an incorrect result. This issue might be related to #27, but I don't believe so. This is why I created this second issue for you to track.
Storecp = newStore();
IntVarindex = newIntVar(cp, -3, 3);
IntVar[] vars = newIntVar[]{newIntVar(cp, 0, 0)};
IntVarvalue = newIntVar(cp, -4, 2);
cp.setLevel(cp.level + 1);
cp.impose(Element.choose(index, vars, value));
if ( !cp.consistency() ) {
System.err.println("Ahem, this is wrong !");
}
// This is what gets printed:// index = _1 = 1// vars = [_2 = 0]// value = _3 = 0System.out.println("index = "+ index);
System.out.println("vars = "+ Arrays.toString(vars));
System.out.println("value = "+ value);
// 1st assertion fails because index = {1}. Still vars[1] is not feasible : it is out of boundsassertindex.value() == 0;
assertvars[0].value() == 0;
assertvalue.value() == 0;
The text was updated successfully, but these errors were encountered:
Thank you for making an effort to report a problem.
For element the first element in the list has index 1 not 0. ;). Therefore, it is correct.
If you prefer to have things indexed from zero then you need to add extra parameter to Element.
cp.impose(Element.choose(index, vars, value, -1));
This -1 changes starting index from 1 to 0. If I do then your test does not fail.
Again, thank you for making an effort to report a problem. JaCoP participates in solver competition and solves thousands of different problems so usually we have no simple issues like that. Therefore, if you find those type of simple problems most of the time is use of API in the wrong place or misunderstanding of the constraint contract.
I hope you will pass those initial difficulty in using CP/JaCoP and enjoying using our library. I recommend looking at many different examples we provide. It helps a lot at the beginning.
Using JaCop 4.6.0 on Java.
The following code snippet showcases an example where jacop's element constraint yields an incorrect result. This issue might be related to #27, but I don't believe so. This is why I created this second issue for you to track.
The text was updated successfully, but these errors were encountered: