I need to define a function that takes a large number of arguments. I am trying to follow JuMP documentation:
All arguments to user-defined functions are scalars, not vectors. To define a function which takes a large number of arguments, you may use the splatting syntax f(x…) = …
So did this, but it does not work:
m = JuMP.Model(solver=Ipopt.IpoptSolver())
f(x...) = x[1] + x[2]
JuMP.register(m, :f, 2, f, autodiff=true)
JuMP.@variable(m, x[i=1:2], start = 0.)
JuMP.@NLobjective(m, :Min, f(x...) + 100(x[2]-x[1]^2)^2)
I also tried different things using setNLobjective and raw expression input, but it also didn’t work.
What am I doing wrong?