Constraining the Sum of Even Indices of an array

In reply to Tulasiram:

Your constraint should be

 constraint c_sum { s == a.sum() with (item.index%2 ? 0 : item);  // Performing sum only on even index
        s == 100;  // constraining sum to 100.
      }

1 Like