Search code examples
arrayssetminizinc

Declaring an array of vars with an array of sets


I'm pretty new to minizinc, and this might be a simple question, but I can't find the answer anywhere so I'm resorting to asking here.

I have this array:

set of int: N=1..n;
array[N] of set of int: x_d = [ { j | j in i+1..min(2*i,n-1) } | i in N];

n is subject to change, it's inputted externally, so I don't have access to that value in writing this code. What I want is this array of variables:

array[N] of var int: x;

to be restricted to the sets above. Meaning, x[i] should be restricted to its corresponding set x_d[i], where i belongs to [1, 2, ..., n].


Solution

  • Would constraint forall(i in N)(x[i] in x_d[i]); suit your needs?