From: Vivien Maisonneuve Date: Tue, 19 Aug 2014 14:00:56 +0000 (+0200) Subject: Add method Polyhedron.convex_union() X-Git-Tag: 1.0~38 X-Git-Url: https://svn.cri.ensmp.fr/git/linpy.git/commitdiff_plain/f03bfa8b26b45b0ba2b47c6eadafa7787200a9c9?ds=inline;hp=c3149dd6dbf0dd296c85676fcf9f997ead2470f0 Add method Polyhedron.convex_union() --- diff --git a/doc/reference.rst b/doc/reference.rst index 18e69c0..83ee9d3 100644 --- a/doc/reference.rst +++ b/doc/reference.rst @@ -2,6 +2,7 @@ Module Reference ================ + Symbols ------- @@ -227,6 +228,7 @@ They are implemented by the :class:`Rational` class, that inherits from both :cl See the documentation of :class:`fractions.Fraction` for more information and examples. + Polyhedra --------- @@ -278,6 +280,10 @@ This space can be unbounded. The tuple of constraints, i.e., equalities and inequalities. This is semantically equivalent to: ``equalities + inequalities``. + .. method:: convex_union(polyhedron[, ...]) + + Return the convex union of two or more polyhedra. + .. method:: widen(polyhedron) Compute the *standard widening* of two polyhedra, à la Halbwachs. diff --git a/linpy/polyhedra.py b/linpy/polyhedra.py index e5e2523..50af053 100644 --- a/linpy/polyhedra.py +++ b/linpy/polyhedra.py @@ -144,6 +144,15 @@ class Polyhedron(Domain): def aspolyhedron(self): return self + def convex_union(self, *others): + """ + Return the convex union of two or more polyhedra. + """ + for other in others: + if not isinstance(other, Polyhedron): + raise TypeError('arguments must be Polyhedron instances') + return Polyhedron(self.union(*others)) + def __contains__(self, point): if not isinstance(point, Point): raise TypeError('point must be a Point instance')