X-Git-Url: https://scm.cri.ensmp.fr/git/linpy.git/blobdiff_plain/40d0f350adb81eb15adb3aa68867aaf768358550..51e97eade63b2f4c7b500feb503436cc4a886e59:/examples/squares.py diff --git a/examples/squares.py b/examples/squares.py index e622c27..1df6e3d 100755 --- a/examples/squares.py +++ b/examples/squares.py @@ -1,5 +1,22 @@ #!/usr/bin/env python3 +""" + This file is part of Linpy. + + Linpy is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Linpy is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with Linpy. If not, see . +""" + from pypol import * a, x, y, z = symbols('a x y z') @@ -9,8 +26,11 @@ 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) +sq6 = Le(1, x) & Le(x, 2) & Le(1, y) & Le(y, 3) sq7 = Le(0, x) & Le(x, 2) & Le(0, y) & Eq(z, 2) & Le(a, 3) +p = Le(2*x+1, y) & Le(-2*x-1, y) & Le(y, 1) + + universe = Polyhedron([]) q = sq1 - sq2 e = Empty @@ -55,7 +75,7 @@ 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 + sq2 is:', q.polyhedral_hull()) #test polyhedral hull +print('Polyhedral hull of sq1 + sq2 is:', q.aspolyhedron()) #test polyhedral hull print() print('is sq1 bounded?', sq1.isbounded()) #unbounded should return True print('is sq5 bounded?', sq5.isbounded()) #unbounded should return False @@ -69,3 +89,9 @@ print() print('sq1 has {} parameters'.format(sq1.num_parameters())) print() print('does sq1 constraints involve x?', sq1.involves_dims([x])) +print() +print('the verticies for s are:', p.vertices()) +print() +print(p.plot()) + +# Copyright 2014 MINES ParisTech