Skip to content

Commit 3a1eddb

Browse files
committed
Address comments
1 parent 35a5689 commit 3a1eddb

File tree

3 files changed

+35
-30
lines changed

3 files changed

+35
-30
lines changed

docs/src/apimanual.md

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -864,7 +864,7 @@ read!(io, src_2)
864864
### Duals
865865

866866
Conic duality is the starting point for MOI's duality conventions. When all functions are affine (or coordinate projections), and all constraint sets are closed convex cones, the model may be called a conic optimization problem.
867-
For conic-form minimization problems, the primal is:
867+
For a minimization problem in geometric conic form, the primal is:
868868

869869
```math
870870
\begin{align}
@@ -874,7 +874,7 @@ For conic-form minimization problems, the primal is:
874874
\end{align}
875875
```
876876

877-
and the dual is:
877+
and the dual is a maximization problem in standard conic form:
878878

879879
```math
880880
\begin{align}
@@ -888,7 +888,7 @@ and the dual is:
888888

889889
where each ``\mathcal{C}_i`` is a closed convex cone and ``\mathcal{C}_i^*`` is its dual cone.
890890

891-
For conic-form maximization problems, the primal is:
891+
For a maximization problem in geometric conic form, the primal is:
892892
```math
893893
\begin{align}
894894
& \max_{x \in \mathbb{R}^n} & a_0^T x + b_0
@@ -897,7 +897,7 @@ For conic-form maximization problems, the primal is:
897897
\end{align}
898898
```
899899

900-
and the dual is:
900+
and the dual is a minimization problem in standard conic form:
901901

902902
```math
903903
\begin{align}
@@ -1127,25 +1127,27 @@ MOI.set(model, MyPackage.PrintLevel(), 0)
11271127

11281128
### Supported constrained variables and constraints
11291129

1130-
The solver interface should only implement support for constrained variables
1131-
(see [`add_constrained_variable`](@ref)/[`add_constrained_variables`](@ref))
1132-
or constraints that directly map to a structure exploited by the solver
1133-
algorithm. There is no need to add support for additional types, this is
1134-
handled by the [Automatic reformulation](@ref). Furthermore, this allows
1130+
The solver interface should only implement support for support for variables
1131+
constrained on creation (see
1132+
[`add_constrained_variable`](@ref)/[`add_constrained_variables`](@ref)) or
1133+
constraints that directly map to a structure exploited by the solver algorithm.
1134+
There is no need to add support for additional types, this is handled by the
1135+
[Automatic reformulation](@ref). Furthermore, this allows
11351136
[`supports_constraint`](@ref) to indicate which types are exploited by the
11361137
solver and hence allows layers such as [`Bridges.LazyBridgeOptimizer`](@ref)
11371138
to accurately select the most appropriate transformations.
11381139

11391140
As [`add_constrained_variable`](@ref) (resp. [`add_constrained_variables`](@ref))
11401141
falls back to [`add_variable`](@ref) (resp. [`add_variables`](@ref)) followed by
11411142
[`add_constraint`](@ref), there is no need to implement this function
1142-
if `model` supports creating free variables. However, if `model` does not
1143-
support creating free variables, then it should only implement
1144-
[`add_constrained_variable`](@ref) and not [`add_variable`](@ref) nor
1145-
[`add_constraint`](@ref) for [`SingleVariable`](@ref)-in-`typeof(set)`.
1146-
In addition, it should implement `supports_add_constrained_variables(::Optimizer,
1147-
::Type{Reals})` and return `false` so that free variables are bridged,
1148-
see [`supports_add_constrained_variables`](@ref).
1143+
if `model` does not require that variables be constrained when they are created.
1144+
However, if `model` requires that variables be constrained when they're created,
1145+
then it should only implement [`add_constrained_variable`](@ref) and not
1146+
[`add_variable`](@ref) nor [`add_constraint`](@ref) for
1147+
[`SingleVariable`](@ref)-in-`typeof(set)`. In addition, it should implement
1148+
`supports_add_constrained_variables(::Optimizer, ::Type{Reals})` and return
1149+
`false` so that free variables are bridged, see
1150+
[`supports_add_constrained_variables`](@ref).
11491151

11501152
### Handling duplicate coefficients
11511153

src/constraints.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ sum of a nonnegative and a nonpositive variables.
2929
""" # Implemented as only one method to avoid ambiguity
3030
function supports_constraint(model::ModelLike, F::Type{<:AbstractFunction},
3131
S::Type{<:AbstractSet})
32-
# TODO removed this condition, as `supports_add_constrained_variables(model, Reals)`
32+
# TODO remove this condition, as `supports_add_constrained_variables(model, Reals)`
3333
# should be called instead of
3434
# `supports_constraint(model, ::VectorOfVariables, ::Reals)
3535
if F === VectorOfVariables && S === Reals

src/variables.jl

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,14 @@ definition for most models.
5353
## Example
5454
5555
Suppose that a solver supports only two kind of variables: binary variables
56-
and continuous variables with a lower bound. If the solver decide not to
56+
and continuous variables with a lower bound. If the solver decides not to
5757
support `SingleVariable`-in-`Binary` and `SingleVariable`-in-`GreaterThan`
5858
constraints, it only has to implement `add_constrained_variable` for these
5959
two sets which prevents the user to add both a binary constraint and a
6060
lower bound on the same variable. Moreover, if the user adds a
61-
`SingleVariable`-in-`GreaterThan` constraint, it will transparently be bridged
62-
into a supported constraint.
61+
`SingleVariable`-in-`GreaterThan` constraint, implementing this interface (i.e.,
62+
`supports_add_constrained_variables`) enables the constraint to be transparently
63+
bridged. into a supported constraint.
6364
"""
6465
function supports_add_constrained_variable(model::ModelLike,
6566
S::Type{<:AbstractScalarSet})
@@ -106,33 +107,35 @@ definition for most models.
106107
107108
## Example
108109
109-
In the standard conic form, the variables are grouped into several cones
110-
and the constraints are affine equality constraints.
110+
In the standard conic form (see [Duals](@ref)), the variables are grouped into
111+
several cones and the constraints are affine equality constraints.
111112
If `Reals` is not one of the cones supported by the solvers then it needs
112113
to implement `supports_add_constrained_variables(::Optimizer, ::Type{Reals}) = false`
113114
as free variables are not supported.
114115
The solvers should then implement
115116
`supports_add_constrained_variables(::Optimizer, ::Type{<:SupportedCones}) = true`
116-
where `SupportedCones` is the union of all cone types that are supported
117-
but it should not implement
117+
where `SupportedCones` is the union of all cone types that are supported;
118+
but it does not have to implement the method
118119
`supports_constraint(::Type{VectorOfVariables}, Type{<:SupportedCones})`
119-
as it should return `false`.
120+
as it should return `false` and it's the default.
120121
This prevents the user to constrain the same variable in two different cones.
121122
When a `VectorOfVariables`-in-`S` is added, the variables of the vector
122123
have already been created so they already belong to given cones.
123-
The constraint will therefore be bridged by adding slack variables in `S`
124-
and equality constraints ensuring that the slack variables are equal to the
125-
corresponding variables of the given constraint function.
124+
If bridges are enabled, the constraint will therefore be bridged by adding slack
125+
variables in `S` and equality constraints ensuring that the slack variables are
126+
equal to the corresponding variables of the given constraint function.
126127
127128
Note that there may also be sets for which
128129
`!supports_add_constrained_variables(model, S)` and
129130
`supports_constraint(model, MOI.VectorOfVariables, S)`.
130131
For instance, suppose a solver supports positive semidefinite variable
131132
constraints and two types of variables: binary variables and nonnegative
132133
variables. Then the solver should support adding
133-
`VectorOfVariables`-in-`PositiveSemidefiniteConeTriangle` constraints but it
134+
`VectorOfVariables`-in-`PositiveSemidefiniteConeTriangle` constraints, but it
134135
should not support creating variables constrained to belong to the
135-
`PositiveSemidefiniteConeTriangle` as free variables are not supported.
136+
`PositiveSemidefiniteConeTriangle` because the variables in
137+
`PositiveSemidefiniteConeTriangle` should first be created as either binary or
138+
non-negative.
136139
"""
137140
function supports_add_constrained_variables(
138141
model::ModelLike, S::Type{<:AbstractVectorSet})

0 commit comments

Comments
 (0)