How to build a constraint with summation?

The code is a little confusing:

  • a is both a constant defined before and the elements you iterate with the comprehension for a in A.
  • There is a .<= but both sides are scalars in that context, no?
  • The constraint should be left-hand-expression <= right-hand-expression but the <= is inside a comprehension what makes no sense.

Seem to me that what is wanted is something like:

@constraint(Model1, sum(Q[a,w]*x[a,t] for a in A) - sum(s[a,t] for a in A) <= (RHE[w] + OHE[w]) * NE[w] - WH[w,t])
2 Likes