-
-
Notifications
You must be signed in to change notification settings - Fork 395
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
✨ Add support for solver at optimize with bridges #1626
Conversation
[2] get(::JuMP.JuMPMOIModel{Float64}, ::MathOptInterface.ObjectiveFunction{MathOptInterface.SingleVariable}) at /home/blegat/.julia/dev/MathOptInterface/src/Utilities/model.jl:259 | ||
[3] get at /home/blegat/.julia/dev/MathOptInterface/src/Utilities/universalfallback.jl:105 [inlined] | ||
[4] get at /home/blegat/.julia/dev/MathOptInterface/src/Utilities/cachingoptimizer.jl:436 [inlined] | ||
[1] convert at /home/blegat/.julia/dev/MathOptInterface/src/functions.jl:398 [inlined] |
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.
Surely this fails because we're not filtering out the path as well? Or does that happen somewhere else?
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.
We are filtering out this output so I was not required to update it.
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.
Oh, I missed the .*
at the end of the regex. r"^Stacktrace:.*"s
might be more clear?
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.
If I'm not mistaken, .*
doesn't catch newlines
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.
The modifier s
on the end makes it. I guess that's just as opaque... nm.
Codecov Report
@@ Coverage Diff @@
## master #1626 +/- ##
=========================================
+ Coverage 90.86% 91.26% +0.4%
=========================================
Files 28 28
Lines 3743 3984 +241
=========================================
+ Hits 3401 3636 +235
- Misses 342 348 +6
Continue to review full report at Codecov.
|
src/JuMP.jl
Outdated
""" | ||
function bridge_constraints(model::Model) | ||
caching_optimizer = backend(model) | ||
if caching_optimizer isa MOIU.CachingOptimizer |
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.
Nit: if backend(model) isa MOIU.CachingOptimizer
. It's weird call something caching_optimizer
if it might not be one.
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.
I renamed it moi_backend
. The advantage of storing it in a local variable is that inference can use the fact that it is in the first clause of the if
to infer that the variable is a CachingOptimizer and we loose a bit of the disadvantage that moi_backend
is not concretely typed
src/JuMP.jl
Outdated
""" | ||
bridge_constraints(model::Model) | ||
|
||
Return a `Bool` indicating whether the model `model` is in manual or automatic |
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.
The wording is a bit confusing. Maybe split into cases. When in manual or automatic mode, returns X. When in direct mode, returns false.
src/optimizer_interface.jl
Outdated
end | ||
|
||
function MOIU.dropoptimizer!(model::Model) | ||
error_if_direct_mode(model, :dropoptimizer!) | ||
@assert mode(model) != Direct |
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.
The assert can be dropped now
src/optimizer_interface.jl
Outdated
end | ||
|
||
function MOIU.attachoptimizer!(model::Model) | ||
error_if_direct_mode(model, :attachoptimizer!) | ||
@assert mode(model) != Direct |
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.
Same here
Before this PR, the MOI layers on top of the optimizer where:
Bridges -> CachingOptimizer
Now if the optimizer
supports_default_copy_to
, it is:CachingOptimizer -> Bridges
otherwise, it is:
CachingOptimizer -> Bridges -> CachingOptimizer
When a model is created without any optimizer we have simply:
CachingOptimizer
and the bridges are added with the optimizer when it is added. This allows bridges to work when the optimizer is added after model creation.
Closes #1504