Let a $2$-dimensional polytope given by the vertices $P_1=(0, -1)$, $P_2=(-1, 0)$, $P_3=(-1, 2)$, $P_4=(1, 0)$, $P_5=(1, -1)$:
When I use different libraries to obtain the half-space representation, I get 2 results. Sage for example yields upon
points = [[0,-1],[-1,0],[-1,2],[1,0],[1,-1]]
poly = Polyhedron(points)
poly.Hrepresentation()
the following, where $Ax+b\ge0, b=(1,1,1,1,1)$:
(1,0)x+1>=0
(1,1)x+1>=0
(0,1)x+1>=0
(-1,0)x+1>=0
(-1,-1)x+1>=0
The pypoman library yields upon:
V = np.array([[0, -1], [-1, 0], [-1, 2], [1, 0], [1, -1]])
A, b = compute_polytope_halfspaces(vertices)
print(A)
print(b)
the following, where $Ax+b\le0, b=(1,1,1,1,1)$ which is equivalent to the form $0\le-Ax+b$:
[[-0. -1.]
[-1. -0.]
[-1. -1.]
[ 1. 1.]
[ 1. -0.]]
[1. 1. 1. 1. 1.]
This result corresponds to the result of sage.
But when I use the polytope library as follows:
V = np.array([[0, -1], [-1, 0], [-1, 2], [1, 0], [1, -1]])
P = polytope.qhull(V)
print(P)
I get the following form $Ax\le b$ which is equivalent to pypoman's form $0\le-Ax+b$:
[[ 1. -0. ] | [[1. ]
[ 0.70711 0.70711] | [0.70711]
[-1. 0. ] x <= [1. ]
[-0. -1. ] | [1. ]
[-0.70711 -0.70711]]| [0.70711]]
My question:
Why I get these two different results, the one result of sage and pypoman and the one of the polytope library?
Both results seems to be valid, but why? What is the geometrical intuition behind this?
Validation that both results (half-space representations) are valid:
To verify that both polytopes are the same, I used the following code (based on a really helpful Stack Overflow post):
import numpy as np
import polytope
# halfspace representation computed using `polytope`
# from the vertex representation given in the question
vertices = np.array([[0, -1], [-1, 0], [-1, 2], [1, 0], [1, -1]])
poly = polytope.qhull(vertices)
# first halfspace representation
A = np.array([
[0, -1],
[-1, 0],
[-1, -1],
[1, 1],
[1, 0]])
b = np.array([1, 1, 1, 1, 1])
question_poly_1 = polytope.Polytope(A, b)
# second halfspace representation
A = np.array([
[-0.70711, -0.70711],
[-1, -0],
[0.70711, 0.70711],
[0, -1],
[1, 0]])
b = np.array([0.70711, 1, 0.70711, 1, 1])
question_poly_2 = polytope.Polytope(A, b)
# check that all the above halfspace representations
# represent the same polytope
assert poly == question_poly_1, (poly, question_poly_1)
assert poly == question_poly_2, (poly, question_poly_2)
