# Naming multiple constraints

**URL:** <https://discourse.julialang.org/t/naming-multiple-constraints/26134>\
**Category:** Optimization (Mathematical)\
**Tags:** question, jump\
**Created:** [July 8, 2019, 11:24am UTC](https://discourse.julialang.org/t/naming-multiple-constraints/26134 "2019-07-08T11:24:55Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![MuadhF](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/muadhf/32/20389_2.png) [@MuadhF](https://discourse.julialang.org/u/MuadhF)\
**Post date:** [July 8, 2019, 11:24am UTC](https://discourse.julialang.org/t/naming-multiple-constraints/26134/1 "2019-07-08T11:24:55Z")

</div>

Hi,  
In JuMP, how do I get the name of a constraint by which I can refer to, if I haven’t named it already?  
Also, for multiple constraints, how do you name them? For example:

```julia
for i = 1:5
     @constraint(m, con[i=1:5], x[i] + y[i] <= 15)
end

```

So in this case there are 5 constraints and I want to name each one but it gives me an error saying that an object of this name is already attached to the model. I’ve tried several names and variables but it doesn’t work.  
Please help

---

<div class="post-metadata">

**Author:** ![leethargo](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/leethargo/32/6004_2.png) [@leethargo](https://discourse.julialang.org/u/leethargo)\
**Post date:** [July 8, 2019, 1:15pm UTC](https://discourse.julialang.org/t/naming-multiple-constraints/26134/2 "2019-07-08T13:15:14Z")

</div>

I think you can simply drop the `for` loop. If you put `con[i=1:5]` into the `@constraint` macro invocation, then it will automatically create 5 constraints.

---

<div class="post-metadata">

**Author:** ![MuadhF](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/muadhf/32/20389_2.png) [@MuadhF](https://discourse.julialang.org/u/MuadhF)\
**Post date:** [July 8, 2019, 3:41pm UTC](https://discourse.julialang.org/t/naming-multiple-constraints/26134/3 "2019-07-08T15:41:07Z")

</div>

Yes that worked thanks!
