JuMP register polynomial with its gradient

Dear all,

I am using jump and I want to register a polynomial function with its gradient, with

register(model2, :poly, num_var, poly, gradient)

I build the polynomial with AbstractAlgebra.jl and the gradient with the function

function gradient(x...)
    point = Float64[]
    for i in 1:length(x)
    gradient = Float64[]
    for i in 1:length(x)
        deriv = evaluate(derivative(f,i),point)
    return gradient

If I call the gradient on a point with


there is no error. However, when I solve my problem with Ipopt as follows

num_var = 100
model = Model(Ipopt.Optimizer)
register(model, :poly, num_var, poly, gradient)
@variable(model, 0.0 <= z[1:num_var] <= 1.0)
@NLobjective(model, Min, poly(z...))

JuMP return me the following error message referring to the evaluation step in the gradient of the function.

ERROR: LoadError: Incorrect number of values in evaluation

I would ask you if you have any insight or suggestion to solve this error. Thanks very much

Your gradient function need to accept the gradient as the first argument and modify it in place.