Search code examples
javachoco

Choco 4: Constrain domain of variable to equal a set of values


I have the following array S of IntVar[]:

IntVar[] S = model.intVarArray("Flights Schedule", 18, 0, 19);

I also have the following ArrayList of Integer, called fromHome:

ArrayList<Integer> fromHome = [1, 2, 4];

fromHome is derived later in the program.

I want to constrain the domain of S[0] to contain only the values in fromHome and nothing else. How can I do that? Thanks!


Solution

  • I found a way to do this using the member constraint as follows:

    model.member(S[0], from_home).post();