[I'm using Choco 3.3.3]
I have an IntVar a and an int b. I want to save the difference into an IntVar[] array d. I've done this at another point in the code in exactly the same way and it worked without a problem, but here I just don't get it to work.
d = VF.boundedArray("d", num_ts, -20, 20, solver);
for(int t=0; t < num_ts; t++){
IntVar a = VF.bounded("a", 0, 10, solver);
solver.post(ICF.sum(aa[t], a)); //values are [2,2,2,1,2,2]
int b = bb[t][j]; //values are [2,3,2,2,2,2]
IntVar c = VF.offset(a, -b);
...//see below
}
When I just use c (d[t] = c;), the result when printing out the values of d is [0, -1, 0, -1, 0, 0], but I need the absolut of that, so [0,1,0,1,0,0]
These are the different things that I've tried and the results of d:
d[t] = VF.abs(c); //result [0,0,0,0,0,0]
solver.post(ICF.times(c, -1, d[t])); //result [-7,-6,-7,-7,-7,-7]
solver.post(ICF.sum(new IntVar[]{VF.minus(a), VF.fixed(b, solver)}, d[t])); //result [-7,-6,-7,-7,-7,-7]
solver.post(ICF.arithm(a, "+", d[t], "=", b)); //result [-7,-6,-7,-7,-7,-7]
solver.post(ICF.distance(VF.fixed(b, solver), a, "=", d[t])); //result [-20, -20, -20, -20, -20, -20]
Can anyone tell me what I'm doing wrong? I am especially perplexed as to where [-7,-6,-7,-7,-7,-7] are coming from...