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

118 views Asked by At

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!

1

There are 1 answers

0
Iva On BEST ANSWER

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

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