Skip to content

Commit f42824a

Browse files
authored
Fix formatting of modification section (#402)
1 parent 63b4dd9 commit f42824a

File tree

2 files changed

+60
-55
lines changed

2 files changed

+60
-55
lines changed

docs/src/apimanual.md

Lines changed: 53 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -435,16 +435,17 @@ instance of the same type.
435435
Given a constraint of type `F`-in-`S` (see [Constraints by function-set pairs](@ref)
436436
above for an explanation), we can modify parameters (but not the type) of the
437437
set `S` by replacing it with a new instance of the same type. For example,
438-
given the variable bound ``x \\le 1``:
438+
given the variable bound ``x \le 1``:
439439
```julia
440440
c = addconstraint(m, SingleVariable(x), LessThan(1.0))
441441
```
442-
we can modify the set so that the bound now ``x \\le 2`` as follows:
442+
we can modify the set so that the bound now ``x \le 2`` as follows:
443443
```julia
444444
set!(m, ConstraintSet(), c, LessThan(2.0))
445445
```
446-
where `m` is our [`ModelLike`](@ref) model. However, the following will fail as
447-
the new set (`GreaterThan`) is of a different type to the original set
446+
where `m` is our [`ModelLike`](@ref MathOptInterface.ModelLike) model. However,
447+
the following will fail as the new set (`GreaterThan`) is of a different type to
448+
the original set
448449
(`LessThan`):
449450
```julia
450451
set!(m, ConstraintSet(), c, GreaterThan(2.0)) # errors
@@ -453,36 +454,40 @@ If our constraint is an affine inequality, then this corresponds to modifying
453454
the right-hand side of a constraint in linear programming.
454455

455456
In some special cases, solvers may support efficiently changing the set of a
456-
constraint (for example, from [`LessThan`](@ref) to [`GreaterThan`](@ref)). For
457-
these cases, MathOptInterface provides the [`transform!`](@ref) method. For
458-
example, instead of the error we observed above, the following will work:
457+
constraint (for example, from [`LessThan`](@ref MathOptInterface.LessThan) to
458+
[`GreaterThan`](@ref MathOptInterface.GreaterThan)). For these cases,
459+
MathOptInterface provides the [`transform!`](@ref MathOptInterface.transform!)
460+
method. For example, instead of the error we observed above, the following will
461+
work:
459462
```julia
460463
c2 = transform!(m, c, GreaterThan(1.0))
461464
```
462-
The [`transform!`](@ref) function returns a new constraint index, and the old
463-
constraint index (i.e., `c`) is no longer valid:
465+
The [`transform!`](@ref MathOptInterface.transform!) function returns a new
466+
constraint index, and the old constraint index (i.e., `c`) is no longer valid:
464467
```julia
465468
isvalid(m, c) # false
466469
isvalid(m, c2) # true
467470
```
468-
Also note that [`transform!`](@ref) cannot be called with a set of the same
469-
type; [`set!`](@ref) should be used instead.
471+
Also note that [`transform!`](@ref MathOptInterface.transform!) cannot be called
472+
with a set of the same type; [`set!`](@ref MathOptInterface.set!) should be used
473+
instead.
470474

471475
#### The function of a constraint
472476

473477
Given a constraint of type `F`-in-`S` (see [Constraints by function-set pairs](@ref)
474478
above for an explanation), it is also possible to modify the function of type
475479
`F` by replacing it with a new instance of the same type. For example, given the
476-
variable bound ``x \\le 1``:
480+
variable bound ``x \le 1``:
477481
```julia
478482
c = addconstraint(m, SingleVariable(x), LessThan(1.0))
479483
```
480-
we can modify the function so that the bound now ``y \\le 1`` as follows:
484+
we can modify the function so that the bound now ``y \le 1`` as follows:
481485
```julia
482486
set!(m, ConstraintFunction(), c, SingleVariable(y))
483487
```
484-
where `m` is our [`ModelLike`](@ref) model. However, the following will fail as
485-
the new function is of a different type to the original function:
488+
where `m` is our [`ModelLike`](@ref MathOptInterface.ModelLike) model. However,
489+
the following will fail as the new function is of a different type to the
490+
original function:
486491
```julia
487492
set!(m, ConstraintFunction(), c,
488493
ScalarAffineFunction([ScalarAffineTerm(1.0, x)], 0.0)
@@ -501,25 +506,28 @@ MathOptInterface. They are:
501506

502507
To distinguish between the replacement of the function with a new instance
503508
(described above) and the modification of an existing function, the in-place
504-
modifications use the [`modify!`](@ref) method:
509+
modifications use the [`modify!`](@ref MathOptInterface.modify!) method:
505510
```julia
506511
modify!(model, index, change::AbstractFunctionModification)
507512
```
508-
[`modify!`](@ref) takes three arguments. The first is the [`ModelLike`](@ref)
509-
model `model`, the second is the constraint index, and the third is an instance
510-
of an [`AbstractFunctionModification`](@ref).
513+
[`modify!`](@ref MathOptInterface.modify!) takes three arguments. The first is
514+
the [`ModelLike`](@ref MathOptInterface.ModelLike) model `model`, the second is
515+
the constraint index, and the third is an instance of an
516+
[`AbstractFunctionModification`](@ref MathOptInterface.AbstractFunctionModification).
511517

512518
We now detail each of these four in-place modifications.
513519

514520
#### Constant term in a scalar function
515521

516522
MathOptInterface supports is the ability to modify the constant term within a
517-
[`ScalarAffineFunction`](@ref) and a [`ScalarQuadraticFunction`](@ref) using the
518-
[`ScalarConstantChange`](@ref) subtype of
519-
[`AbstractFunctionModification`](@ref). This includes the objective function, as
520-
well as the function in a function-pair constraint.
521-
522-
For example, consider a problem `m` with the objective ``\\max 1.0x + 0.0``:
523+
[`ScalarAffineFunction`](@ref MathOptInterface.ScalarAffineFunction) and a
524+
[`ScalarQuadraticFunction`](@ref MathOptInterface.ScalarQuadraticFunction) using
525+
the [`ScalarConstantChange`](@ref MathOptInterface.ScalarConstantChange) subtype
526+
of [`AbstractFunctionModification`](@ref MathOptInterface.AbstractFunctionModification).
527+
This includes the objective function, as well as the function in a function-pair
528+
constraint.
529+
530+
For example, consider a problem `m` with the objective ``\max 1.0x + 0.0``:
523531
```julia
524532
set!(m,
525533
ObjectiveFunction{ScalarAffineFunction{Float64}}(),
@@ -533,13 +541,13 @@ modify!(m,
533541
ScalarConstantChange(1.0)
534542
)
535543
```
536-
The objective function will now be ``\\max 1.0x + 1.0``.
544+
The objective function will now be ``\max 1.0x + 1.0``.
537545

538546
#### Constant terms in a vector function
539547

540-
We can modify the constant terms in a [`VectorAffineFunction`](@ref) or a
541-
[`VectorQuadraticFunction`](@ref) using the [`VectorConstantChange`](@ref)
542-
subtype of [`AbstractFunctionModification`](@ref).
548+
We can modify the constant terms in a [`VectorAffineFunction`](@ref MathOptInterface.VectorAffineFunction) or a [`VectorQuadraticFunction`](@ref MathOptInterface.VectorQuadraticFunction) using the
549+
[`VectorConstantChange`](@ref MathOptInterface.VectorConstantChange) subtype of
550+
[`AbstractFunctionModification`](@ref MathOptInterface.AbstractFunctionModification).
543551

544552
For example, consider a model with the following
545553
`VectorAffineFunction`-in-`Nonpositives` constraint:
@@ -554,20 +562,20 @@ c = addconstraint!(m,
554562
Nonpositives(2)
555563
)
556564
```
557-
We can modify the constant vector in the [`VectorAffineFunction`](@ref) from
558-
`[0.0, 0.0]` to `[1.0, 2.0]` as follows:
565+
We can modify the constant vector in the [`VectorAffineFunction`](@ref MathOptInterface.VectorAffineFunction)
566+
from `[0.0, 0.0]` to `[1.0, 2.0]` as follows:
559567
```julia
560568
modify!(m, c, VectorConstantChange([1.0, 2.0])
561569
)
562570
```
563-
The constraints are now ``1.0x + 1.0 \\le 0.0`` and ``2.0y + 2.0 \\le 0.0``.
571+
The constraints are now ``1.0x + 1.0 \le 0.0`` and ``2.0y + 2.0 \le 0.0``.
564572

565573
#### Affine coefficients in a scalar function
566574

567575
In addition to modifying the constant terms in a function, we can also modify
568-
the affine variable coefficients in an [`ScalarAffineFunction`](@ref) or a
569-
[`ScalarQuadraticFunction`](@ref) using the [`ScalarCoefficientChange`](@ref)
570-
subtype of [`AbstractFunctionModification`](@ref).
576+
the affine variable coefficients in an [`ScalarAffineFunction`](@ref MathOptInterface.ScalarAffineFunction) or a [`ScalarQuadraticFunction`](@ref MathOptInterface.ScalarQuadraticFunction) using
577+
the [`ScalarCoefficientChange`](@ref MathOptInterface.ScalarCoefficientChange)
578+
subtype of [`AbstractFunctionModification`](@ref MathOptInterface.AbstractFunctionModification).
571579

572580
For example, given the constraint ``1.0x <= 1.0``:
573581
```julia
@@ -582,19 +590,22 @@ we can modify the coefficient of the `x` variable so that the constraint becomes
582590
modify!(m, c, ScalarCoefficientChange(x, 2.0))
583591
```
584592

585-
[`ScalarCoefficientChange`](@ref) can also be used to modify the objective
586-
function by passing an instance of [`ObjectiveFunction`](@ref) instead of the
593+
[`ScalarCoefficientChange`](@ref MathOptInterface.ScalarCoefficientChange) can
594+
also be used to modify the objective function by passing an instance of
595+
[`ObjectiveFunction`](@ref MathOptInterface.ObjectiveFunction) instead of the
587596
constraint index `c` as we saw above.
588597

589598
#### Affine coefficients in a vector function
590599

591600
Finally, the last modification supported by MathOptInterface is the ability to
592601
modify the affine coefficients of a single variable in a
593-
[`VectorAffineFunction`](@ref) or a [`VectorQuadraticFunction`](@ref) using the
594-
[`MultirowChange`](@ref) subtype of [`AbstractFunctionModification`](@ref).
602+
[`VectorAffineFunction`](@ref MathOptInterface.VectorAffineFunction) or a
603+
[`VectorQuadraticFunction`](@ref MathOptInterface.VectorQuadraticFunction) using
604+
the [`MultirowChange`](@ref MathOptInterface.MultirowChange) subtype of
605+
[`AbstractFunctionModification`](@ref MathOptInterface.AbstractFunctionModification).
595606

596-
For example, given the constraint ``Ax \\in \\mathbb{R}^2_+``, where
597-
``A = [1.0, 2.0]^\\top``:
607+
For example, given the constraint ``Ax \in \mathbb{R}^2_+``, where
608+
``A = [1.0, 2.0]^\top``:
598609
```julia
599610
c = addconstraint!(m,
600611
VectorAffineFunction([
@@ -607,7 +618,7 @@ c = addconstraint!(m,
607618
)
608619
```
609620
we can modify the coefficients of the `x` variable so that the `A` matrix
610-
becomes ``A = [3.0, 4.0]^\\top`` as follows:
621+
becomes ``A = [3.0, 4.0]^\top`` as follows:
611622
```julia
612623
modify!(m, c, MultirowChange(x, [3.0, 4.0]))
613624
```

docs/src/apireference.md

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -163,8 +163,6 @@ isvalid(::ModelLike,::ConstraintIndex)
163163
canaddconstraint
164164
addconstraint!
165165
addconstraints!
166-
modify!
167-
canmodify
168166
transform!
169167
cantransform
170168
supportsconstraint
@@ -207,15 +205,6 @@ Functions for getting and setting properties of sets.
207205
output_dimension
208206
```
209207

210-
List of function modifications.
211-
```@docs
212-
AbstractFunctionModification
213-
ScalarConstantChange
214-
VectorConstantChange
215-
ScalarCoefficientChange
216-
MultirowChange
217-
```
218-
219208
## Sets
220209

221210
List of recognized sets.
@@ -257,13 +246,18 @@ Functions for getting and setting properties of sets.
257246
dimension
258247
```
259248

260-
## Objective modifications
249+
## Modifications
261250

262-
Functions for modifying objective functions. Use `ObjectiveFunction` and `ObjectiveSense` to set and query the objective function.
251+
Functions for modifying objective and constraint functions.
263252

264253
```@docs
265254
modify!
266255
canmodify
256+
AbstractFunctionModification
257+
ScalarConstantChange
258+
VectorConstantChange
259+
ScalarCoefficientChange
260+
MultirowChange
267261
```
268262

269263
## Nonlinear programming (NLP)

0 commit comments

Comments
 (0)