From 7035565322373ef4a7721bd0f740324d020b8fe7 Mon Sep 17 00:00:00 2001 From: odow Date: Thu, 4 Jan 2024 13:12:02 +1300 Subject: [PATCH 1/3] Add AutomaticDifferentiationBackend --- docs/src/manual/models.md | 2 ++ src/attributes.jl | 14 ++++++++++++++ 2 files changed, 16 insertions(+) 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/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() From 67ceae882dff67b3ea3fb50cfdd6559e194938ce Mon Sep 17 00:00:00 2001 From: Oscar Dowson Date: Thu, 4 Jan 2024 13:25:00 +1300 Subject: [PATCH 2/3] Update models.md --- docs/src/reference/models.md | 1 + 1 file changed, 1 insertion(+) 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 From bc255c35b1d0e10ef02c8a86eda7ffdd17743483 Mon Sep 17 00:00:00 2001 From: odow Date: Thu, 4 Jan 2024 14:34:14 +1300 Subject: [PATCH 3/3] add test --- test/attributes.jl | 6 ++++++ 1 file changed, 6 insertions(+) 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_")