How to build a constraint with summation?

Two things.

First, prefer the term constraint to restriction, I do believe you are instinctively translating “restrição” from Portuguese in your mind.

Second,

The only thing I saw that is different from the code I put here, is w , which is actually w = 5 , but I believe that this will not change anything in relation to the error

If @chisquared guess is correct, and the error is [1, 5] not [1.5], then w = 5 is exactly what is causing the error. The whole problem you are having is that the constants you are using (Q, WH, …) are incomplete, where their values come from? Seems clear to me that lists of 8 values cannot be indexed with [79, 5] or [5, 18], there are not such positions in a simple 1D list of 8 values. Where come the constraint that you are trying to replicate? It does not describe all of Q and WH values?