I am trying to optimize a multivariate function with JuMP, but can’t find a way to pass the arguments.
The current code is:
using JuMP
n=100
m=Model()
@variable(m, 0 <= x[1:n] <= 1)
f(x) = rand() # doenst matter here
df(x) = rand(n) # "
JuMP.register(m, :obj, n, (x...)->f(x), (g,x...)->(g[:] = df(x)))
# and now the line in question:
@NLobjective(m, Max, obj(x))
solve(m)
No matter how I try denoting the NLobjective, I get the error
ERROR: Incorrect number of arguments for "obj" in nonlinear expression.
in error(::String) at ./error.jl:21
I also tried obj(x…) but this lead to the same result.
How would I specify this the correct way?