JuMP constraints with conditions in Sum

JuMP sums use standard Julia generator syntax. So you can go:

julia> using JuMP

julia> m=Model()
Feasibility problem with:
 * 0 linear constraints
 * 0 variables
Solver is default solver

julia> @variable(m, x[1:3])
3-element Array{JuMP.Variable,1}:
 x[1]
 x[2]
 x[3]

julia> @constraint(m, sum(x[i] for i in 1:3 if i != 2) == 1)
x[1] + x[3] == 1
2 Likes