-
-
Notifications
You must be signed in to change notification settings - Fork 401
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
Support for skew symmetric variables #2147
Conversation
Codecov Report
@@ Coverage Diff @@
## master #2147 +/- ##
==========================================
+ Coverage 91.42% 91.46% +0.03%
==========================================
Files 42 42
Lines 4105 4122 +17
==========================================
+ Hits 3753 3770 +17
Misses 352 352
Continue to review full report at Codecov.
|
src/sd.jl
Outdated
side_dimension::Int | ||
end | ||
function reshape_vector(vectorized_form::Vector{T}, shape::SkewSymmetricMatrixShape) where T | ||
matrix = Matrix{Base.promote_type(T, _MA.promote_operation(-, T), _MA.promote_operation(zero, T))}(undef, shape.side_dimension, shape.side_dimension) |
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 breaks 80-char limit, see JuMP style guide
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.
ok
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.
Looks good, thanks ! Could you add a subsection documenting this in https://www.juliaopt.org/JuMP.jl/dev/variables/#Variables-constrained-on-creation-1 ?
Thanks, @blegat , I will update the pr and add the docs tomorrow |
So tests fail for
Not sure where to go with this? |
test/variable.jl
Outdated
@test x[1, 2] == -x[2, 1] | ||
@test iszero(x[1, 1]) | ||
@test iszero(x[2, 2]) | ||
@test model[:x] === x |
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 test for the number of variables actually added to the inner model
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'm not sure how to access those?
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.
src/sd.jl
Outdated
n = _square_side(_error, variables) | ||
set = MOI.Reals(div(n^2 - n, 2)) | ||
shape = SkewSymmetricMatrixShape(n) | ||
return VariablesConstrainedOnCreation(vectorize(variables, SkewSymmetricMatrixShape(n)), set, shape) |
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.
Here, you will ignore variables
outside the upper triangle, add a TODO for throwing error in case the user set something that does not suit the skew symmetry like we do in _vectorize_variables
Any updates on this PR? This feature could be convenient for me |
Moved to #2416 |
This is an attempt to support skew symmetric variables (#2146).
Note that the return type (affine expression) is different from the input type (variable ref) here.
Keen to hear your feedback!
Closes #2146