Skip to content
This repository was archived by the owner on Jan 30, 2023. It is now read-only.

Commit ba54691

Browse files
author
Release Manager
committed
Trac #31253: Put equations in stable position for backend cdd
Currently, equations positions in Hrepresentation of backend `cdd` depends on the input: {{{ sage: P = polytopes.permutahedron(2, backend='cdd') sage: P.Hrepresentation() (An equation (1, 1) x - 3 == 0, An inequality (0, 1) x - 1 >= 0, An inequality (1, 0) x - 1 >= 0) sage: Q = Polyhedron(P.vertices(), backend='cdd') sage: Q.Hrepresentation() (An inequality (-1, 0) x + 2 >= 0, An inequality (1, 0) x - 1 >= 0, An equation (1, 1) x - 3 == 0) }}} This leads to the following failure: {{{ sage: [x.ambient_Hrepresentation() for x in P.facets()] [(An inequality (1, 0) x - 1 >= 0, An inequality (0, 1) x - 1 >= 0), (An inequality (1, 0) x - 1 >= 0, An equation (1, 1) x - 3 == 0)] }}} We fix this by putting equations always in the same position. URL: https://trac.sagemath.org/31253 Reported by: gh-kliem Ticket author(s): Jonathan Kliem Reviewer(s): Matthias Koeppe
2 parents badd79c + 1c6c90a commit ba54691

File tree

3 files changed

+26
-5
lines changed

3 files changed

+26
-5
lines changed

build/pkgs/configure/checksums.ini

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
tarball=configure-VERSION.tar.gz
2-
sha1=48014f7cb1b4058977e37a8a24b356b8f49cb407
3-
md5=05f179d63fdbf1d2115190e056adcb6c
4-
cksum=3494189359
2+
sha1=69e3dffde527833c504246a159deee707b293c26
3+
md5=2bc896e7c3a7188b8ff0b02eaf52cbc2
4+
cksum=1400865248
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
313fa89231831703c8da1840c71435517b72624c
1+
e18e9db0b62dbc8f531d8891de3777255769ca57

src/sage/geometry/polyhedron/backend_cdd.py

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,22 @@ def _init_from_cdd_output(self, cddout):
238238
sage: V.points()[1], R[V.points()[1]]
239239
(P(-2686.81000000000, -2084.19000000000),
240240
A 2-dimensional polyhedron in RDF^2 defined as the convex hull of 1 vertex, 1 ray, 1 line)
241+
242+
Check that :trac:`31253` is fixed::
243+
244+
sage: P = polytopes.permutahedron(2, backend='cdd')
245+
sage: P.Hrepresentation()
246+
(An inequality (0, 1) x - 1 >= 0,
247+
An inequality (1, 0) x - 1 >= 0,
248+
An equation (1, 1) x - 3 == 0)
249+
sage: Q = Polyhedron(P.vertices(), backend='cdd')
250+
sage: Q.Hrepresentation()
251+
(An inequality (-1, 0) x + 2 >= 0,
252+
An inequality (1, 0) x - 1 >= 0,
253+
An equation (1, 1) x - 3 == 0)
254+
sage: [x.ambient_Hrepresentation() for x in P.facets()]
255+
[(An equation (1, 1) x - 3 == 0, An inequality (1, 0) x - 1 >= 0),
256+
(An equation (1, 1) x - 3 == 0, An inequality (0, 1) x - 1 >= 0)]
241257
"""
242258
cddout = cddout.splitlines()
243259

@@ -271,7 +287,12 @@ def parse_H_representation(intro, data):
271287
assert self.ambient_dim() == dimension - 1, "Unexpected ambient dimension"
272288
assert len(data) == count, "Unexpected number of lines"
273289
R = self.base_ring()
274-
for i, line in enumerate(data):
290+
from itertools import chain
291+
# We add equations to the end of the Hrepresentation.
292+
for i in chain(
293+
(j for j in range(len(data)) if not j in equations),
294+
equations):
295+
line = data[i]
275296
coefficients = [R(x) for x in line]
276297
if coefficients[0] != 0 and all(e == 0 for e in coefficients[1:]):
277298
# cddlib sometimes includes an implicit plane at infinity: 1 0 0 ... 0

0 commit comments

Comments
 (0)