I haven’t tested this, but do instead something like
if demand
P = Generate_PowerMatrix(L)
R = Generate_DemandPeakRef(L.Δt, 4, 1)
for i in 1:size(P, 1)
if any(!iszero, P[i, :])
@constraint(model, 0 <= P[i, :]' * x <= R[i])
end
end
end