Skip to content

Commit 9ae1a89

Browse files
authored
Add AutomaticDifferentiationBackend (#2386)
1 parent ea5f1a6 commit 9ae1a89

File tree

4 files changed

+23
-0
lines changed

4 files changed

+23
-0
lines changed

docs/src/manual/models.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ The following attributes are available:
7878
* [`ObjectiveFunction`](@ref)
7979
* [`ObjectiveFunctionType`](@ref)
8080
* [`ObjectiveSense`](@ref)
81+
8182
## AbstractOptimizer API
8283

8384
The following attributes are available:
@@ -104,3 +105,4 @@ The following attributes are available:
104105
* [`TimeLimitSec`](@ref)
105106
* [`ObjectiveLimit`](@ref)
106107
* [`SolutionLimit`](@ref)
108+
* [`AutomaticDifferentiationBackend`](@ref)

docs/src/reference/models.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ NumberOfThreads
8686
RawSolver
8787
AbsoluteGapTolerance
8888
RelativeGapTolerance
89+
AutomaticDifferentiationBackend
8990
```
9091

9192
List of attributes useful for optimizers

src/attributes.jl

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2119,6 +2119,20 @@ struct ListOfSupportedNonlinearOperators <: AbstractOptimizerAttribute end
21192119
OTHER_ERROR,
21202120
)
21212121

2122+
"""
2123+
AutomaticDifferentiationBackend() <: AbstractOptimizerAttribute
2124+
2125+
An [`AbstractOptimizerAttribute`](@ref) for setting the automatic differentiation
2126+
backend used by the solver.
2127+
2128+
The value must be a subtype of [`Nonlinear.AbstractAutomaticDifferentiation`](@ref).
2129+
"""
2130+
struct AutomaticDifferentiationBackend <: AbstractOptimizerAttribute end
2131+
2132+
function attribute_value_type(::AutomaticDifferentiationBackend)
2133+
return Nonlinear.AbstractAutomaticDifferentiation
2134+
end
2135+
21222136
"""
21232137
TerminationStatus()
21242138

test/attributes.jl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,12 @@ function test_scalar_nonlinear_function_set_objective()
310310
return
311311
end
312312

313+
function test_attributes_AutomaticDifferentiationBackend()
314+
@test MOI.attribute_value_type(MOI.AutomaticDifferentiationBackend()) ==
315+
MOI.Nonlinear.AbstractAutomaticDifferentiation
316+
return
317+
end
318+
313319
function runtests()
314320
for name in names(@__MODULE__; all = true)
315321
if startswith("$name", "test_")

0 commit comments

Comments
 (0)