diff --git a/src/Nonlinear/types.jl b/src/Nonlinear/types.jl index ca91a9caeb..2afc67a931 100644 --- a/src/Nonlinear/types.jl +++ b/src/Nonlinear/types.jl @@ -184,6 +184,13 @@ An abstract type for extending [`Evaluator`](@ref). """ abstract type AbstractAutomaticDifferentiation end +function MOI.Utilities.map_indices( + ::F, + backend::AbstractAutomaticDifferentiation, +) where {F<:Function} + return backend +end + """ Evaluator( model::Model, diff --git a/test/Nonlinear/Nonlinear.jl b/test/Nonlinear/Nonlinear.jl index 9fcd1793aa..16b320538c 100644 --- a/test/Nonlinear/Nonlinear.jl +++ b/test/Nonlinear/Nonlinear.jl @@ -1147,6 +1147,22 @@ function test_unsupported_features_expr_graph_only() return end +function test_automatic_differentiation_backend() + inner = MOI.Utilities.UniversalFallback(MOI.Utilities.Model{Float64}()) + model = MOI.Utilities.CachingOptimizer( + MOI.Utilities.UniversalFallback(MOI.Utilities.Model{Float64}()), + MOI.Utilities.MockOptimizer(inner), + ) + MOI.set( + model, + MOI.AutomaticDifferentiationBackend(), + MOI.Nonlinear.ExprGraphOnly(), + ) + @test MOI.get(inner, MOI.AutomaticDifferentiationBackend()) == + MOI.Nonlinear.ExprGraphOnly() + return +end + end # TestNonlinear TestNonlinear.runtests()