# Dynamic generation of constraints

**URL:** <https://discourse.julialang.org/t/dynamic-generation-of-constraints/4107>\
**Category:** Optimization (Mathematical)\
**Created:** [June 6, 2017, 2:04pm UTC](https://discourse.julialang.org/t/dynamic-generation-of-constraints/4107 "2017-06-06T14:04:39Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![miles.lubin](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/miles.lubin/32/279_2.png) [@miles.lubin](https://discourse.julialang.org/u/miles.lubin)\
**Post date:** [June 6, 2017, 2:13pm UTC](https://discourse.julialang.org/t/dynamic-generation-of-constraints/4107/2 "2017-06-06T14:13:09Z")

</div>

Nope. JuMP doesn’t have a concept of base sets like in AMPL. The syntax `@constraint(model, mycons[i in 1:2], x[i] >= 1)` is just a convenient way of writing the `for` loop:

```julia
@constraintref mycons[1:2]
for i in 1:2 mycons[i] = @constraint(model, x[i] >= 1)

```

---

_[View the full topic](https://discourse.julialang.org/t/dynamic-generation-of-constraints/4107)._
