Constrain the number of occurrences in an array

In reply to Bahaa Osman:

Hi Bahaa,

I think you want to use the sum() method

constraint add_less_than_5 {(c_inst.sum() with (item.e == ADD)) <= 5)}

This assumes you have either constructed the dynamic array before calling randomize, or constrained the size of c_inst in another constraint.

P.S. And please use a typedef for your enum :)