898f76546fdbf6ac7fac4c200f1f96d68e2f638e
7 sq1
= Le(0, x
) & Le(x
, 2) & Le(0, y
) & Le(y
, 2)
8 sq2
= Le(1, x
) & Le(x
, 3) & Le(1, y
) & Le(y
, 3)
10 sq3
= Le(0, x
) & Le(x
, 3) & Le(0, y
) & Le(y
, 3)
11 sq4
= Le(1, x
) & Le(x
, 2) & Le(1, y
) & Le(y
, 2)
12 sq5
= Le(1, x
) & Le(x
, 2) & Le(1, y
)
15 print('sq1 =', sq1
) #print correct square
16 print('sq2 =', sq2
) #print correct square
17 print('sq3 =', sq3
) #print correct square
18 print('sq4 =', sq4
) #print correct square
19 print('u =', u
) #print correct square
21 print('¬sq1 =', ~sq1
) #test compliment
23 print('sq1 + sq1 =', sq1
+ sq2
) #test addition
24 print('sq1 + sq2 =', Polyhedron(sq1
+ sq2
))
25 print('sq1 - sq1 =', u
- u
)
26 print('sq2 - sq1 =', sq2
- sq1
) #test subtraction
27 print('sq2 - sq1 =', Polyhedron(sq2
- sq1
))
28 print('sq1 - sq1 =', Polyhedron(sq1
- sq1
)) #test polyhedreon
30 print('sq1 ∩ sq2 =', sq1
& sq2
) #test intersection
31 print('sq1 ∪ sq2 =', sq1 | sq2
) #test union
33 print('sq1 ⊔ sq2 =', Polyhedron(sq1 | sq2
)) #test convex union
35 print('check if sq1 and sq2 disjoint:', sq1
.isdisjoint(sq2
)) #should return false
37 print('sq1 disjoint:', sq1
.disjoint()) #make disjoint
38 print('sq2 disjoint:', sq2
.disjoint()) #make disjoint
40 print('is square 1 universe?:', sq1
.isuniverse()) #test if square is universe
41 print('is u universe?:', u
.isuniverse()) #test if square is universe
43 print('is sq1 a subset of sq2?:', sq1
.issubset(sq2
)) #test issubset()
44 print('is sq4 less than sq3?:', sq4
.__lt__(sq3
)) # test lt(), must be a strict subset
46 print('lexographic min of sq1:', sq1
.lexmin()) #test lexmin()
47 print('lexographic max of sq1:', sq1
.lexmax()) #test lexmin()
48 print('lexographic min of sq2:', sq2
.lexmin()) #test lexmax()
49 print('lexographic max of sq2:', sq2
.lexmax()) #test lexmax()
51 print('Polyhedral hull of sq1 is:', sq1
.polyhedral_hull())
53 print('is sq1 bounded?', sq1
.isbounded())
54 print('is sq5 bounded?', sq5
.isbounded())