@NLconstraint not working with splatting syntax

I am trying to solve a constrained non linear optimization problem with JuMP/Ipopt and since the cost function and the constraint are functions of vector variables, I am using the splatting syntax as suggested in the JuMP documentation. Here is the minimal reproducible example of the problem:

using JuMP
using Ipopt

function Cost(args...)
    x = [args[i] for i=1:8]
    y = [args[i] for i=9:16]
    u = [sum(x), sum(y)]
    
    return  - cos((u[1]-0.1)*u[2])^2 - u[1]*(sin(3u[1]+u[2]))
end

function Constr(args...)
    x = [args[i] for i=1:8]
    y = [args[i] for i=9:16]
    t = atan2(sum(y), sum(x))
    
    return (2cos(t) - cos(2t) / 2 - cos(3t) / 4 - cos(4t) / 8)^2 + (2sin(t))^2 
end

m = Model(solver=IpoptSolver(print_level=1))

JuMP.register(m, :Cost, 16, Cost, autodiff=true)
JuMP.register(m, :Constr, 16, Constr, autodiff=true)

@variable(m, -2.25 <= x[1:8] <= 2.5, start=1)
@variable(m, -2.5  <= y[1:8] <= 1.75, start=1)

@NLconstraint(m, c1, sum(x[i]^2 for i in 1:8) + sum(y[i]^2 for i in 1:8) <= Constr(x...,y...))
@NLobjective(m, Min, Cost(x...,y...))

solve(m)

and the error is:

MethodError: no method matching parseNLExpr_runtime(::JuMP.Model, ::JuMP.Variable, ::JuMP.Variable, ::JuMP.Variable, ::JuMP.Variable, ::JuMP.Variable, ::JuMP.Variable, ::JuMP.Variable, ::JuMP.Variable, ::Array{ReverseDiffSparse.NodeData,1}, ::Int64, ::Array{Float64,1})
Closest candidates are:
  parseNLExpr_runtime(::JuMP.Model, ::JuMP.Variable, ::Any, ::Any, ::Any) at C:\Users\arbenede\.julia\v0.6\JuMP\src\parsenlp.jl:202
  parseNLExpr_runtime(::JuMP.Model, ::Number, ::Any, ::Any, ::Any) at C:\Users\arbenede\.julia\v0.6\JuMP\src\parsenlp.jl:196
  parseNLExpr_runtime(::JuMP.Model, ::JuMP.NonlinearExpression, ::Any, ::Any, ::Any) at C:\Users\arbenede\.julia\v0.6\JuMP\src\parsenlp.jl:208
  ...

Stacktrace:
 [1] macro expansion at C:\Users\arbenede\.julia\v0.6\JuMP\src\parsenlp.jl:88 [inlined]
 [2] macro expansion at C:\Users\arbenede\.julia\v0.6\JuMP\src\macros.jl:1201 [inlined]
 [3] anonymous at .\<missing>:?

Any ideas about what is going on?

Thank,

-Arrigo

Yes, this nasty error message means that the splatting syntax is not supported. I just fixed the error message (syntax error on splatting in NLexpression by mlubin · Pull Request #1434 · jump-dev/JuMP.jl · GitHub). See previous discussions for workarounds:

Thanks, Miles. I’ll try the suggestions.