Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Obtaining H representation from vertices flips the vertices in the one dimensional case #5

Open
DavidUmsonst opened this issue Nov 21, 2023 · 0 comments

Comments

@DavidUmsonst
Copy link

DavidUmsonst commented Nov 21, 2023

Hi,

I realized that when defining a one-dimensional polytope via its vertices and obtaining the H representation from its V representation, the vertices will be flipped.
For example, we want to define the polytope given by the inverval $[-a,b]$, where $a,b>0$, and define a polytope based on $a$ and $b$.
Then the H representation of this polytope actually describes the polytope $[-b, a]$ and not $[-a, b]$.
Furthermore, when determining the V representation after determining the H representation, the V representation will also contain the flipped vertices.

Below I provide a code snippet to reproduce the issue, where $a=0.5$ and $b=1$.

import numpy as np
import pytope as pt # tested version 0.0.5

# define vertices for the polytope [-0.5, 1]
V= np.array([[-0.5], [1]])

# define polytope by vertices
poly = pt.Polytope(V=V)
print('Vertices describing poly before determining H rep:')
print(poly._get_V().T)
poly.determine_H_rep()
# Check if vertices are in the H representation
for i in range(len(V)):
    vertex = V[i]   
    print(f"Is vertex = {vertex[0]} in the H representation of the polytope defined by [-0.5, 1]?")
    if sum(poly.A*vertex-poly.b>0)>0:
        print("No")
# check vertices after determining the H rep
print('Vertices describing poly after determining H rep:')
print(poly._get_V().T)
# check vertices after determining both the H and V rep
poly.determine_V_rep()
print('Vertices describing poly after determining H rep and V rep:')
print(poly._get_V().T)

This code will print out "No", when we check if the vertex $1$ is in the H representation of the polytope and show that the vertices are flipped when determining the V representation after the H representation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant