0

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();
ingambe
  • 26
  • 3

1 Answers1

1

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();
ingambe
  • 26
  • 3