Skip to content

Commit

Permalink
Fix map_indices for AbstractAutomaticDifferentiation (#2394)
Browse files Browse the repository at this point in the history
  • Loading branch information
odow authored Jan 7, 2024
1 parent 79455ba commit 3a7f891
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/Nonlinear/types.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
16 changes: 16 additions & 0 deletions test/Nonlinear/Nonlinear.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit 3a7f891

Please sign in to comment.