X-Git-Url: https://scm.cri.ensmp.fr/git/linpy.git/blobdiff_plain/0da8076d0fb7aab6c4cb61b55db4fcf3a916f588..bf0ba2bac20a5c3f288001a78275e83a0106a02a:/examples/squares.py diff --git a/examples/squares.py b/examples/squares.py index 898f765..0f4e1a5 100755 --- a/examples/squares.py +++ b/examples/squares.py @@ -5,12 +5,14 @@ from pypol import * x, y = symbols('x y') sq1 = Le(0, x) & Le(x, 2) & Le(0, y) & Le(y, 2) -sq2 = Le(1, x) & Le(x, 3) & Le(1, y) & Le(y, 3) +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) u = Polyhedron([]) +x = sq1 - sq2 print('sq1 =', sq1) #print correct square print('sq2 =', sq2) #print correct square @@ -21,16 +23,19 @@ print() print('¬sq1 =', ~sq1) #test compliment print() print('sq1 + sq1 =', sq1 + sq2) #test addition -print('sq1 + sq2 =', Polyhedron(sq1 + sq2)) -print('sq1 - sq1 =', u - u) +print('sq1 + sq2 =', Polyhedron(sq1 + sq2)) #test addition +print() +print('u + u =', u + u)#test addition +print('u - u =', u - u) #test subtraction +print() print('sq2 - sq1 =', sq2 - sq1) #test subtraction -print('sq2 - sq1 =', Polyhedron(sq2 - sq1)) -print('sq1 - sq1 =', Polyhedron(sq1 - sq1)) #test polyhedreon +print('sq2 - sq1 =', Polyhedron(sq2 - sq1)) #test subtraction +print('sq1 - sq1 =', Polyhedron(sq1 - sq1)) #test subtraction print() print('sq1 ∩ sq2 =', sq1 & sq2) #test intersection print('sq1 ∪ sq2 =', sq1 | sq2) #test union print() -print('sq1 ⊔ sq2 =', Polyhedron(sq1 | sq2)) #test convex union +print('sq1 ⊔ sq2 =', Polyhedron(sq1 | sq2)) # test convex union print() print('check if sq1 and sq2 disjoint:', sq1.isdisjoint(sq2)) #should return false print() @@ -45,10 +50,16 @@ print('is sq4 less than sq3?:', sq4.__lt__(sq3)) # test lt(), must be a strict s print() print('lexographic min of sq1:', sq1.lexmin()) #test lexmin() print('lexographic max of sq1:', sq1.lexmax()) #test lexmin() +print() print('lexographic min of sq2:', sq2.lexmin()) #test lexmax() print('lexographic max of sq2:', sq2.lexmax()) #test lexmax() print() -print('Polyhedral hull of sq1 is:', sq1.polyhedral_hull()) +print('Polyhedral hull of sq1 + sq2 is:', x.polyhedral_hull()) #test polyhedral hull, returns same + #value as Polyhedron(sq1 + sq2) print() -print('is sq1 bounded?', sq1.isbounded()) -print('is sq5 bounded?', sq5.isbounded()) +print('is sq1 bounded?', sq1.isbounded()) #unbounded should return True +print('is sq5 bounded?', sq5.isbounded()) #unbounded should return False +print() +print('sq6:', sq6) +print('sq6 simplified:', sq6.sample()) +