You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Begin refactor from `modifyconstraint(m, c, set)` to
`set!(m, ConstraintSet(), c, set)`. This patch currently errors as
it needs to be implemented for src/Utilities/model.jl, but I'm not
sure where to start.
* Update Model (#389)
Updates from @blegat
* Resolve ambiguity errors relating to canset and set! ConstraintSet.
* Fixes to get tests passing
* Refactor modfiyconstraint!(m,c,f) to set!(m,ConstraintFunction(),c,f)
* Refactor modifyconstraint! to modify! and canmodifycontraint to
canmodify. These functions now only apply to
AbstractFunctionModification changes.
* Fix definition of canmodify. This patch does not pass tests due to
problems with canmodify in the bridge code.
* Add broken tests
* Add unit tests for setting ConstraintSet
* Refactor modifyobjective! to modify!(m, ObjectiveFunction, change).
* Add more tests for modifications
* Begin documentation of problem modificatino
* Add more modification tests
* Add test for modifying constraint function. There is a broken test
and one commented out as MockOptimizer fails getting the constraint
function.
* Fix bridges tests
* Fix set! ConstraintFunction for mock optimizer
* Add more tests for default fallbacks
* Add more documentation, tests for MultirowChange, and fix
associated bug.
* Refactor transformconstraint! to transform!. Currently this is not
tested as transform! is not implemented in MockOptimizer
* Update modification docs with comments from @mlubin
* Address method ambiguity
* Refactor canset and set! to reduce method ambiguities
* Fix typo
* Fix cantransform
* Address comments by @blegat
* Re-enable transform test
* Address comments by @mlubin
we can modify the coefficient of the `x` variable so that the constraint becomes
580
+
``2.0x <= 1.0`` as follows:
581
+
```julia
582
+
modify!(m, c, ScalarCoefficientChange(x, 2.0))
583
+
```
584
+
585
+
[`ScalarCoefficientChange`](@ref) can also be used to modify the objective
586
+
function by passing an instance of [`ObjectiveFunction`](@ref) instead of the
587
+
constraint index `c` as we saw above.
588
+
589
+
#### Affine coefficients in a vector function
590
+
591
+
Finally, the last modification supported by MathOptInterface is the ability to
592
+
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).
595
+
596
+
For example, given the constraint ``Ax \\in \\mathbb{R}^2_+``, where
597
+
``A = [1.0, 2.0]^\\top``:
598
+
```julia
599
+
c =addconstraint!(m,
600
+
VectorAffineFunction([
601
+
VectorAffineTerm(1, ScalarAffineTerm(1.0, x)),
602
+
VectorAffineTerm(1, ScalarAffineTerm(2.0, x))
603
+
],
604
+
[0.0, 0.0]
605
+
),
606
+
Nonnegatives(2)
607
+
)
608
+
```
609
+
we can modify the coefficients of the `x` variable so that the `A` matrix
610
+
becomes ``A = [3.0, 4.0]^\\top`` as follows:
611
+
```julia
612
+
modify!(m, c, MultirowChange(x, [3.0, 4.0]))
613
+
```
614
+
415
615
## Advanced
416
616
417
617
### Duals
418
618
419
-
420
619
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.
421
620
For conic-form minimization problems, the primal is:
422
621
@@ -529,9 +728,6 @@ If the set ``C_i`` of the section [Duals](@ref) is one of these three cones,
529
728
then the rows of the matrix ``A_i`` corresponding to off-diagonal entries are twice the value of the `coefficients` field in the `VectorAffineFunction` for the corresponding rows.
530
729
See [`PositiveSemidefiniteConeTriangle`](@ref MathOptInterface.PositiveSemidefiniteConeTriangle) for details.
531
730
532
-
### Modifying a model
533
-
534
-
[Explain `modifyconstraint!` and `modifyobjective!`.]
MOI.canmodify(b::AbstractBridgeOptimizer, obj::MOI.ObjectiveFunction, ::Type{M}) where M<:MOI.AbstractFunctionModification= MOI.canmodify(b.model, obj, M)
function MOI.modifyconstraint!(model::MOI.ModelLike, c::SplitIntervalBridge, change::Union{MOI.ScalarAffineFunction, MOI.AbstractFunctionModification})
56
-
MOI.modifyconstraint!(model, c.lower, change)
57
-
MOI.modifyconstraint!(model, c.upper, change)
58
-
end
59
-
function MOI.modifyconstraint!(model::MOI.ModelLike, c::SplitIntervalBridge, change::MOI.Interval)
0 commit comments