sq3 = Le(0, x) & Le(x, 3) & Le(0, y) & Le(y, 3)
sq4 = Le(1, x) & Le(x, 2) & Le(1, y) & Le(y, 2)
sq5 = Le(1, x) & Le(x, 2) & Le(1, y)
-sq6 = Le(1, x) & Le(x, 2) & Le(1, y) & Eq(y, 3)
+sq6 = Le(1, x) & Le(x, 2) & Le(1, y) & Le(y, 3)
sq7 = Le(0, x) & Le(x, 2) & Le(0, y) & Eq(z, 2) & Le(a, 3)
+p = Le(2*x+1, y) & Le(-2*x-1, y) & Le(y, 1)
+
+
universe = Polyhedron([])
q = sq1 - sq2
e = Empty
print('sq1 has {} parameters'.format(sq1.num_parameters()))
print()
print('does sq1 constraints involve x?', sq1.involves_dims([x]))
+print()
+print('the verticies for s are:', p.vertices())
+print()
+print(p.plot())
points = {}
num = 0
vertices_points = []
- symbols = list(self.symbols)
for vertex in vertices:
- expr = libisl.isl_vertex_get_expr(vertex); #make vertices a bset
if islhelper.isl_version < '0.13':
+ expr = libisl.isl_vertex_get_expr(vertex)
constraints = islhelper.isl_basic_set_constraints(expr) #get bset constraints
- for dim in symbols:
- index = symbols.index(dim)
- for c in constraints: #for each constraint
- constant = libisl.isl_constraint_get_constant_val(c) #get contant value
+ for index, dim in enumerate(self.symbols):
+ for c in constraints: #for each constraint
+ constant = libisl.isl_constraint_get_constant_val(c) #get constant value
constant = islhelper.isl_val_to_int(constant)
coefficient = libisl.isl_constraint_get_coefficient_val(c,libisl.isl_dim_set, index)
coefficient = islhelper.isl_val_to_int(coefficient) #get coefficient
if coefficient != 0:
- num = Fraction(constant, coefficient)
- points.update({dim:num})
- vertices_points.append(points)
- print(points)
-
+ num = -Fraction(constant, coefficient)
+ points[dim]= float(num)
+ vertices_points.append(points.copy())
else:
points = []
string = islhelper.isl_multi_aff_to_str(expr)
+
import functools
import numbers
from . import islhelper
from .islhelper import mainctx, libisl
-from .linexprs import Expression, Rational
+from .linexprs import Expression, Symbol, Rational
from .domains import Domain
for inequality in self.inequalities:
constraints.append(sympy.Ge(inequality.tosympy(), 0))
return sympy.And(*constraints)
+
+ def plot(self):
+ import matplotlib.pyplot as plt
+ from matplotlib.path import Path
+ import matplotlib.patches as patches
+
+ if len(self.symbols)> 3:
+ raise TypeError
+
+ elif len(self.symbols) == 2:
+ verts = self.vertices()
+ points = []
+ codes = [Path.MOVETO]
+ for vert in verts:
+ pairs = ()
+ for sym in sorted(vert, key=Symbol.sortkey):
+ num = vert.get(sym)
+ pairs = pairs + (num,)
+ points.append(pairs)
+ points.append((0.0, 0.0))
+ num = len(points)
+ while num > 2:
+ codes.append(Path.LINETO)
+ num = num - 1
+ else:
+ codes.append(Path.CLOSEPOLY)
+ path = Path(points, codes)
+ fig = plt.figure()
+ ax = fig.add_subplot(111)
+ patch = patches.PathPatch(path, facecolor='blue', lw=2)
+ ax.add_patch(patch)
+ ax.set_xlim(-5,5)
+ ax.set_ylim(-5,5)
+ plt.show()
+
+ elif len(self.symbols)==3:
+ return 0
+
+ return points
def _polymorphic(func):