Constraint number of occurrences in dynamic array

In reply to Blitzz0418:

That is a lot more information than your original post. Also, you are contradicting what you said first about not repeatingmore than 4 times, and then later you said repeated at least 4 times. I’m going to assume you meant at least 4 times which means there needs to be a constraint in the minimum size of the array to be 16. You probably should set an upper bound to the array size as well.

class A;
  int N = 4;
  int values[] = {2, 3, 4, 5};
  rand int arr[];
  constraint c {
     arr.size inside {[N*values.size() : 100]};
     foreach(arr[i]) arr[i] inside {values};
     foreach(values[i]) arr.sum() with (int'(item == values[i])) >= N;
  }
endclass