Do not cast values returned by LinExpr accessors to Rational
[linpy.git] / examples / tesseract.py
1 #!/usr/bin/env python3
2
3 from linpy import *
4
5 x, y, z, t = symbols('x y z t')
6
7 tesseract = \
8 Le(0, x) & Le(x, 1) & \
9 Le(0, y) & Le(y, 1) & \
10 Le(0, z) & Le(z, 1) & \
11 Le(0, t) & Le(t, 1)
12
13 def faces(polyhedron):
14 for points in polyhedron.faces():
15 face = points[0].aspolyhedron()
16 face = face.union(*[point.aspolyhedron() for point in points[1:]])
17 face = face.aspolyhedron()
18 yield face
19
20 print('Faces of tesseract\n\n {}\n\nare:\n'.format(tesseract))
21 for face in faces(tesseract):
22 assert(len(face.vertices()) == 8)
23 print(' {}'.format(face))