From: Vivien Maisonneuve Date: Wed, 20 Aug 2014 11:48:06 +0000 (+0200) Subject: Update reference examples to match the tutorial X-Git-Tag: 1.0~8 X-Git-Url: https://svn.cri.ensmp.fr/git/linpy.git/commitdiff_plain/a16251fd5fb481e97f05fd488ad718ba2147396b?ds=inline Update reference examples to match the tutorial --- diff --git a/doc/reference.rst b/doc/reference.rst index e6f291d..4a2c419 100644 --- a/doc/reference.rst +++ b/doc/reference.rst @@ -250,27 +250,27 @@ This space can be unbounded. For example, the polyhedron ``0 <= x <= 2, 0 <= y <= 2`` can be constructed with: >>> x, y = symbols('x y') - >>> square = Polyhedron([], [x, 2 - x, y, 2 - y]) - >>> square + >>> square1 = Polyhedron([], [x, 2 - x, y, 2 - y]) + >>> square1 And(0 <= x, x <= 2, 0 <= y, y <= 2) It may be easier to use comparison operators :meth:`LinExpr.__lt__`, :meth:`LinExpr.__le__`, :meth:`LinExpr.__ge__`, :meth:`LinExpr.__gt__`, or functions :func:`Lt`, :func:`Le`, :func:`Eq`, :func:`Ge` and :func:`Gt`, using one of the following instructions: >>> x, y = symbols('x y') - >>> square = (0 <= x) & (x <= 2) & (0 <= y) & (y <= 2) - >>> square = Le(0, x, 2) & Le(0, y, 2) + >>> square1 = (0 <= x) & (x <= 2) & (0 <= y) & (y <= 2) + >>> square1 = Le(0, x, 2) & Le(0, y, 2) It is also possible to build a polyhedron from a string. - >>> square = Polyhedron('0 <= x <= 2, 0 <= y <= 2') + >>> square1 = Polyhedron('0 <= x <= 2, 0 <= y <= 2') Finally, a polyhedron can be constructed from a :class:`GeometricObject` instance, calling the :meth:`GeometricObject.aspolyedron` method. This way, it is possible to compute the polyhedral hull of a :class:`Domain` instance, i.e., the convex hull of two polyhedra: - >>> square = Polyhedron('0 <= x <= 2, 0 <= y <= 2') - >>> square2 = Polyhedron('2 <= x <= 4, 2 <= y <= 4') - >>> Polyhedron(square | square2) - And(x <= 4, 0 <= x, y <= 4, 0 <= y, x <= y + 2, y <= x + 2) + >>> square1 = Polyhedron('0 <= x <= 2, 0 <= y <= 2') + >>> square2 = Polyhedron('1 <= x <= 3, 1 <= y <= 3') + >>> Polyhedron(square1 | square2) + And(0 <= x, 0 <= y, x <= y + 2, y <= x + 2, x <= 3, y <= 3) A polyhedron is a :class:`Domain` instance, and, therefore, inherits the functionalities of this class. It is also a :class:`GeometricObject` instance. @@ -328,22 +328,20 @@ Unlike polyhedra, domains allow exact computation of union, subtraction and comp Return a domain from a sequence of polyhedra. - >>> square = Polyhedron('0 <= x <= 2, 0 <= y <= 2') - >>> square2 = Polyhedron('2 <= x <= 4, 2 <= y <= 4') - >>> dom = Domain(square, square2) + >>> square1 = Polyhedron('0 <= x <= 2, 0 <= y <= 2') + >>> square2 = Polyhedron('1 <= x <= 3, 1 <= y <= 3') + >>> dom = Domain(square1, square2) >>> dom - Or(And(x <= 2, 0 <= x, y <= 2, 0 <= y), And(x <= 4, 2 <= x, y <= 4, 2 <= y)) + Or(And(x <= 2, 0 <= x, y <= 2, 0 <= y), And(x <= 3, 1 <= x, y <= 3, 1 <= y)) - It is also possible to build domains from polyhedra using arithmetic operators :meth:`Domain.__and__`, :meth:`Domain.__or__` or functions :func:`And` and :func:`Or`, using one of the following instructions: + It is also possible to build domains from polyhedra using arithmetic operators :meth:`Domain.__or__`, :meth:`Domain.__invert__` or functions :func:`Or` and :func:`Not`, using one of the following instructions: - >>> square = Polyhedron('0 <= x <= 2, 0 <= y <= 2') - >>> square2 = Polyhedron('2 <= x <= 4, 2 <= y <= 4') - >>> dom = square | square2 - >>> dom = Or(square, square2) + >>> dom = square1 | square2 + >>> dom = Or(square1, square2) Alternatively, a domain can be built from a string: - >>> dom = Domain('0 <= x <= 2, 0 <= y <= 2; 2 <= x <= 4, 2 <= y <= 4') + >>> dom = Domain('0 <= x <= 2, 0 <= y <= 2; 1 <= x <= 3, 1 <= y <= 3') Finally, a domain can be built from a :class:`GeometricObject` instance, calling the :meth:`GeometricObject.asdomain` method.