from pypol import *
-x, y = symbols('x y')
+a, x, y, z = symbols('a x y z')
sq1 = Le(0, x) & Le(x, 2) & Le(0, y) & Le(y, 2)
sq2 = Le(2, x) & Le(x, 4) & Le(2, y) & Le(y, 4)
-
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)
+sq7 = Le(0, x) & Le(x, 2) & Le(0, y) & Eq(z, 2) & Le(a, 3)
u = Polyhedron([])
x = sq1 - sq2
print()
print('sq6:', sq6)
print('sq6 simplified:', sq6.sample())
+print()
+print('sq7 with out constraints involving y and a', sq7.drop_dims('y a'))
return self.complement()
def simplify(self):
- # see isl_set_coalesce, isl_set_detect_equalities,
- # isl_set_remove_redundancies
- # which ones? in which order?
- raise NotImplementedError
+ #does not change anything in any of the examples
+ #isl seems to do this naturally
+ islset = self._toislset(self.polyhedra, self.symbols)
+ islset = libisl.isl_set_remove_redundancies(islset)
+ return self._fromislset(islset, self.symbols)
def polyhedral_hull(self):
# several types of hull are available
islbset = libisl.isl_set_polyhedral_hull(islset)
return Polyhedron._fromislbasicset(islbset, self.symbols)
- def project(self, symbols):
- # not sure what isl_set_project_out actually does…
- # use isl_set_drop_constraints_involving_dims instead?
- raise NotImplementedError
-
+ def drop_dims(self, dims):
+ # use to remove certain variables use isl_set_drop_constraints_involving_dims instead?
+ from .polyhedra import Polyhedron
+ dims = list(dims)
+ symbols = list(self.symbols)
+ islset = self._toislset(self.polyhedra, self.symbols)
+ for dim in dims:
+ if dim in symbols:
+ num = symbols.index(dim)
+ islbset = libisl.isl_set_drop_constraints_involving_dims(islset, libisl.isl_dim_set, num, 1)
+ return Polyhedron._fromislset(islbset, self.symbols)
+
def sample(self):
from .polyhedra import Polyhedron
islset = self._toislset(self.polyhedra, self.symbols)
def tosympy(self):
raise NotImplementedError
-
def And(*domains):
if len(domains) == 0:
from .polyhedra import Universe