Array constraint. Each row total should be 100, with each element less than 80. I want to understand how to do this using only sum method of array

In reply to vickydhudashia:

  constraint array_c   {     
    foreach  (array1[i]) 
      array1[i].sum(item) with ((item < 80) ? item : 101) == 100; 
  }

You first try was very close. Your cast int’(item) < 80 is unnecessary because the width of the conditional expression does not propagate to the result of the conditional operator ?:— it’s just true or false. The result width is the maximum width of the second(true) or third(false) operand. Since the false operand is plain decimal number, its width is at least 32 bits, so the result will be at least 32 bits

That third operand needs to be a value greater than 100 so that item < 80 must always be true.