I want to use the value of an IntVar as an index of another IntVar array in a constraint, using Choco Solver.
I have an IntVar who contains the next task who follow the i-th task And I have another IntVar who contains the person assigned to a task. My constraint is to ensure the continuity in the task allocation.
This is what I've already tried, but it failled:
model.distance(person[i], person[next[i].getValue()], "=", 0).post();
The solution is to use IntConstraintFactory.element​(IntVar value, int[] table, IntVar index, int offset).
In my case:
model.element(person[i], person, next[i], 0).post();