Constraint that verify binary variable get the same value for at least 4 consecutive points. not sure what approach should i take

set T := 1…card(I); #I is timestamp, so i converted to number
param idx_to_time {T} symbolic := ord(I, I);
subject to 4_consecutive_points {t in T: t >=1,<= card(I) - 4}:
y_ind[t] != y_ind[t-1] ==>
y_ind[t] + y_ind[t+1] + y_ind[t+2] + y_ind[t+3]>=4;

Yes this should be efficient

1 Like