# How to build a constraint with summation?

**URL:** https://discourse.julialang.org/t/how-to-build-a-constraint-with-summation/41618
**Category:** Optimization (Mathematical)
**Tags:** question, jump
**Created:** [June 17, 2020, 6:20pm UTC](https://discourse.julialang.org/t/how-to-build-a-constraint-with-summation/41618 "2020-06-17T18:20:39Z")
**Posts on this page:** 1
**Showing post:** 11

<div class="post-metadata">

### Author: ![Henrique\_Becker](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/henrique_becker/32/15443_2.png) [@Henrique\_Becker](https://discourse.julialang.org/u/Henrique_Becker)
#### Post date: [June 18, 2020, 7:58pm UTC](https://discourse.julialang.org/t/how-to-build-a-constraint-with-summation/41618/11 "2020-06-18T19:58:49Z")

</div>

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?

---

_[View the full topic](https://discourse.julialang.org/t/how-to-build-a-constraint-with-summation/41618)._
