-
-
Notifications
You must be signed in to change notification settings - Fork 398
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 set inequality syntax for matrices #3766
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #3766 +/- ##
=======================================
Coverage 98.38% 98.39%
=======================================
Files 44 44
Lines 5885 5904 +19
=======================================
+ Hits 5790 5809 +19
Misses 95 95 ☔ View full report in Codecov by Sentry. |
I can see us getting asked to support this for all matrices, not just symmetric ones. But perhaps that' a PR for another day. |
FWIW, yes. The |
What we are doing for |
As this is breaking then maybe we should continue to do what we do but we should add a warning in the docs that |
Peanut gallery comment: the docs and disscussion in the issue make it seem
This kinda sounds like either solution would address my concerns from #3765, i think.
Peanut gallery comment: the concern here is external non JuMP/MOI sets/code, correct? Since i don't think this syntax currently works on native JuMP/MOI stuff, so it would only affect extensions? |
Let's just throw an error for these |
But it already does it for AbstractVector so wouldn't adding an error be breaking ? |
Peanut gallery comment:
is always the same as
likewise
is always the same as
... for any [common] type of Currently
are not valid, and the code is always expected to explicitly spell out the cone type. As i see it, it's an obvious trade-off, and the current solution is not obviously optimal. I'll shut up now. |
e982863
to
7a9a6be
Compare
I've added an error for these new cases. No change to the existing vector support. I've added a warning to #3769, and we don't mention |
I actually think this is less problematic that it seems. You're opting into a new syntax. In Boyd's book, they have: And they write
It's not obvious that flipping |
FWIW i believe this (& its non-symmetric friend) can proceed without waiting for the understanding in #3770 to be reached. |
set_start_value.(y, [6 4; 4 7]) | ||
g = [x[1, 1] - y[1, 1], x[1, 2] - y[1, 2], x[2, 2] - y[2, 2]] | ||
for set in (Nonnegatives(), Nonpositives(), Zeros()) | ||
c = @constraint(model, x >= y, set) |
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.
Add a test for x - y in set
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.
Ah. @mlubin, I remember now.
We can't support x - y in Nonnegatives()
because then we can't tell it apart from @constraint(model, x >= y)
which was the whole point in the first place.
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 can't support
x - y in Nonnegatives()
What do you mean ? You mean x >= y, Nonnegatives()
?
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.
No I mean @constraint(model, x - y in Nonnegatives())
because this hits the same codepath as @constraint(model, x >= y)
.
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.
Unless I intercept the GreaterThan(false)
method, but then I think the last time I looked that makes ambiguities.
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.
Ah, that's the part I didn't get. It does make sense to intersect the GreaterThan
then because having AbstractArray
-in-GreaterThan
is ambiguous and shouldn't be allowed while AbstractArray
-in-Nonnegatives
should be allowed.
So neither @constraint(model, x - y in GreaterThan(false))
nor @constraint(model, x >= y)
will work.
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.
Ah. I forgot. We switched from GreaterThan(false)
to Nonnegatives
. So we can't even intercept. x >= y
is exactly equal to x - y in Nonnegatives
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.
Ouch, that was probably not ideal. Using Nonnegatives
by default kind of means we interpret >=
as elementwise by default.
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.
Maybe we could add a layer of indirection to fix that without being breaking
Let's merge this as a strict improvement for now. I can come back to the |
Merging this for now, but I'll hold off tagging a new release until I've had a go at |
Closes #3765
Documentation preview: https://jump.dev/JuMP.jl/previews/PR3766/manual/constraints/#Symmetric-matrices