Skip to content

Define dimension for AbstractScalarSet, add some tests. #342

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

Merged
merged 2 commits into from
Jun 14, 2018

Conversation

tkoolen
Copy link
Contributor

@tkoolen tkoolen commented May 1, 2018

No description provided.

@codecov-io
Copy link

codecov-io commented May 1, 2018

Codecov Report

Merging #342 into master will increase coverage by 1.81%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #342      +/-   ##
==========================================
+ Coverage    94.6%   96.42%   +1.81%     
==========================================
  Files          34       35       +1     
  Lines        4673     4725      +52     
==========================================
+ Hits         4421     4556     +135     
+ Misses        252      169      -83
Impacted Files Coverage Δ
src/sets.jl 100% <100%> (+21.87%) ⬆️
src/Test/UnitTests/unit_tests.jl 100% <0%> (ø)
src/Utilities/model.jl 98.71% <0%> (+0.02%) ⬆️
src/Test/UnitTests/objectives.jl 100% <0%> (+50%) ⬆️
src/Test/UnitTests/variables.jl 75.67% <0%> (+50.67%) ⬆️
src/Test/UnitTests/constraints.jl 100% <0%> (+100%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 9948a72...15c4246. Read the comment docs.

Copy link
Member

@mlubin mlubin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This reminds me of matlab's treatment of scalars (i.e., as 1x1 matrices) so it's a bit unsettling, but I don't have a more substantial objection than that so, ok with me.

src/sets.jl Outdated
"""
dimension(s::AbstractSet)

Return the underlying dimension (number of vector components) in the set `s`, i.e.,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"number of vector components" doesn't quite make sense anymore. Please clarify the definition.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, yeah, what should it be?

Typically, mathematical definitions of dimension refer to an intrinsic property of a space (e.g. a vector space). Dimension isn't defined for arbitrary sets. In addition, for AbstractSet there are cases like PositiveSemidefiniteConeTriangle and PositiveSemidefiniteConeSquare where the number we want to return is not the dimension of the vector space to which a given member of the set belongs: same mathematical object (a member of $S^n_+$), two different dimensions.

So I guess concrete AbstractSet subtypes implicitly define some particular vector space that is used to parameterize members of the set and the AbstractSet's dimension is the dimension of that vector space. (Note by the way that the real line is in fact a vector space, and as such it has a well-defined dimension.)

So how about:

The dimension of the vector space used to parameterize members of s.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alternatively, it is equal to the dimension that an AbstractFunction should have to be used with the set. Then the dimension of an AbstractFunction is 1 for scalar function and the number of rows for a vector function.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whichever you want, just let me know and I'll change it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the link with the function is simpler, the vector space might be ambiguous for cases like PSDCTriangle

src/sets.jl Outdated
@@ -184,7 +188,7 @@ dimension(s::Union{ExponentialCone, DualExponentialCone, PowerCone, DualPowerCon

The (vectorized) cone of symmetric positive semidefinite matrices, with side length `dimension` and with off-diagonals unscaled.
The entries of the upper triangular part of the matrix are given column by column (or equivalently, the entries of the lower triangular part are given row by row).
An ``dimension \\times dimension`` matrix has ``dimension(dimension+1)/2`` lower-triangular elements, so for the vectorized cone of dimension ``n``, the corresponding symmetric matrix has side dimension ``\\sqrt{1/4 + 2 n} - 1/2`` elements.
An ``dimension \\times dimension`` matrix has ``dimension * (dimension+1)/2`` lower-triangular elements, so for the vectorized cone of dimension ``n``, the corresponding symmetric matrix has side dimension ``\\sqrt{1/4 + 2 n} - 1/2`` elements.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As we use double backquote, we are in LaTeX mode. In LaTeX, I prefer \cdot or \times or nothing over *. Here \times would be ambiguous with matrix dimensions so \cdot seems more appropriate

@tkoolen
Copy link
Contributor Author

tkoolen commented May 7, 2018

Updated the docstring.

@blegat blegat merged commit cc56507 into jump-dev:master Jun 14, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

4 participants