ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Mon, 28 Dec 2015 21:31:01 +0100Checking cone containmenthttps://ask.sagemath.org/question/31892/checking-cone-containment/I would like to check if one cone contains another cone, where the cones are convex rational polyhedral cones. I don't want to compute the intersection of two cones, because when done many times, that becomes prohibitively slow. Checking containment should be much faster. Is this possible in Sage? Thanks! Mon, 28 Dec 2015 20:59:45 +0100https://ask.sagemath.org/question/31892/checking-cone-containment/Answer by vdelecroix for <p>I would like to check if one cone contains another cone, where the cones are convex rational polyhedral cones. I don't want to compute the intersection of two cones, because when done many times, that becomes prohibitively slow. Checking containment should be much faster. Is this possible in Sage? Thanks! </p>
https://ask.sagemath.org/question/31892/checking-cone-containment/?answer=31894#post-id-31894Assuming that your cones only contains the vertex 0, you can use containment as follows
sage: def polyhedron_contains(P, Q):
....: return all(P.contains(v) for v in Q.rays())
sage: P1 = Polyhedron(rays = [(1,0,0), (0,1,0), (0,0,1)])
sage: P2 = Polyhedron(rays = [(1,2,1), (1,0,0), (1,1,1), (1,1,2)])
sage: polyhedron_contains(P1,P2)
TrueMon, 28 Dec 2015 21:31:01 +0100https://ask.sagemath.org/question/31892/checking-cone-containment/?answer=31894#post-id-31894