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