Force a gradient value at a degenerate point


#1

I wish to implement Wolfe’s example

x0 = [0; 0.25; 0.0]
lb = [0.0; 0.0; 0.0]
ub = [Inf; Inf; 2.0]
@variable(nlp,  lb[i] <= x[i = 1:3] <= ub[i],  start = x0[i])

@NLobjective(
    nlp,
    Min,
    4/3*(x[1]^2 - x[1] * x[2] + x[2]^2)^(3/4) - x[3]
)

The gradient is not defined at x[1]=x[2]=0.0 but one may fill the hole by forcing it to be [0,0,-1], which is the right value when evaluating the limit.
How may I force JuMP to return [0,0,1] instead of [NaN,NaN,1]

Thx,
vepiteski


#2

You cannot, without modifying JuMP’s code for computing derivatives. You could implement your own callbacks for derivatives at the MathProgBase level instead.