-
Notifications
You must be signed in to change notification settings - Fork 8
Fix setter for ConstraintSet and ConstraintFunction #120
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -406,6 +406,78 @@ function MOI.set( | |
| MOI.set(model.optimizer, MOI.ConstraintFunction(), c, f) | ||
| return | ||
| end | ||
| function MOI.set( | ||
| model::Optimizer, | ||
| ::MOI.ConstraintFunction, | ||
| c::MOI.ConstraintIndex{MOI.ScalarAffineFunction{T},S}, | ||
| f::F, | ||
| ) where {T,S<:MOI.AbstractSet,F} | ||
| if haskey(model.affine_added_cache, c) | ||
| MOI.set( | ||
| model.optimizer, | ||
| MOI.ConstraintFunction(), | ||
| model.affine_added_cache[c], | ||
| f, | ||
| ) | ||
| else | ||
| MOI.set(model.optimizer, MOI.ConstraintFunction(), c, f) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is also strange, you might have parameters in |
||
| end | ||
| return | ||
| end | ||
| function MOI.set( | ||
| model::Optimizer, | ||
| ::MOI.ConstraintFunction, | ||
| c::MOI.ConstraintIndex{MOI.ScalarQuadraticFunction{T},S}, | ||
| f::F, | ||
| ) where {T,S<:MOI.AbstractSet,F} | ||
| if haskey(model.quadratic_added_cache, c) | ||
| MOI.set( | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same as above |
||
| model.optimizer, | ||
| MOI.ConstraintFunction(), | ||
| model.quadratic_added_cache[c], | ||
| f, | ||
| ) | ||
| else | ||
| MOI.set(model.optimizer, MOI.ConstraintFunction(), c, f) | ||
| end | ||
| return | ||
| end | ||
| function MOI.set( | ||
| model::Optimizer, | ||
| ::MOI.ConstraintSet, | ||
| c::MOI.ConstraintIndex{MOI.ScalarQuadraticFunction{T},S}, | ||
| s::S, | ||
| ) where {T,S<:MOI.AbstractSet} | ||
| if haskey(model.quadratic_added_cache, c) | ||
| MOI.set( | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same |
||
| model.optimizer, | ||
| MOI.ConstraintSet(), | ||
| model.quadratic_added_cache[c], | ||
| s, | ||
| ) | ||
| else | ||
| MOI.set(model.optimizer, MOI.ConstraintSet(), c, s) | ||
| end | ||
| return | ||
| end | ||
| function MOI.set( | ||
| model::Optimizer, | ||
| ::MOI.ConstraintSet, | ||
| c::MOI.ConstraintIndex{MOI.ScalarAffineFunction{T},S}, | ||
| s::S, | ||
| ) where {T,S<:MOI.AbstractSet} | ||
| if haskey(model.affine_added_cache, c) | ||
| MOI.set( | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same |
||
| model.optimizer, | ||
| MOI.ConstraintSet(), | ||
| model.affine_added_cache[c], | ||
| s, | ||
| ) | ||
| else | ||
| MOI.set(model.optimizer, MOI.ConstraintSet(), c, s) | ||
| end | ||
| return | ||
| end | ||
| function MOI.set( | ||
| model::Optimizer, | ||
| ::MOI.ConstraintSet, | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this looks too simple, don't we have any other data cached for affine function in the
POI.Optimizer?