Opened 5 years ago

Last modified 2 weeks ago

#21255 new enhancement

Categories for Cones

Reported by: mkoeppe Owned by:
Priority: major Milestone: sage-9.5
Component: categories Keywords:
Cc: tscrim, novoselt, nthiery Merged in:
Authors: Reviewers:
Report Upstream: N/A Work issues:
Branch: Commit:
Dependencies: Stopgaps:

Status badges

Description

Right now a Cone is not a parent, and it does not have a specific category.

sage: C = Cone([[1,0], [1,5]])
sage: C.category()
Category of objects

I am wondering whether suitable categories, such as SemiModules (here, using the monoid of nonnegative integers), Cones (nonnegative reals), ... should be set up. This category framework should then be general enough to represent other (non-polyhedral) cones, such as the cone of convex functions of a real variable; the cone of semidefinite matrices; etc.

Also, there should be a method to create the affine semigroup of the integer points in a cone (its generators are computed by the method semigroup_generators) as a monoid.

Change History (13)

comment:1 follow-up: Changed 5 years ago by tscrim

You can do more than 1 category, i.e. create a subcategory for polyhedral cones. However, right now we unfortunately have (very) limited support for categories with just objects (those that don't fit into the Parent-Element setup) (unless I am forgetting something, Nicolas?). So you might run into this technical limitation if you wanted to pull generic object code into the category, unless you are thinking of making cones a parent with an element class? Nevertheless, there could likely be code for morphisms and functors you could be able to apply.

comment:2 in reply to: ↑ 1 Changed 5 years ago by mkoeppe

Replying to tscrim:

[...] unless you are thinking of making cones a parent with an element class?

That's part of what I am trying to figure out. Likewise, for polyhedra and the points contained in them - there is also no parent/element relationship at the moment.

comment:3 follow-up: Changed 5 years ago by novoselt

But points of a cone/polyhedron are elements of a vector space parent. Do you want to wrap them up for the sake of points knowing that they belong to a certain cone? With different instances for the same point belonging to different cones? The setup for toric cones etc. was that generating points are shared between related structures, as in they are the same objects to decrease memory consumption and increase speed of construction.

comment:4 in reply to: ↑ 3 ; follow-up: Changed 5 years ago by mkoeppe

Replying to novoselt:

But points of a cone/polyhedron are elements of a vector space parent. Do you want to wrap them up for the sake of points knowing that they belong to a certain cone? With different instances for the same point belonging to different cones? The setup for toric cones etc. was that generating points are shared between related structures, as in they are the same objects to decrease memory consumption and increase speed of construction.

Thanks for sharing this perspective and background. However it seems that it is a goal in Sage that "every set should be a parent". Perhaps Facade sets can help to reconcile this goal and the goal of efficiency?

comment:5 in reply to: ↑ 4 ; follow-up: Changed 5 years ago by novoselt

Replying to mkoeppe:

Thanks for sharing this perspective and background. However it seems that it is a goal in Sage that "every set should be a parent".

Can you please clarify "seems"? Do we have some written policy/recommendation for this? Does it cover subsets of bigger sets? I.e. if I have a bunch of subsets of some set S, should elements of each of these subsets have different parents rather than S? Seems quite odd to me. What about parents for operations? Should adding two points belonging to two cones result in constructing the Minkowski sum cone where the result is guaranteed to live???

comment:6 in reply to: ↑ 5 Changed 5 years ago by mkoeppe

Replying to novoselt:

Replying to mkoeppe:

Thanks for sharing this perspective and background. However it seems that it is a goal in Sage that "every set should be a parent".

Can you please clarify "seems"? Do we have some written policy/recommendation for this?

I'm afraid the project is a bit short on policies. It's what I gathered from reading http://doc.sagemath.org/html/en/reference/categories/sage/categories/primer.html, https://trac.sagemath.org/wiki/CategoriesRoadMap etc. and looking at various examples such as posets.

Hoping that people familiar with the category framework can help to clarify.

Does it cover subsets of bigger sets? I.e. if I have a bunch of subsets of some set S, should elements of each of these subsets have different parents rather than S? Seems quite odd to me.

It's already the case as soon as the subsets have enough (algebraic) structure. Example, for point lattices:

sage: L1 = (QQ^2).span([[1, 6], [1,0]], ZZ)
sage: L2 = (QQ^2).span([[1, 3], [1,0]], ZZ)
sage: L1.0
(1, 0)
sage: L2.0
(1, 0)
sage: L1.0 == L2.0
True
sage: L1.0.parent()

Free module of degree 2 and rank 2 over Integer Ring
Echelon basis matrix:
[1 0]
[0 6]
sage: L2.0.parent()

Free module of degree 2 and rank 2 over Integer Ring
Echelon basis matrix:
[1 0]
[0 3]

I guess in the end the question is: Do cones have enough structure to warrant similar behavior? The category- and axiom-based inheritance of methods, including _test_* methods, seems quite attractive to me, and it would be nice if cones could benefit from this infrastructure.

What about parents for operations? Should adding two points belonging to two cones result in constructing the Minkowski sum cone where the result is guaranteed to live???

It sounds a bit excessive, but that matches the sound of the word "pushout".

comment:7 follow-up: Changed 5 years ago by tscrim

If you want to consider a cone is considered as a set of objects (i.e., an object in a concrete category), then it should be a Parent and the elements should be a subclass of Element. If you want to consider them in some objects in a non-concrete category, then I think they should just be a CategoryObject (where we would need to add support for ObjectMethods, but you can work around this for now with an ABC). Be warned, we have yet to really include non-concrete categories, so you are wondering into the wilderness here.

A facade parent P is for when the elements of P would more naturally belong to another parent, but you want to construct them through P.

However, it seems the idea is to consider cones as a vector space but over a semiring (more explicitly, an additive monoid with a distributive multiplicative structure). Perhaps a more simple question, is every module over a (commutative?) ring/field a cone?

The pushout construction of Sage should work well if you do want to have compatible arithmetic and coercion.

comment:8 Changed 5 years ago by novoselt

I am all for extra features and functionality, especially implemented by others, as long as it does not severely harm "usual" usage. Constructing Minkowski sum of cones when adding a couple of vectors does not sound reasonable to me as it is a very expensive operation for non-trivial cones.

comment:9 in reply to: ↑ 7 Changed 5 years ago by mkoeppe

Replying to tscrim:

However, it seems the idea is to consider cones as a vector space but over a semiring (more explicitly, an additive monoid with a distributive multiplicative structure). Perhaps a more simple question, is every module over a (commutative?) ring/field a cone?

One would take the nonnegative elements of an ordered field, not an arbitrary commutative ring. They form a semiring. The (semi)modules over this semiring would be a cone.

A non-example, the nonnegative integer vectors of RR^2 would not form a cone because they are merely a semimodule over Z_+ , not an ordered field (equivalently, an additive monoid).

comment:10 Changed 13 months ago by mkoeppe

  • Milestone set to sage-9.2

comment:11 Changed 12 months ago by mkoeppe

  • Milestone changed from sage-9.2 to sage-9.3

comment:12 Changed 6 months ago by mkoeppe

  • Milestone changed from sage-9.3 to sage-9.4

Setting new milestone based on a cursory review of ticket status, priority, and last modification date.

comment:13 Changed 2 weeks ago by mkoeppe

  • Milestone changed from sage-9.4 to sage-9.5
Note: See TracTickets for help on using tickets.