The signature to register a function in JuMP is as follows
JuMP.register(m::Model, s::Symbol, dimension::Integer, f::Function, ∇f::Function, ∇²f::Function)
I have an array of unnamed functions, like:
funs = [x -> x^2, x -> x + 1]
that I need to use in the definition of a non-linear programming problem. A priori I do not know what functions I will receive in the array, therefore I need my code to be generic.
I tried to register them like this:
for (i,f) in enumerate(funs) JuMP.register(m, Symbol("f$i"), 1, f, autodiff=true) end
But then I can’t use them, in macros like @NLobjective:
JuMP.@NLobjective(m, Min, eval(Symbol("f1")) + 100(y-x^2)^2)
gives an error. Is there any other way to do this?