using "max" in nonlinear constraints

@zhangxz1123, you’re looking for the splatting syntax (note: I’m not sure if this works on JuMP v0.18, which it looks like you’re using. It does on the latest JuMP v0.19.):

using JuMP, Ipopt
m = Model(with_optimizer(Ipopt.Optimizer))
N = 4
@variable(m, x[i=1:N] >= i)
f(y...) = max(y...)
JuMP.register(m, :f, N, f, autodiff=true)
@NLobjective(m, Min, f(x...))
optimize!(m)
5 Likes