-
-
Notifications
You must be signed in to change notification settings - Fork 453
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
Constructions for common polyhedral cones #26623
Comments
comment:1
They certainly should take a lattice argument! From a toric perspective it is probably more natural to have these as methods of lattices, i.e. something like
although of course this makes it impossible to use
|
comment:2
Replying to @novoselt:
I think from a design standpoint, that's where the method belongs, but there are two things that bug me about it. First: in many cases, the user won't care about the lattice and will want "the default." This is basically what happens when you do Second: tab completion on (Might we have something like
My main objection to this is that I'm not smart enough to implement it or remember which cone is associated with which toric variety =) Having the code above be the implementation for |
comment:3
"A lot of the time you just don't care though" - I always care, we are just using cones for different things ;-) But you are right - just because cones are associated to lattices does not mean that they have to be methods of lattices. So I think |
comment:4
I have another question. There are a few vector spaces associated with each cone, that can be thought of as cones themselves:
The span of the cone and its lineality space are already available as,
But none of those return cones directly. Having a cone is handy when you want to compute e.g. the intersection of one of these things with some other cone. If we were to add similar methods that return cones, how would you prefer to do it? We could either...
The first one seems more correct to me, but risks polluting the namespace with a bunch of methods that all look the same but return different things. The second one does make it obvious that you're going to get a cone back, but only if people know to look there for what should in principle be a method on the cone itself. |
comment:5
Option 3: For the span and the orthogonal complement, we could sensibly add a
which would be a wrapper around
The problem with that is, when starting from a cone and passing through a vector space, the lattice information is lost. If I start with a cone in a lattice
it should live in the same lattice as the original cone. I don't see how to fix that immediately. |
comment:6
Just a reminder - orthogonality in the toric setting is handled via dual lattices:
I can't imagine use cases where I would like to treat all these spaces as cones. Can you please explain it in more details, i.e. what is wrong with treating them as, well, spaces? If you really do want to have cones associated to spaces, then you can easily attach a method to toric lattices and sublattices, or, alternatively or in addition, you can modify the But I am still unclear why would one want to turn a space into a cone, what is there to gain from such a representation? |
comment:7
Oof, it looks like I'm missing trac emails again. It would just be nice to have the cone methods available on subspaces. For example, Corollary 1 in these notes, http://michael.orlitzky.com/notes/on_z-operators_and_viability_theorems.pdf is very easy to test as the intersection of a closed convex (dual) cone and a subspace. If span(x) is a cone, and if its orthogonal complement is a cone, then I can use the cone intersection method that we already have to test it. Another example is the "maximal angle between two convex cones." This is a newish concept (from 2016), and I've implemented it as a method on cones. However, the "principal angle between subspaces" is a classical idea going back to the 1950s, and they turn out to be equivalent for cones that are subspaces. If subspaces can be treated as cones, then I can use the same method that I have on cones to compute principal angles between subspaces. And so on. The reason I think there's plenty of work to do just to get the trivial cone, nonnegative orthant, and a few others implemented and documented. I'll focus on that and worry about the other questions later. |
Commit: |
comment:8
Here's my first attempt at this. I'm open to other suggestions if you don't like the module or class names. New commits:
|
Author: Michael Orlitzky |
Branch: u/mjo/ticket/26623 |
comment:9
I am fine with the class names but the objects would better be like graphs (and many other constructors): that is in caml case like |
comment:10
Replying to @videlec:
Doesn't that violate PEP8? They're not really constructors, even though they do mimic constructors (in the sense that they would be constructors if I didn't want the |
comment:11
Please have a look at: |
comment:12
It seems that when you do specify a lattice, you also have to specify its dimension and there is a check that you do not make a mistake. It would be more pleasant to provide only one input argument: either a number to get the cone in the default lattice of that dimension, or a lattice and get a cone in that lattice. |
comment:13
Replying to @novoselt:
But that's exactly how The additional check is not strictly required; it serves only to provide a more relevant error message. For example, if I were to delete the check and then pass a lattice of the wrong rank to
If you know the generators of (say) the Schur cone, then you might be able to figure out what that error message means. But, if you don't know what those generators are off the top of your head, then an error message complaining about converting
I don't think this is workable, since in applications we often want to intersect the dual of some cone (which will live in a non-default lattice) with e.g. a nonnegative orthant.
This is the best API, but as a user-interface is pretty annoying to use. The "pass a lattice, but only if you don't want the default one" approach of
is even worse than
In the common case, the user is left wondering why he has to type |
comment:14
|
comment:15
Replying to @novoselt:
Ah, sorry I misunderstood. This sounds like a good idea. |
Branch pushed to git repo; I updated commit sha1. This was a forced push. New commits:
|
comment:17
Each method will now make an attempt to determine the ambient dimension from the lattice and vice-versa. An error is raised if they are both left unspecified, or if they disagree. I don't think it's necessary to prohibit e.g. I also added a commit on top of the others to switch to PascalCase names. My mother taught me that "everyone else is doing it" isn't a good excuse, so I'm not sold on the motivation, but it's there. I don't feel that strongly about it if I'm in the minority. |
Branch pushed to git repo; I updated commit sha1. This was a forced push. New commits:
|
comment:19
Force-pushed a rebase onto the "develop" branch to fix a conflict in |
comment:20
There seems to be a conflict with version 8.9.beta8. |
comment:35
Thanks. Overall this will be a nice improvement. A few comments for now.
+globally-available ``cones`` prefix, to create some common cones:
+
+- The nonnegative orthant,
+- the rearrangement cone of order ``p``,
+- the Schur cone,
+- the trivial cone.
- globally-available ``cones`` prefix, to create some common cones:
-
-- The nonnegative orthant
-- The rearrangement cone of order ``p``
-- The Schur cone
-- The trivial cone
|
Branch pushed to git repo; I updated commit sha1. This was a forced push. New commits:
|
comment:37
Thanks, I added the commas, and expanded the warning at the beginning of the module. As for the bots: I don't think they're complaining about
Instead, I think the bots are pointing out that There may be some clever way to delay even that import, while still retaining the name "cones" along with its tab-completion list. For example, if I give a top-level variable name to the module, and then import that object lazily... e.g. this seems to work in cone_catalog.py
if I then do
in sage/geometry/all.py. But that's veering dangerously close to "too clever" to save a few microseconds in my opinion. New commits:
|
comment:38
One could just do
I don't know if it's faster, but I don't see a disadvantage. Tab completion and everything still works. |
Branch pushed to git repo; I updated commit sha1. This was a forced push. New commits:
|
comment:40
Replying to @kliem:
Thank you! I wasted a lot of time trying to figure out how to do that. I had even written a new |
comment:41
I failing doctest, due to the fact that there is a new submodule of
|
Branch pushed to git repo; I updated commit sha1. New commits:
|
comment:43
Replying to @kliem:
Oof, fixed. The switch back to a lazy import caused that one. |
comment:44
Again many minor things.
Don't know if that is better.
- - ``ambient_dim`` -- (default: ``None``) the dimension of the
- ambient space, a nonnegative integer
-
- - ``lattice`` -- (default: ``None``) the toric lattice in which
- the cone will live
+ - ``ambient_dim`` -- (default: ``None``); the dimension of the
+ ambient space, a nonnegative integer
+
+ - ``lattice`` -- (default: ``None``); the toric lattice in which
+ the cone will live
- I = matrix.identity(ZZ,ambient_dim)
+ I = matrix.identity(ZZ, ambient_dim) - I = matrix.identity(ZZ,ambient_dim)
- M = matrix.ones(ZZ,ambient_dim) - p*I
+ I = matrix.identity(ZZ, ambient_dim)
+ M = matrix.ones(ZZ, ambient_dim) - p*I
|
Branch pushed to git repo; I updated commit sha1. New commits:
|
comment:46
Replying to @kliem:
This is actually the documented way to get sphinx to create an "em" dash in the HTML output. It's displaying correctly for me in the built docs.
Clever =) But, the extra imports are "free", so I don't think it's worth changing them around again at this point.
You are right...
Is that written down anywhere (for my future reference)? I don't care either way, I changed them to double quotes.
Hmm.. someone has updated the developer's guide without fixing the existing docstrings or mentioning it to anyone. I tried to conform to the new examples in the guide.
This one works!
Other languages/projects have a standard location to document the exceptions that can be raised, but as far as I know, we don't. We probably should. I think it's nice to mention that a function can fail in the OUTPUT docs, just to be on the safe side in case the user skips the INPUT docs. But to me it feels like the relationship between the inputs belongs in the INPUT block. My mind could be changed on this, if everyone could agree to do it consistently.
Added spacing throughout.
Thanks, I don't like that the function would silently return nonsense if you pass in e.g. |
Reviewer: Jonathan Kliem |
comment:47
Missing comma for the if ... then statement:
Otherwise, you can set it on positive review on my behalf. |
Branch pushed to git repo; I updated commit sha1. This was a forced push. New commits:
|
comment:49
Replying to @kliem:
Thanks again. I squashed this and the other recent commits into the main one. It will be nice to have this off my to-do list. |
Changed branch from u/mjo/ticket/26623-ng to |
When working with graphs, we have a nice tab-completed list of common graphs that we can construct; for example,
More and more, I find myself wishing we had the same thing for convex cones, particularly in test cases. I have constructions for all of the following and use them regularly:
trivial_cone(n)
looks a lot nicer thanCone([], ToricLattice(n))
.et cetera; I'm sure I can think of more. Each of these makes sense in any dimension
n
.I'm wondering if you think this would be a useful feature to make available as e.g.
They should all probably take a "lattice" argument too now that I think about it.
CC: @novoselt
Component: geometry
Author: Michael Orlitzky
Branch/Commit:
b2aab91
Reviewer: Jonathan Kliem
Issue created by migration from https://trac.sagemath.org/ticket/26623
The text was updated successfully, but these errors were encountered: