Description
We discussed with @ccoffrin, @harshangrjn and @kaarthiksundar about what the next-generation NLP could look like.
Here is a gist of the idea:
We create two new function types. First NonlinearExpressionFunction
which will be used by JuMP to give the objective function and the constraints (as NonlinearExpressionFunction
-in-EqualTo
/GreaterThan
/LessThan
) to the MOI backend.
struct NonlinearExpressionFunction <: AbstractScalarFunction
expression
end
Then SecondOrderBlackBoxFunction
will be what NLP solvers such as Ipopt supports:
struct SecondOrderBlackBoxFunction <: AbstractScalarFunction
evaluation_oracle::Function
gradient_oracle::Function # May need to replace it by `append_to_jacobian_sparsity!` and `fill_constraint_jacobian!`
hessian_oracle::Function
end
But NLP solvers such as Alpine can directly support NonlinearExpressionFunction
as it exploits the expression structure.
We can then define the bridges AffinetoSecondOrderBlackBox
and QuadratictoSecondOrderBlackBoxBridge
which transforms respectively ScalarAffineFunction
and ScalarQuadraticFunction
into SecondOrderBlackBoxFunctionBridge
(as is currently done in the Ipopt MOI wrapper for instance).
The transformation from NonlinearExpressionFunction
to SecondOrderBlackBoxFunction
can be achieved by a AutomaticDifferentiationBridge{ADBackend}
which computes the callbacks using ADBackend
.
We can move the current AD implementation form JuMP to MOI.Utilities
into an DefaultADBackend
and full_bridge_optimizer
adds AutomaticDifferentiationBridge{DefaultADBackend}
.
If the user wants to change the AD backend to OtherADBackend
, there will be a JuMP function that internally removes AutomaticDifferentiationBridge{DefaultADBackend}
and adds AutomaticDifferentiationBridge{OtherADBackend}
.
@kaarthiksundar would be interested to work on this and we thought a good first step is to define SecondOrderBlackBoxFunction
and create the bridges AffinetoSecondOrderBlackBox
and QuadratictoSecondOrderBlackBoxBridge
.
Let us know what you think !