# Constraint declaration

**URL:** <https://discourse.julialang.org/t/constraint-declaration/92683>\
**Category:** Optimization (Mathematical)\
**Created:** [January 8, 2023, 5:55pm UTC](https://discourse.julialang.org/t/constraint-declaration/92683 "2023-01-08T17:55:08Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![odow](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/odow/32/28685_2.png) [@odow](https://discourse.julialang.org/u/odow)\
**Post date:** [January 8, 2023, 9:58pm UTC](https://discourse.julialang.org/t/constraint-declaration/92683/4 "2023-01-08T21:58:54Z")

</div>

From your previous post, it looks like `W` is an array, which you indexed like `W[i]`.

So it doesn’t mean anything, mathematically, to sum \sum\limits\_{j \in W}^p x\_j. Perhaps you just meant \sum\limits\_{j \in W\_p} x\_j?

If so, the JuMP equivalent is:

`@constraint(model, c2, sum(x[j] for j in W[p]) <= p)`.

It’s easier to help if you read [Please read: make it easier to help you](https://discourse.julialang.org/t/please-read-make-it-easier-to-help-you/14757) and can provide a reproducible example.

---

_[View the full topic](https://discourse.julialang.org/t/constraint-declaration/92683)._
