From: Danielle Bolan Date: Fri, 8 Aug 2014 15:47:55 +0000 (+0200) Subject: Update plot examples X-Git-Tag: 1.0~82 X-Git-Url: https://scm.cri.mines-paristech.fr/git/linpy.git/commitdiff_plain/997e3c68590b274c372a6785cda5a69887683891?hp=2baf863a42cd79849834f7d8ad4d4f428929e3d1 Update plot examples --- diff --git a/doc/domain.rst b/doc/domain.rst index 4cd79d9..edf8934 100644 --- a/doc/domain.rst +++ b/doc/domain.rst @@ -3,8 +3,6 @@ Domains Module .. py:class :: Domain - The properties of a domain can be are found using the following - .. py:method:: symbols Returns a tuple of the symbols that exsist in a domain. @@ -21,8 +19,6 @@ Domains Module Returns ``True`` if a domain depends on the given dimensions. - The unary properties of a domain can be inspected using the following methods. - .. py:method:: isempty(self) Return ``True`` is a domain is empty. @@ -39,8 +35,6 @@ Domains Module It is not guarenteed that a domain is disjoint. If it is necessary, this method will return a domain as disjoint. - The following methods compare two domains to find the binary properties. - .. py:method:: isdisjoint(self, other) Return ``True`` if the intersection of *self* and *other* results in an empty set. @@ -74,9 +68,6 @@ Domains Module Test whether every element in *other* is in a domain. - - The following methods implement unary operations on a domain. - .. py:method:: complement(self) ¬self @@ -98,8 +89,6 @@ Domains Module Return a single sample subset of a domain. - The following methods implement binary operations on two domains. - .. py:method:: intersection(self, other) self | other @@ -120,8 +109,6 @@ Domains Module Return the sum of two domains. - The following methods use lexicographical ordering to find the maximum or minimum element in a domain. - .. py:method:: lexmin(self) Return a new set containing the lexicographic minimum of the elements in the set. @@ -131,7 +118,7 @@ Domains Module Return a new set containing the lexicographic maximum of the elements in the set. - A 2D or 3D domain can be plotted using the :meth:`plot` function. The points, verticies, and faces of a domain can be inspected using the following functions. +A 2D or 3D domain can be plotted using the :meth:`plot` function. The points, verticies, and faces of a domain can be inspected using the following functions. .. py:method:: points(self) diff --git a/doc/examples.rst b/doc/examples.rst index 62a7dfd..13c59fc 100644 --- a/doc/examples.rst +++ b/doc/examples.rst @@ -18,16 +18,16 @@ Basic Examples >>> #test equality >>> square1 == square2 False - >>> # find the union of two polygons - >>> square1 + square2 + >>> # compute the union of two polygons + >>> square1 | square2 Or(And(Ge(x, 0), Ge(-x + 2, 0), Ge(y, 0), Ge(-y + 2, 0)), And(Ge(x - 2, 0), Ge(-x + 4, 0), Ge(y - 2, 0), Ge(-y + 4, 0))) >>> # check if square1 and square2 are disjoint >>> square1.disjoint(square2) False - >>> # find the intersection of two polygons + >>> # compute the intersection of two polygons >>> square1 & square2 And(Eq(y - 2, 0), Eq(x - 2, 0)) - >>> # find the convex union of two polygons + >>> # compute the convex union of two polygons >>> Polyhedron(square1 | sqaure2) And(Ge(x, 0), Ge(-x + 4, 0), Ge(y, 0), Ge(-y + 4, 0), Ge(x - y + 2, 0), Ge(-x + y + 2, 0)) @@ -39,6 +39,7 @@ Basic Examples (x, y) >>> square1.inequalities (x, -x + 2, y, -y + 2) + >>> # project out the variable x >>> square1.project([x]) And(Ge(-y + 2, 0), Ge(y, 0)) @@ -70,4 +71,26 @@ Plot Examples [Point({x: Fraction(0, 1), y: Fraction(1, 1)}), Point({x: Fraction(-1, 1), y: Fraction(0, 1)}), Point({x: Fraction(1, 1), y: Fraction(0, 1)}), Point({x: Fraction(0, 1), y: Fraction(-1, 1)})] >>> diamond.points() [Point({x: -1, y: 0}), Point({x: 0, y: -1}), Point({x: 0, y: 0}), Point({x: 0, y: 1}), Point({x: 1, y: 0})] + + The user also can pass another plot to the :meth:`plot` method. This can be useful to compare two polyhedrons on the same axis. This example illustrates the union of two squares. + + >>> from linpy import * + >>> import matplotlib.pyplot as plt + >>> from matplotlib import pylab + >>> x, y = symbols('x y') + >>> square1 = Le(0, x) & Le(x, 2) & Le(0, y) & Le(y, 2) + >>> square2 = Le(1, x) & Le(x, 3) & Le(1, y) & Le(y, 3) + >>> fig = plt.figure() + >>> plot = fig.add_subplot(1, 1, 1, aspect='equal') + >>> square1.plot(plot, facecolor='red', alpha=0.3) + >>> square2.plot(plot, facecolor='blue', alpha=0.3) + >>> squares = Polyhedron(square1 + square2) + >>> squares.plot(plot, facecolor='blue', alpha=0.3) + >>> pylab.show() + + .. figure:: images/union.jpg + :align: center + + + diff --git a/doc/images/union.jpg b/doc/images/union.jpg new file mode 100644 index 0000000..7d14ae8 Binary files /dev/null and b/doc/images/union.jpg differ diff --git a/doc/linexpr.rst b/doc/linexpr.rst index 4101252..2aab652 100644 --- a/doc/linexpr.rst +++ b/doc/linexpr.rst @@ -3,6 +3,9 @@ Linear Expression Module This class implements linear expressions. +.. py:class:: Expression + + .. py:method:: coefficient(self, symbol) Return the coefficient value of the given symbol. @@ -38,6 +41,9 @@ This class implements linear expressions. .. py:method:: tosympy(self) Return an expression as a sympy object. + +.. py:class:: Symbol(Expression) + .. py:class:: Dummy(Symbol) diff --git a/doc/polyhedra.rst b/doc/polyhedra.rst index 736cff6..47462a7 100644 --- a/doc/polyhedra.rst +++ b/doc/polyhedra.rst @@ -3,7 +3,7 @@ Polyhedra Module .. py:class:: Polyhedron - Polyhedron class allows users to build and inspect polyherons. The following methods provide the properties of a polyhedron. + Polyhedron class allows users to build and inspect polyherons. .. py:method:: equalities(self) @@ -17,8 +17,6 @@ Polyhedra Module Return ta list of the constraints of a polyhedron. - The following unary operations can be used to inspect a polyhedron. - .. py:method:: disjoint(self) Returns a polyhedron as a disjoint.