Enzyme.jl icon indicating copy to clipboard operation
Enzyme.jl copied to clipboard

Add JuMP extension

Open michel2323 opened this issue 1 year ago • 1 comments

This extends JuMP and allows a user in JuMP to differentiate an external function using Enzyme. I still should reduce the allocations. Feedback is very welcome.

Use case:

using Ipopt
using JuMP
using Enzyme

# Rosenbrock
rosenbrock(x...) = (1 - x[1])^2 + 100 * (x[2] - x[1]^2)^2

model = Model(Ipopt.Optimizer)
op_rosenbrock =  model[:op_rosenbrock] = add_nonlinear_operator(model, 2, rosenbrock; name=:op_rosenbrock) 
@variable(model, x[1:2])

@objective(model, Min, op_rosenbrock(x[1],x[2]))

optimize!(model)

michel2323 avatar Mar 08 '24 18:03 michel2323

Since we're using the memory, I added the batched mode to get the Hessian in one go.

michel2323 avatar Mar 08 '24 19:03 michel2323

This should be closed. We're discussing it over in https://github.com/jump-dev/JuMP.jl/pull/3712.

odow avatar Mar 14 '24 22:03 odow