0f4e1a5a8de1703f71132307c543e762bd113087
7 sq1
= Le(0, x
) & Le(x
, 2) & Le(0, y
) & Le(y
, 2)
8 sq2
= Le(2, x
) & Le(x
, 4) & Le(2, y
) & Le(y
, 4)
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
)
13 sq6
= Le(1, x
) & Le(x
, 2) & Le(1, y
) & Eq(y
, 3)
17 print('sq1 =', sq1
) #print correct square
18 print('sq2 =', sq2
) #print correct square
19 print('sq3 =', sq3
) #print correct square
20 print('sq4 =', sq4
) #print correct square
21 print('u =', u
) #print correct square
23 print('¬sq1 =', ~sq1
) #test compliment
25 print('sq1 + sq1 =', sq1
+ sq2
) #test addition
26 print('sq1 + sq2 =', Polyhedron(sq1
+ sq2
)) #test addition
28 print('u + u =', u
+ u
)#test addition
29 print('u - u =', u
- u
) #test subtraction
31 print('sq2 - sq1 =', sq2
- sq1
) #test subtraction
32 print('sq2 - sq1 =', Polyhedron(sq2
- sq1
)) #test subtraction
33 print('sq1 - sq1 =', Polyhedron(sq1
- sq1
)) #test subtraction
35 print('sq1 ∩ sq2 =', sq1
& sq2
) #test intersection
36 print('sq1 ∪ sq2 =', sq1 | sq2
) #test union
38 print('sq1 ⊔ sq2 =', Polyhedron(sq1 | sq2
)) # test convex union
40 print('check if sq1 and sq2 disjoint:', sq1
.isdisjoint(sq2
)) #should return false
42 print('sq1 disjoint:', sq1
.disjoint()) #make disjoint
43 print('sq2 disjoint:', sq2
.disjoint()) #make disjoint
45 print('is square 1 universe?:', sq1
.isuniverse()) #test if square is universe
46 print('is u universe?:', u
.isuniverse()) #test if square is universe
48 print('is sq1 a subset of sq2?:', sq1
.issubset(sq2
)) #test issubset()
49 print('is sq4 less than sq3?:', sq4
.__lt__(sq3
)) # test lt(), must be a strict subset
51 print('lexographic min of sq1:', sq1
.lexmin()) #test lexmin()
52 print('lexographic max of sq1:', sq1
.lexmax()) #test lexmin()
54 print('lexographic min of sq2:', sq2
.lexmin()) #test lexmax()
55 print('lexographic max of sq2:', sq2
.lexmax()) #test lexmax()
57 print('Polyhedral hull of sq1 + sq2 is:', x
.polyhedral_hull()) #test polyhedral hull, returns same
58 #value as Polyhedron(sq1 + sq2)
60 print('is sq1 bounded?', sq1
.isbounded()) #unbounded should return True
61 print('is sq5 bounded?', sq5
.isbounded()) #unbounded should return False
64 print('sq6 simplified:', sq6
.sample())