Giter Site home page Giter Site logo

pytope's Introduction

pytope

Package with a limited set of operations for polytopes, zonotopes, and invariant sets.

The currently implemented features include

  • constructing polytopes from inequalities (halfspace representation), vertices, and upper and lower bounds,
  • linear mapping (multiplying a matrix M and a polytope P: M P),
  • the Minkowski sum and Pontryagin difference of polytopes,
  • the intersection of polytopes, and
  • simple plotting.

The figures below are generated with pytope. The first two illustrate some of the currently implemented operations (see demo.py); the third uses pytope to plot a robust MPC trajectory (obtained with CasADi), combining Figures 1 and 2 from Mayne et al. (2005) with a rough approximation of the disturbance sequence; the fourth shows an outer ε-approximation of a minimal robust positively invariant, or MRPI, set computed with pytope, reproducing the example from Raković et al. (2005).

pytope is experimental, fragile, largely untested, and probably buggy.

Illustration of various polytope operations
Figure: Illustration of various polytope operations.

The Minkowski sum of two polytopes
Figure: The Minkowski sum of two polytopes.

Robust MPC trajectory from Mayne et al. (2005)
Figure: Robust MPC trajectory from Mayne et al. (2005), combining Figures 1 and 2.

Outer ε-approximation of a minimal RPI
Figure: Outer ε-approximation of a minimal robust positively invariant (MRPI) set – a reproduction of the example in Raković et al. (2005).

References

pytope's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

pytope's Issues

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

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.

Pip version

Hello Tor,

We've been using your library in safe-control-gym for implementing robust tube MPC among other things.
Would you mind updating the pipy package to be version 0.0.5?
We would greatly appreciate it!
There's a couple features that you added in your latest release that we need and we'd like to avoid having to git clone and pip install from source.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.