I have a MiniZinc program with 3 arrays of variables of the following form:
array[NbLines] of var Domain: vars1;
array[NbLines, NbRows] of var Domain: vars2;
array[NbLines, NbRows] of var Domain: vars3;
I need to specify my search variable order in the following way, but I did not success to correctly construct my array. There is the MiniZinc like code:
varsOrder = [[vars1[i]] ++ row(vars2, i) ++ row(vars3, i) | i in NbLines]
MiniZinc indicates that arrays are not allowed in array comprehension expressions. How should I do?
Thank you for your help.
As you have noticed, you cannot concatenate arrays like this. What I can think of are two approaches, though the first is not exactly what you want.
1) use array1d(array)
You can flatten matrices (2d arrays) with "array1d" like this:
solve :: int_search(vars1 ++ array1d(vars2) ++ array1d(vars3), first_fail, indomain_min, complete) satisfy;
However, this is not exactly the same as what you write above, but it's way easier than the next approach:
2) Make a master array and insert all the elements in the proper positions.
int: totLen = ...; % the total length of all the arrays
array[1..totLen] of var Domain: all;
You have to do a loop to insert all the elements in the exact position you want in the "all" array. However, I leave this as an exercise. :-)
Then the "all" array can be used in the labeling:
solve :: int_search(all, first_fail, indomain_min, complete) satisfy;