# Unsupported feature Hess with user-defined functions using JuMP and Alpine

**URL:** https://discourse.julialang.org/t/unsupported-feature-hess-with-user-defined-functions-using-jump-and-alpine/70204
**Category:** Optimization (Mathematical)
**Tags:** jump
**Created:** [October 22, 2021, 10:09am UTC](https://discourse.julialang.org/t/unsupported-feature-hess-with-user-defined-functions-using-jump-and-alpine/70204 "2021-10-22T10:09:55Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![blob](https://avatars.discourse-cdn.com/v4/letter/b/ebca7d/32.png) [@blob](https://discourse.julialang.org/u/blob)
#### Post date: [October 22, 2021, 10:09am UTC](https://discourse.julialang.org/t/unsupported-feature-hess-with-user-defined-functions-using-jump-and-alpine/70204/1 "2021-10-22T10:09:55Z")

</div>

I am trying to use a global solver Alpine in JuMP with user-registered functions. I am getting the same error as mentioned in this [Github issue](https://github.com/jump-dev/JuMP.jl/issues/1735) and here [discourse post for the same error](https://discourse.julialang.org/t/random-error-unsupported-feature-hess/19306) for Ipopt. The code that reproduces the error is the same as in the links:

```julia
using JuMP, Alpine

model = Model(Alpine.Optimizer)

my_square(x) = x^2
my_square_prime(x) = 2x
my_square_prime_prime(x) = 2

my_f(x, y) = (x - 1)^2 + (y - 2)^2
function ∇f(g, x, y)
    g[1] = 2 * (x - 1)
    g[2] = 2 * (y - 2)
end

JuMP.register(model, :my_f, 2, my_f, ∇f)
JuMP.register(model, :my_square, 1, my_square, my_square_prime,
              my_square_prime_prime)

@variable(model, x[1:2] >= 0.5)
@NLobjective(model, Min, my_f(x[1], my_square(x[2])))
JuMP.optimize!(model);
objetivo = JuMP.objective_value.(model)
print(objetivo)

```

Would this be a JuMP or Alpine issue? The same example works fine with Ipopt.

Edit. I jsut checked MadNLP (other nonlinear solver) and got the same error as with Alpine.

---

<div class="post-metadata">

### Author: ![odow](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/odow/32/28685_2.png) [@odow](https://discourse.julialang.org/u/odow)
#### Post date: [October 23, 2021, 5:02am UTC](https://discourse.julialang.org/t/unsupported-feature-hess-with-user-defined-functions-using-jump-and-alpine/70204/2 "2021-10-23T05:02:17Z")

</div>

This is a bug in Alpine and MadNLP. When initializing their problem, they should check `features_available` to see what callbacks they can access. In this case, `:Hess` is not in `features_available`, so attempting to initialize it will return an unsupported feature.

```nohighlight
using JuMP

model = Model()

my_square(x) = x^2
my_square_prime(x) = 2x
my_square_prime_prime(x) = 2

my_f(x, y) = (x - 1)^2 + (y - 2)^2
function ∇f(g, x, y)
    g[1] = 2 * (x - 1)
    g[2] = 2 * (y - 2)
end

JuMP.register(model, :my_f, 2, my_f, ∇f)
JuMP.register(model, :my_square, 1, my_square, my_square_prime,
              my_square_prime_prime)

@variable(model, x[1:2] >= 0.5)
@NLobjective(model, Min, my_f(x[1], my_square(x[2])))

julia> e = NLPEvaluator(model)
"A JuMP.NLPEvaluator"

julia> MOI.features_available(e)
4-element Vector{Symbol}:
 :Grad
 :Jac
 :JacVec
 :ExprGraph

```

---

<div class="post-metadata">

### Author: ![odow](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/odow/32/28685_2.png) [@odow](https://discourse.julialang.org/u/odow)
#### Post date: [October 23, 2021, 5:04am UTC](https://discourse.julialang.org/t/unsupported-feature-hess-with-user-defined-functions-using-jump-and-alpine/70204/3 "2021-10-23T05:04:59Z")

</div>

I opened an issue for Alpine: [https://github.com/lanl-ansi/Alpine.jl/issues/176](https://github.com/lanl-ansi/Alpine.jl/issues/176)

What was the error from MadNLP? It. looks like they should throw “Hessian information needed”, not the same error as Alpine.  
[https://github.com/MadNLP/MadNLP.jl/blob/86eba3dbd29885c0705c0a62028f5c716fa629f1/src/Interfaces/MOI\_interface.jl#L1112-L1113](https://github.com/MadNLP/MadNLP.jl/blob/86eba3dbd29885c0705c0a62028f5c716fa629f1/src/Interfaces/MOI_interface.jl#L1112-L1113)

---

<div class="post-metadata">

### Author: ![blob](https://avatars.discourse-cdn.com/v4/letter/b/ebca7d/32.png) [@blob](https://discourse.julialang.org/u/blob)
#### Post date: [October 23, 2021, 9:36am UTC](https://discourse.julialang.org/t/unsupported-feature-hess-with-user-defined-functions-using-jump-and-alpine/70204/4 "2021-10-23T09:36:37Z")

</div>

Thank you, that explains it.

And yes, I must have looked at the wrong error message for MadNLP, this is what I am getting:  
 ![image](https://global.discourse-cdn.com/julialang/original/3X/1/2/125f74abc205f1594d46011eb28dc6ca85f4dae5.png)  
I will open an issue with them pointing to your solution for Alpine.

---

<div class="post-metadata">

### Author: ![ccoffrin](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ccoffrin/32/400_2.png) [@ccoffrin](https://discourse.julialang.org/u/ccoffrin)
#### Post date: [October 24, 2021, 5:09pm UTC](https://discourse.julialang.org/t/unsupported-feature-hess-with-user-defined-functions-using-jump-and-alpine/70204/5 "2021-10-24T17:09:38Z")

</div>

@blob, thanks for pointing out the issue. I was wondering if this resolved the underlying issue of finding global optimal solutions of the original mathematical program?

---

<div class="post-metadata">

### Author: ![blob](https://avatars.discourse-cdn.com/v4/letter/b/ebca7d/32.png) [@blob](https://discourse.julialang.org/u/blob)
#### Post date: [October 25, 2021, 8:46am UTC](https://discourse.julialang.org/t/unsupported-feature-hess-with-user-defined-functions-using-jump-and-alpine/70204/6 "2021-10-25T08:46:03Z")

</div>

Hi, @ccoffrin no, not really. I am running into other issues with Alpine, but they mostly boil down to the functions that are supported by Alpine/underlying solvers (I think so at least). I will open another topic with an MWE.
