|
12 | 12 | # function that uses `.optimizer`. For example: |
13 | 13 | # `MOI.supports(model.optimizer, F, S)::Bool`. |
14 | 14 |
|
15 | | -@enum CachingOptimizerState NO_OPTIMIZER EMPTY_OPTIMIZER ATTACHED_OPTIMIZER |
16 | | -@enum CachingOptimizerMode MANUAL AUTOMATIC |
| 15 | +MOI.@_documented_enum( |
| 16 | + """ |
| 17 | + A [`Utilities.CachingOptimizer`](@ref) may be in one of three possible |
| 18 | + states. |
| 19 | + """, |
| 20 | + CachingOptimizerState, |
| 21 | + "The CachingOptimizer does not have any optimizer.", |
| 22 | + NO_OPTIMIZER, |
| 23 | + """ |
| 24 | + The CachingOptimizer has an optimizer. The optimizer is empty and it is not |
| 25 | + synchronized with the cached model. |
| 26 | + """, |
| 27 | + EMPTY_OPTIMIZER, |
| 28 | + """ |
| 29 | + The CachingOptimizer has an optimizer, and it is synchronized with the |
| 30 | + cached model. |
| 31 | + """, |
| 32 | + ATTACHED_OPTIMIZER, |
| 33 | +) |
| 34 | +MOI.@_documented_enum( |
| 35 | + """ |
| 36 | + A [`Utilities.CachingOptimizer`](@ref) has two modes of operation. |
| 37 | + """, |
| 38 | + CachingOptimizerMode, |
| 39 | + """ |
| 40 | + The only methods that change the state of the `CachingOptimizer` |
| 41 | + are [`Utilities.reset_optimizer`](@ref), [`Utilities.drop_optimizer`](@ref), |
| 42 | + and [`Utilities.attach_optimizer`](@ref). |
| 43 | +
|
| 44 | + Attempting to perform an operation in the incorrect state results in an |
| 45 | + error. |
| 46 | + """, |
| 47 | + MANUAL, |
| 48 | + """ |
| 49 | + The [`Utilities.CachingOptimizer`](@ref) changes its state when necessary. |
| 50 | + For example, [`optimize!`](@ref) will automatically call |
| 51 | + [`Utilities.attach_optimizer`](@ref) (an optimizer must have been previously |
| 52 | + set). Attempting to add a constraint or perform a modification not supported |
| 53 | + by the optimizer results in a drop to the [`EMPTY_OPTIMIZER`](@ref) state. |
| 54 | + """, |
| 55 | + AUTOMATIC, |
| 56 | +) |
17 | 57 |
|
18 | 58 | """ |
19 | 59 | CachingOptimizer |
|
22 | 62 | links it with an optimizer. It supports incremental model construction and |
23 | 63 | modification even when the optimizer doesn't. |
24 | 64 |
|
25 | | -## Constructors |
| 65 | +## Mode |
| 66 | +
|
| 67 | +A [`Utilities.CachingOptimizer`](@ref) has two modes of operation: |
| 68 | +[`Utilities.AUTOMATIC`](@ref) and [`Utilities.MANUAL`](@ref). See their |
| 69 | +docstrings for details. |
| 70 | +
|
| 71 | +Use [`Utilities.mode`](@ref) to query the mode of a |
| 72 | +[`Utilities.CachingOptimizer`](@ref). |
| 73 | +
|
| 74 | +## State |
| 75 | +
|
| 76 | +A [`Utilities.CachingOptimizer`](@ref) may be in one of three possible states: |
| 77 | +[`NO_OPTIMIZER`](@ref), [`Utilities.EMPTY_OPTIMIZER`](@ref), and |
| 78 | +[`Utilities.ATTACHED_OPTIMIZER`](@ref). See their docstrings for details. |
| 79 | +
|
| 80 | +Use [`Utilities.state`](@ref) to query the state of a |
| 81 | +[`Utilities.CachingOptimizer`](@ref). |
| 82 | +
|
| 83 | +## Constructor with optimizer |
26 | 84 |
|
27 | 85 | ```julia |
28 | 86 | CachingOptimizer(cache::MOI.ModelLike, optimizer::AbstractOptimizer) |
29 | 87 | ``` |
30 | 88 |
|
31 | | -Creates a `CachingOptimizer` in `AUTOMATIC` mode, with the optimizer |
| 89 | +Creates a `CachingOptimizer` in [`AUTOMATIC`](@ref) mode, with the optimizer |
32 | 90 | `optimizer`. |
33 | 91 |
|
34 | 92 | The type of the optimizer returned is |
35 | | -`CachingOptimizer{typeof(optimizer), typeof(cache)}` so it does not support the |
36 | | -function `reset_optimizer(::CachingOptimizer, new_optimizer)` if the type of |
37 | | -`new_optimizer` is different from the type of `optimizer`. |
| 93 | +`CachingOptimizer{typeof(optimizer),typeof(cache)}` so it does not support the |
| 94 | +function [`Utilities.reset_optimizer(::CachingOptimizer, new_optimizer)`](@ref) |
| 95 | +if the type of `new_optimizer` is different from the type of `optimizer`. |
| 96 | +
|
| 97 | +## Constructor without optimizer |
38 | 98 |
|
39 | 99 | ```julia |
40 | 100 | CachingOptimizer(cache::MOI.ModelLike, mode::CachingOptimizerMode) |
41 | 101 | ``` |
42 | 102 |
|
43 | | -Creates a `CachingOptimizer` in the `NO_OPTIMIZER` state and mode `mode`. |
| 103 | +Creates a `CachingOptimizer` in the [`NO_OPTIMIZER`](@ref) |
| 104 | +[`Utilties.CachingOptimizerState`](@ref) and the |
| 105 | +[`Utilties.CachingOptimizerMode`](@ref) `mode`. |
44 | 106 |
|
45 | 107 | The type of the optimizer returned is |
46 | 108 | `CachingOptimizer{MOI.AbstractOptimizer,typeof(cache)}` so it _does_ support the |
47 | 109 | function `reset_optimizer(::CachingOptimizer, new_optimizer)` if the type of |
48 | 110 | `new_optimizer` is different from the type of `optimizer`. |
49 | | -
|
50 | | -## About the type |
51 | | -
|
52 | | -### States |
53 | | -
|
54 | | -A `CachingOptimizer` may be in one of three possible states |
55 | | -(`CachingOptimizerState`): |
56 | | -
|
57 | | -* `NO_OPTIMIZER`: The CachingOptimizer does not have any optimizer. |
58 | | -* `EMPTY_OPTIMIZER`: The CachingOptimizer has an empty optimizer. |
59 | | - The optimizer is not synchronized with the cached model. |
60 | | -* `ATTACHED_OPTIMIZER`: The CachingOptimizer has an optimizer, and it is |
61 | | - synchronized with the cached model. |
62 | | -
|
63 | | -### Modes |
64 | | -
|
65 | | -A `CachingOptimizer` has two modes of operation (`CachingOptimizerMode`): |
66 | | -
|
67 | | -* `MANUAL`: The only methods that change the state of the `CachingOptimizer` |
68 | | - are [`Utilities.reset_optimizer`](@ref), [`Utilities.drop_optimizer`](@ref), |
69 | | - and [`Utilities.attach_optimizer`](@ref). |
70 | | - Attempting to perform an operation in the incorrect state results in an error. |
71 | | -* `AUTOMATIC`: The `CachingOptimizer` changes its state when necessary. For |
72 | | - example, `optimize!` will automatically call `attach_optimizer` (an |
73 | | - optimizer must have been previously set). Attempting to add a constraint or |
74 | | - perform a modification not supported by the optimizer results in a drop to |
75 | | - `EMPTY_OPTIMIZER` mode. |
76 | 111 | """ |
77 | 112 | mutable struct CachingOptimizer{O,M<:MOI.ModelLike} <: MOI.AbstractOptimizer |
78 | 113 | optimizer::Union{Nothing,O} |
@@ -154,14 +189,18 @@ end |
154 | 189 | """ |
155 | 190 | state(m::CachingOptimizer)::CachingOptimizerState |
156 | 191 |
|
157 | | -Returns the state of the CachingOptimizer `m`. See [`Utilities.CachingOptimizer`](@ref). |
| 192 | +Returns the state of the CachingOptimizer `m`. |
| 193 | +
|
| 194 | +See [`Utilities.CachingOptimizer`](@ref). |
158 | 195 | """ |
159 | 196 | state(m::CachingOptimizer) = m.state |
160 | 197 |
|
161 | 198 | """ |
162 | 199 | mode(m::CachingOptimizer)::CachingOptimizerMode |
163 | 200 |
|
164 | | -Returns the operating mode of the CachingOptimizer `m`. See [`Utilities.CachingOptimizer`](@ref). |
| 201 | +Returns the operating mode of the CachingOptimizer `m`. |
| 202 | +
|
| 203 | +See [`Utilities.CachingOptimizer`](@ref). |
165 | 204 | """ |
166 | 205 | mode(m::CachingOptimizer) = m.mode |
167 | 206 |
|
|
0 commit comments