-
-
Notifications
You must be signed in to change notification settings - Fork 407
Add vector version for setting constraint attributes #4033
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
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #4033 +/- ##
===========================================
- Coverage 100.00% 99.88% -0.12%
===========================================
Files 43 43
Lines 6149 6156 +7
===========================================
Hits 6149 6149
- Misses 0 7 +7 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
I'm not convinced this is needed. It would still require users to understand the relationship between JuMP and MOI. The would need to know that We already have too many methods in JuMP and MOI. I'm hesitant to add yet more. |
More concretely: using JuMP, HiGHS
N = 1_000
model = direct_model(HiGHS.Optimizer())
@variable(model, x[1:N] >= 0)
bounds = rand(N)
# Current option
MOI.set(
backend(model),
MOI.ConstraintSet(),
index.(LowerBoundRef.(x)),
MOI.GreaterThan.(v),
)
# This PR:
MOI.set(
model,
MOI.ConstraintSet(),
LowerBoundRef.(x),
MOI.GreaterThan.(v),
) I don't really see that as a win. I think I'd prefer we had fewer special cases and a more documented way to lower from JuMP to MOI. |
Those two options are not equivalent since the first one does not check |
Similarly with the The current option also avoids an extra vector allocation since |
The more I think about this the less I like it. |
Actually, one issue is that if we start on this road, we'll also probably need to support containers as wellw extracting the vectorization of the underlying constraints |
Agreed. Close this then? People can use MOI if they really need to, and that means reshaping into a vector if they need. |
The user could also write the
my_set_lower_bound
of #4030 (comment)However, calling this version is a bit easier to write but also a bit safer since it still calls
check_belongs_to_model
and takes care of theis_model_dirty
flag.One caveat is that users might then try doing it with JuMP containers so we may need at some point to also add support for
AbstractArray
that then collects and redirect to this method.We could also check that the
Vector
have the same length here.Closes #4030