Search code examples
arraysminizinc

Minzinc: Applying a constraint on each row of a 2D-array


I am trying to apply a regular constraint on each row of a 2D array of int var:

enum ROW;
enum COL;
enum VAR_ENUM;
array[ROW, COL] of var VAR_ENUM: sequence;
include "regular.mzn"
constraint forall(r in ROW)(regular(sequence[r], ... other regular parameters))

I end up with the error MiniZinc: type error: 2-dimensional array accessed with 1 expression.

Is there a way to slice a 2D array? If not, how else could I apply a regular constraint on a large number of array variables?


Solution

  • Row r of 2D-array sequence can be accessed by row(sequence, r).