diff --git a/docs/src/manual/models.md b/docs/src/manual/models.md index 7863b45ff8..d17e0f27f5 100644 --- a/docs/src/manual/models.md +++ b/docs/src/manual/models.md @@ -78,6 +78,7 @@ The following attributes are available: * [`ObjectiveFunction`](@ref) * [`ObjectiveFunctionType`](@ref) * [`ObjectiveSense`](@ref) + ## AbstractOptimizer API The following attributes are available: @@ -104,3 +105,4 @@ The following attributes are available: * [`TimeLimitSec`](@ref) * [`ObjectiveLimit`](@ref) * [`SolutionLimit`](@ref) + * [`AutomaticDifferentiationBackend`](@ref) diff --git a/docs/src/reference/models.md b/docs/src/reference/models.md index 253c1d6063..349130fbb2 100644 --- a/docs/src/reference/models.md +++ b/docs/src/reference/models.md @@ -86,6 +86,7 @@ NumberOfThreads RawSolver AbsoluteGapTolerance RelativeGapTolerance +AutomaticDifferentiationBackend ``` List of attributes useful for optimizers diff --git a/src/attributes.jl b/src/attributes.jl index c30f67329b..c2ae466e07 100644 --- a/src/attributes.jl +++ b/src/attributes.jl @@ -2119,6 +2119,20 @@ struct ListOfSupportedNonlinearOperators <: AbstractOptimizerAttribute end OTHER_ERROR, ) +""" + AutomaticDifferentiationBackend() <: AbstractOptimizerAttribute + +An [`AbstractOptimizerAttribute`](@ref) for setting the automatic differentiation +backend used by the solver. + +The value must be a subtype of [`Nonlinear.AbstractAutomaticDifferentiation`](@ref). +""" +struct AutomaticDifferentiationBackend <: AbstractOptimizerAttribute end + +function attribute_value_type(::AutomaticDifferentiationBackend) + return Nonlinear.AbstractAutomaticDifferentiation +end + """ TerminationStatus() diff --git a/test/attributes.jl b/test/attributes.jl index ba4af69682..929ad53a88 100644 --- a/test/attributes.jl +++ b/test/attributes.jl @@ -310,6 +310,12 @@ function test_scalar_nonlinear_function_set_objective() return end +function test_attributes_AutomaticDifferentiationBackend() + @test MOI.attribute_value_type(MOI.AutomaticDifferentiationBackend()) == + MOI.Nonlinear.AbstractAutomaticDifferentiation + return +end + function runtests() for name in names(@__MODULE__; all = true) if startswith("$name", "test_")