.. py:class :: Domain
- .. py:method:: symbols
+ .. attribute:: symbols
Returns a tuple of the symbols that exsist in a domain.
- .. py:method:: dimension
+ .. attribute:: dimension
Returns the number of variables that exist in a domain.
- .. py:method:: disjoint
-
- Returns a domain as disjoint.
-
- .. py:method:: involves_vars(self, dims)
-
- Returns ``True`` if a domain depends on the given dimensions.
-
.. py:method:: isempty(self)
Return ``True`` is a domain is empty.
Test whether every element in *other* is in a domain.
.. py:method:: complement(self)
- ¬self
+ ~self
Return the complement of a domain.
Return a new domain without any redundant constraints.
- .. py:method:: project(self, dims)
+ .. py:method:: project(self, variables)
- Return a new domain with the given dimensions removed.
+ Return a new domain with the given variables removed.
.. py:method:: aspolyhedron(self)
Return a single sample subset of a domain.
.. py:method:: intersection(self, other)
+ __or__
self | other
Return a new domain with the elements that are common between *self* and *other*.
.. py:method:: union(self, other)
+ __and__
self & other
Return a new domain with all the elements from *self* and *other*.
.. py:method:: difference(self, other)
+ __sub__
self - other
Return a new domain with the elements in a domain that are not in *other* .
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` method. The points, vertices, and faces of a domain can be inspected using the following functions.
.. py:method:: points(self)
.. py:method:: plot(self, plot=None, **kwargs)
- Return a plot of the given domain.
+ Return a plot of the given domain or add a plot to a plot instance.
False
>>> # compute the union of two polyhedrons
>>> square1 | square2
- Or(And(Ge(x, 0), Ge(-x + 2, 0), Ge(y, 0), Ge(-y + 2, 0)), And(Ge(x - 1, 0), Ge(-x + 3, 0), Ge(y - 1, 0), Ge(-y + 3, 0)))
+ Or(And(Ge(x, 0), Ge(-x + 2, 0), Ge(y, 0), Ge(-y + 2, 0)), \
+ And(Ge(x - 1, 0), Ge(-x + 3, 0), Ge(y - 1, 0), Ge(-y + 3, 0)))
>>> # check if square1 and square2 are disjoint
>>> square1.disjoint(square2)
False
And(Ge(x - 1, 0), Ge(-x + 2, 0), Ge(y - 1, 0), Ge(-y + 2, 0))
>>> # compute the convex union of two polyhedrons
>>> Polyhedron(square1 | sqaure2)
- And(Ge(x, 0), Ge(y, 0), Ge(-y + 3, 0), Ge(-x + 3, 0), Ge(x - y + 2, 0), Ge(-x + y + 2, 0))
+ And(Ge(x, 0), Ge(y, 0), Ge(-y + 3, 0), Ge(-x + 3, 0), \
+ Ge(x - y + 2, 0), Ge(-x + y + 2, 0))
Unary operation and properties examples:
.. py:method:: __eq__(self, other)
- Compares two Points for equality.
+ Compare two Points for equality.
.. py:method:: __add__(self, other)
- Adds a Point to a Vector and returns the result as a Point.
+ Add a Point to a Vector and return the result as a Point.
.. py:method:: __sub__(self, other)
- Returns the difference between two Points as a Vector.
+ Return the difference between two Points as a Vector.
.. py:method:: aspolyhedon(self)
- Returns a Point as a polyhedron.
+ Return a Point as a polyhedron corresponding to the Point, assuming the Point has integer coordinates.
.. py:class:: Vector
.. py:method:: __eq__(self, other)
- Compares two Vectors for equality.
+ Compare two Vectors for equality.
.. py:method:: __add__(self, other)
- Adds either a Point or Vector to a Vector. The resulting sum is returned as the same structure *other* is.
+ Add either a Point or Vector to a Vector. The resulting sum is returned as the same structure *other* is.
.. py:method:: __sub__(self, other)
.. py:method:: __mul__(self, other)
- Multiples a Vector by a scalar value and returns the result as a Vector.
+ Multiply a Vector by a scalar value and returns the result as a Vector.
.. py:method:: __neg__(self)
- Negates a Vector.
+ Negate a Vector.
.. py:method:: norm(self)
.. py:method:: cross(self, other)
- Calculate the cross product of two Vector3D structures.
+ Calculate the cross product of two Vector3D structures. If the vectors are not tridimensional, a _____ error is raised.
.. py:method:: dot(self, other)
Linear Expression Module
========================
-This class implements linear expressions.
+This class implements linear expressions. A linear expression is….
.. py:class:: Expression
Return a list of the coefficients of an expression
- .. py:method:: constant(self)
+ .. attribute:: constant
Return the constant value of an expression.
- .. py:method:: symbols(self)
+ .. attribute:: symbols
Return a list of symbols in an expression.
- .. py:method:: dimension(self)
+ .. attribute:: dimension
- Return the number of vriables in an expression.
+ Return the number of variables in an expression.
.. py:method:: __sub__(self, other)
- Return the difference between two expressions.
+ Return the difference between *self* and *other*.
.. py:method:: subs(self, symbol, expression=None)
LinPy Module Reference
======================
-There are four main LinPy modules:
+There are four main LinPy modules, all of them can be inherited at once with the LinPy package:
+
+ >>> from linpy import *
.. toctree::
:maxdepth: 2
.. py:class:: Polyhedron
- .. attribute:: equalities(self)
+ .. py:property:: equalities
- Return a list of the equalities in a polyhedron.
+ Returns a list of the equalities in a polyhedron.
- .. attribute:: inequalities(self)
+ .. py:property:: inequalities
- Return a list of the inequalities in a polyhedron.
+ Returns a list of the inequalities in a polyhedron.
- .. py:method:: constraints(self)
+ .. py:property:: constraints
- Return ta list of the constraints of a polyhedron.
+ Returns a list of the constraints of a polyhedron.
.. py:method:: disjoint(self)
.. py:method:: subs(self, symbol, expression=None)
- Subsitutes an expression into a polyhedron and returns the result.
+ Substitutes an expression into a polyhedron and returns the result.
-To create a polyhedron, the user can use the following functions to define equalities and inequalities as the contraints.
+To create a polyhedron, the user can use the following functions to define equalities and inequalities as the constraints.
.. py:function:: Eq(left, right)
- Create a constraint by setting *left* equal to *right*.
+ Returns a Polyhedron instance with a single constraint as *left* equal to *right*.
.. py:function:: Ne(left, right)
- Create a constraint by setting *left* not equal to *right*.
+ Returns a Polyhedron instance with a single constraint as *left* not equal to *right*.
.. py:function:: Lt(left, right)
- Create a constraint by setting *left* less than *right*.
+ Returns a Polyhedron instance with a single constraint as *left* less than *right*.
.. py:function:: Le(left, right)
- Create a constraint by setting *left* less than or equal to *right*.
+ Returns a Polyhedron instance with a single constraint as *left* less than or equal to *right*.
.. py:function:: Gt(left, right)
- Create a constraint by setting *left* greater than *right*.
+ Returns a Polyhedron instance with a single constraint as *left* greater than *right*.
.. py:function:: Ge(left, right)
- Create a constraint by setting *left* greater than or equal to *right*.
+ Returns a Polyhedron instance with a single constraint as *left* greater than or equal to *right*.