X-Git-Url: https://svn.cri.ensmp.fr/git/linpy.git/blobdiff_plain/27d0bac21b2bb5f5eac92064edd8a1896b67eefc..fd990941199581e977b4455345b55f841bbaa05a:/examples/squares.py diff --git a/examples/squares.py b/examples/squares.py index 7f1aa30..898f765 100755 --- a/examples/squares.py +++ b/examples/squares.py @@ -5,17 +5,50 @@ from pypol import * x, y = symbols('x y') 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) +sq2 = Le(1, x) & Le(x, 3) & Le(1, y) & Le(y, 3) -print('sq1 =', sq1) -print('sq2 =', sq2) +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) +u = Polyhedron([]) + +print('sq1 =', sq1) #print correct square +print('sq2 =', sq2) #print correct square +print('sq3 =', sq3) #print correct square +print('sq4 =', sq4) #print correct square +print('u =', u) #print correct square +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('sq2 - sq1 =', sq2 - sq1) #test subtraction +print('sq2 - sq1 =', Polyhedron(sq2 - sq1)) +print('sq1 - sq1 =', Polyhedron(sq1 - sq1)) #test polyhedreon +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() +print('check if sq1 and sq2 disjoint:', sq1.isdisjoint(sq2)) #should return false +print() +print('sq1 disjoint:', sq1.disjoint()) #make disjoint +print('sq2 disjoint:', sq2.disjoint()) #make disjoint +print() +print('is square 1 universe?:', sq1.isuniverse()) #test if square is universe +print('is u universe?:', u.isuniverse()) #test if square is universe print() -print('¬sq1 =', ~sq1) +print('is sq1 a subset of sq2?:', sq1.issubset(sq2)) #test issubset() +print('is sq4 less than sq3?:', sq4.__lt__(sq3)) # test lt(), must be a strict subset print() -print('sq1 - sq2 =', sq1 - sq2) -print('sq1 - sq2 =', Polyhedron(sq1 - sq2)) +print('lexographic min of sq1:', sq1.lexmin()) #test lexmin() +print('lexographic max of sq1:', sq1.lexmax()) #test lexmin() +print('lexographic min of sq2:', sq2.lexmin()) #test lexmax() +print('lexographic max of sq2:', sq2.lexmax()) #test lexmax() print() -print('sq1 ∩ sq2 =', sq1 & sq2) -print('sq1 ∪ sq2 =', sq1 | sq2) +print('Polyhedral hull of sq1 is:', sq1.polyhedral_hull()) print() -print('sq1 ⊔ sq2 =', Polyhedron(sq1 | sq2)) +print('is sq1 bounded?', sq1.isbounded()) +print('is sq5 bounded?', sq5.isbounded())