For syntax in @constraints

Hi!

I am looking for the most elegant way of adding multiple constraints (e.g. with a for loop) in a JuMP model.

For example I would like to be able to write :

using JuMP

m = Model()
@variable(m,x[1:5])
@constraints(m, begin
    x[i+1] <= x[i] , for i in 1:4  
   x[i]+x[2i] == 1, for i in 1:2
    end)

Currently I’m makin a for loop and using @constraint(m,…) inside the loop. Is there another way ?

See Constraints · JuMP

You need

@constraints(model, begin
    [i=1:4], x <= i
end)