15aed1699bb7eda9f1d8659041ebf4a4a049ba0a
3 # This is the code example used in the tutorial. It shows how to define and
4 # manipulate polyhedra.
9 class InteractiveConsole(code
.InteractiveConsole
):
10 def push(self
, line
=''):
13 return super().push(line
)
18 if __name__
== '__main__':
20 shell
= InteractiveConsole()
22 shell
.push('from linpy import *')
23 shell
.push("x, y = symbols('x y')")
26 shell
.push('square1 = Le(0, x, 2) & Le(0, y, 2)')
30 shell
.push("square2 = Polyhedron('1 <= x <= 3, 1 <= y <= 3')")
34 shell
.push('inter = square1.intersection(square2)')
38 shell
.push('hull = square1.convex_union(square2)')
42 shell
.push('square1.project([y])')
45 shell
.push('inter <= square1')
46 shell
.push('inter == Empty')
49 shell
.push('union = square1 | square2')
51 shell
.push('union <= hull')
54 shell
.push('diff = square1 - square2')
56 shell
.push('~square1')