Skip to content

Commit 548793f

Browse files
authored
[docs] better document various enums (#2699)
1 parent 8f2f253 commit 548793f

File tree

8 files changed

+193
-90
lines changed

8 files changed

+193
-90
lines changed

docs/src/reference/models.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,8 +155,12 @@ OTHER_RESULT_STATUS
155155
```@docs
156156
compute_conflict!
157157
ConflictStatus
158-
ConstraintConflictStatus
159158
ConflictStatusCode
159+
COMPUTE_CONFLICT_NOT_CALLED
160+
NO_CONFLICT_EXISTS
161+
NO_CONFLICT_FOUND
162+
CONFLICT_FOUND
163+
ConstraintConflictStatus
160164
ConflictParticipationStatusCode
161165
NOT_IN_CONFLICT
162166
IN_CONFLICT

docs/src/reference/standard_form.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,9 @@ NormNuclearCone
9898
SOS1
9999
SOS2
100100
Indicator
101+
ActivationCondition
102+
ACTIVATE_ON_ZERO
103+
ACTIVATE_ON_ONE
101104
Complements
102105
HyperRectangle
103106
Scaled

docs/src/submodules/FileFormats/reference.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,19 @@ Functions to help read and write MOI models to/from various file formats. See
1414
```@docs
1515
FileFormats.Model
1616
FileFormats.FileFormat
17+
FileFormats.FORMAT_AUTOMATIC
18+
FileFormats.FORMAT_CBF
1719
FileFormats.CBF.Model
20+
FileFormats.FORMAT_LP
1821
FileFormats.LP.Model
22+
FileFormats.FORMAT_MOF
1923
FileFormats.MOF.Model
24+
FileFormats.FORMAT_MPS
2025
FileFormats.MPS.Model
26+
FileFormats.FORMAT_NL
2127
FileFormats.NL.Model
28+
FileFormats.FORMAT_REW
29+
FileFormats.FORMAT_SDPA
2230
FileFormats.SDPA.Model
2331
```
2432

docs/src/submodules/Utilities/reference.md

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,18 @@ Utilities.struct_of_constraint_code
5353

5454
```@docs
5555
Utilities.CachingOptimizer
56+
Utilities.CachingOptimizerState
57+
Utilities.NO_OPTIMIZER
58+
Utilities.EMPTY_OPTIMIZER
59+
Utilities.ATTACHED_OPTIMIZER
60+
Utilities.state
61+
Utilities.CachingOptimizerMode
62+
Utilities.AUTOMATIC
63+
Utilities.MANUAL
64+
Utilities.mode
5665
Utilities.attach_optimizer
5766
Utilities.reset_optimizer
5867
Utilities.drop_optimizer
59-
Utilities.state
60-
Utilities.mode
6168
```
6269

6370
## Mock optimizer

src/FileFormats/FileFormats.jl

Lines changed: 49 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -20,42 +20,72 @@ include("MPS/MPS.jl")
2020
include("NL/NL.jl")
2121
include("SDPA/SDPA.jl")
2222

23-
"""
24-
FileFormat
25-
26-
List of accepted export formats.
27-
28-
- `FORMAT_AUTOMATIC`: try to detect the file format based on the file name
29-
- `FORMAT_CBF`: the Conic Benchmark format
30-
- `FORMAT_LP`: the LP file format
31-
- `FORMAT_MOF`: the MathOptFormat file format
32-
- `FORMAT_MPS`: the MPS file format
33-
- `FORMAT_NL`: the AMPL .nl file format
34-
- `FORMAT_REW`: the .rew file format, which is MPS with generic names
35-
- `FORMAT_SDPA`: the SemiDefinite Programming Algorithm format
36-
"""
37-
@enum(
23+
MOI.@_documented_enum(
24+
"""
25+
FileFormat
26+
27+
List of accepted export formats.
28+
""",
3829
FileFormat,
30+
"""
31+
Try to detect the file format based on the file name.
32+
""",
3933
FORMAT_AUTOMATIC,
34+
"""
35+
The Conic Benchmark format.
36+
37+
See [`FileFormats.CBF.Model`](@ref) for more details.
38+
""",
4039
FORMAT_CBF,
40+
"""
41+
The LP file format.
42+
43+
See [`FileFormats.LP.Model`](@ref) for more details.
44+
""",
4145
FORMAT_LP,
46+
"""
47+
The MathOptFormat file format.
48+
49+
See [`FileFormats.MOF.Model`](@ref) for more details.
50+
""",
4251
FORMAT_MOF,
52+
"""
53+
The MPS file format.
54+
55+
See [`FileFormats.MPS.Model`](@ref) for more details.
56+
""",
4357
FORMAT_MPS,
58+
"""
59+
The AMPL .nl file format.
60+
61+
See [`FileFormats.NL.Model`](@ref) for more details.
62+
""",
4463
FORMAT_NL,
64+
"""
65+
The .rew file format, which is equivalent to the MPS format
66+
([`FileFormats.FORMAT_MPS`](@ref)) with the `generic_names = true` keyword
67+
argument set by default.
68+
69+
See [`FileFormats.MPS.Model`](@ref) for more details.
70+
""",
4571
FORMAT_REW,
72+
"""
73+
The SemiDefinite Programming Algorithm format.
74+
75+
See [`FileFormats.SDPA.Model`](@ref) for more details.
76+
""",
4677
FORMAT_SDPA,
4778
)
4879

4980
"""
50-
Model(
51-
;
81+
Model(;
5282
format::FileFormat = FORMAT_AUTOMATIC,
5383
filename::Union{Nothing, String} = nothing,
5484
kwargs...
5585
)
5686
57-
Return model corresponding to the `FileFormat` `format`, or, if
58-
`format == FORMAT_AUTOMATIC`, guess the format from `filename`.
87+
Return model corresponding to the [`FileFormats.FileFormat`](@ref) `format`, or,
88+
if `format == FORMAT_AUTOMATIC`, guess the format from `filename`.
5989
6090
The `filename` argument is only needed if `format == FORMAT_AUTOMATIC`.
6191

src/Utilities/cachingoptimizer.jl

Lines changed: 80 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,52 @@
1212
# function that uses `.optimizer`. For example:
1313
# `MOI.supports(model.optimizer, F, S)::Bool`.
1414

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+
)
1761

1862
"""
1963
CachingOptimizer
@@ -22,57 +66,52 @@
2266
links it with an optimizer. It supports incremental model construction and
2367
modification even when the optimizer doesn't.
2468
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
2688
2789
```julia
2890
CachingOptimizer(cache::MOI.ModelLike, optimizer::AbstractOptimizer)
2991
```
3092
31-
Creates a `CachingOptimizer` in `AUTOMATIC` mode, with the optimizer
93+
Creates a `CachingOptimizer` in [`AUTOMATIC`](@ref) mode, with the optimizer
3294
`optimizer`.
3395
3496
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
38102
39103
```julia
40104
CachingOptimizer(cache::MOI.ModelLike, mode::CachingOptimizerMode)
41105
```
42106
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`.
44110
45111
The type of the optimizer returned is
46112
`CachingOptimizer{MOI.AbstractOptimizer,typeof(cache)}` so it _does_ support the
47113
function `reset_optimizer(::CachingOptimizer, new_optimizer)` if the type of
48114
`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.
76115
"""
77116
mutable struct CachingOptimizer{O,M<:MOI.ModelLike} <: MOI.AbstractOptimizer
78117
optimizer::Union{Nothing,O}
@@ -154,14 +193,18 @@ end
154193
"""
155194
state(m::CachingOptimizer)::CachingOptimizerState
156195
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).
158199
"""
159200
state(m::CachingOptimizer) = m.state
160201

161202
"""
162203
mode(m::CachingOptimizer)::CachingOptimizerMode
163204
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).
165208
"""
166209
mode(m::CachingOptimizer) = m.mode
167210

src/attributes.jl

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1449,26 +1449,27 @@ struct ResultCount <: AbstractModelAttribute end
14491449

14501450
attribute_value_type(::ResultCount) = Int
14511451

1452-
"""
1453-
ConflictStatusCode
1452+
@_documented_enum(
1453+
"""
1454+
ConflictStatusCode
14541455
1455-
An Enum of possible values for the `ConflictStatus` attribute. This attribute
1456-
is meant to explain the reason why the conflict finder stopped executing in the
1457-
most recent call to [`compute_conflict!`](@ref).
1456+
An Enum of possible values for the [`ConflictStatus`](@ref) attribute.
14581457
1459-
Possible values are:
1460-
* `COMPUTE_CONFLICT_NOT_CALLED`: the function [`compute_conflict!`](@ref) has
1461-
not yet been called
1462-
* `NO_CONFLICT_EXISTS`: there is no conflict because the problem is feasible
1463-
* `NO_CONFLICT_FOUND`: the solver could not find a conflict
1464-
* `CONFLICT_FOUND`: at least one conflict could be found
1465-
"""
1466-
@enum ConflictStatusCode begin
1467-
COMPUTE_CONFLICT_NOT_CALLED
1468-
NO_CONFLICT_EXISTS
1469-
NO_CONFLICT_FOUND
1470-
CONFLICT_FOUND
1471-
end
1458+
This attribute is meant to explain the reason why the conflict finder
1459+
stopped executing in the most recent call to [`compute_conflict!`](@ref).
1460+
""",
1461+
ConflictStatusCode,
1462+
"""
1463+
The function [`compute_conflict!`](@ref) has not yet been called.
1464+
""",
1465+
COMPUTE_CONFLICT_NOT_CALLED,
1466+
"There is no conflict because the problem is feasible.",
1467+
NO_CONFLICT_EXISTS,
1468+
"The solver could not find a conflict.",
1469+
NO_CONFLICT_FOUND,
1470+
"The solver found a conflict.",
1471+
CONFLICT_FOUND,
1472+
)
14721473

14731474
"""
14741475
ConflictStatus()

0 commit comments

Comments
 (0)