Skip to content

Commit bf18652

Browse files
committed
[docs] better document various enums
1 parent 8f2f253 commit bf18652

File tree

8 files changed

+189
-90
lines changed

8 files changed

+189
-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: 76 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,48 @@
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+
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+
)
1757

1858
"""
1959
CachingOptimizer
@@ -22,57 +62,52 @@
2262
links it with an optimizer. It supports incremental model construction and
2363
modification even when the optimizer doesn't.
2464
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
2684
2785
```julia
2886
CachingOptimizer(cache::MOI.ModelLike, optimizer::AbstractOptimizer)
2987
```
3088
31-
Creates a `CachingOptimizer` in `AUTOMATIC` mode, with the optimizer
89+
Creates a `CachingOptimizer` in [`AUTOMATIC`](@ref) mode, with the optimizer
3290
`optimizer`.
3391
3492
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
3898
3999
```julia
40100
CachingOptimizer(cache::MOI.ModelLike, mode::CachingOptimizerMode)
41101
```
42102
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`.
44106
45107
The type of the optimizer returned is
46108
`CachingOptimizer{MOI.AbstractOptimizer,typeof(cache)}` so it _does_ support the
47109
function `reset_optimizer(::CachingOptimizer, new_optimizer)` if the type of
48110
`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.
76111
"""
77112
mutable struct CachingOptimizer{O,M<:MOI.ModelLike} <: MOI.AbstractOptimizer
78113
optimizer::Union{Nothing,O}
@@ -154,14 +189,18 @@ end
154189
"""
155190
state(m::CachingOptimizer)::CachingOptimizerState
156191
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).
158195
"""
159196
state(m::CachingOptimizer) = m.state
160197

161198
"""
162199
mode(m::CachingOptimizer)::CachingOptimizerMode
163200
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).
165204
"""
166205
mode(m::CachingOptimizer) = m.mode
167206

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)