Giter VIP home page Giter VIP logo

zonolab's Introduction

Welcome to zonoLAB!

Introduction

The zonoLAB toolbox is a MATLAB-based software package for generating, manipulating, and analyzing hybrid zonotopes, a set representation that is equivalent to the union of $2^N$ constrained zonotopes (i.e. convex polytopes). Hybrid zonotopes are represented in Hybrid Constrained Generator-representation (HCG-rep), with the shorthand notation $\mathcal{Z}_h = \langle G^c,G^b,c,A^c,A^b,b\rangle\subset\mathbb{R}^n$, such that

$$\mathcal{Z}_h = \lbrace z = \left[G^c \ G^b\right] \begin{bmatrix}\xi^c \atop\xi^b \end{bmatrix} + c \ | \ \begin{bmatrix}\xi^c \atop\xi^b \end{bmatrix} \in \mathcal{B}_{\infty}^{n_{g}} \times \lbrace -1,1\rbrace^{n_{b}}, \ \left[A^c \ A^b\right] \begin{bmatrix}\xi^c \atop\xi^b \end{bmatrix} = b \rbrace, $$

where:

  • $n$ denotes the dimension of the space,
  • $n_g$ denotes the number of continuous generators forming the columns of $G^c \in \mathbb{R}^{n \times n_g}$, which are multiplied by the $n_g$ factors $\xi^c \in \mathbb{R}^{n_g}$,
  • $n_b$ denotes the number of binary generators forming the columns of $G^b \in \mathbb{R}^{n \times n_b}$, which are multiplied by the $n_b$ factors $\xi^b \in \mathbb{R}^{n_b}$,
  • $n_c$ denotes the number of linear equality constraints,
  • $c\in\mathbb{R}^n$ is the center,
  • $\mathcal{B}_{\infty}^{n_{g}}$ is the $n_g$-dimensional unit hypercube such that $\mathcal{B}_{\infty}^{n_{g}} = \lbrace x \in \mathbb{R}^{n} \ | \ || x ||_\infty \leq 1 \rbrace$,
  • $\lbrace -1,1\rbrace^{n_{b}}$ is the set of all $n_{b}$-dimensional binary vectors (i.e. vertices of $\mathcal{B}_{\infty}^{n_{b}}$),
  • $A_c \in \mathbb{R}^{n_c \times n_g}$ is the continuous factor constraint coefficient matrix,
  • $A_b \in \mathbb{R}^{n_c \times n_b}$ is the binary factor constraint coefficient matrix, and
  • $b \in \mathbb{R}^{n_c}$ is the constraint offset vector.

In this toolbox, hybrid zonotopes are represented using the class hybZono. Constrained zonotopes and zonotopes can be viewed as specific cases of hybrid zonotopes and are also represented using the classes conZono and zono, respectively. All three classes inherit properties from the abstract superclass abstractZono, which contains the properties and methods commonly used by hybZono, conZono, and zono.

Installation

The zonoLab toolbox does not require installation beyond adding the folder and subfolders to the path in MATLAB. Running zonoLab_Install will automatically add all necessary folders to your MATLAB path. Additionally, it is highly recommended that Gurobi is installed and added to your MATLAB path. Information on installing Gurobi, including details on free license for academic use, can be found on the Getting Started with Gurobi Optimizer page.

Getting Started

The following code can be used to create and plot your first hybrid zonotope.

Gc = [3 -3 1; 2 1 -2];          % Continuous generator matrix
Gb = [6 -6 2; 4 2 -4];          % Binary generator matrix
c = [0;0];                      % Center
Ac = [1 1 1];                   % Continuous constraint matrix
Ab = [1 1 1];                   % Binary constraint matrix
b = 1;                          % Constraint offset vector
Zh = hybZono(Gc,Gb,c,Ac,Ab,b);  % Creates a hybrid zonotope

figure;
plot(Zh,'b',0.1)                % Plots hybrid zonotope in transparent blue

To learn more about generating hybrid zonotopes, plotting, and set-based operations, please visit the Wiki Tutorial, Functions, and Examples pages.

License

The zonoLab toolbox is distributed under the GNU General Public License (GPL). The paper provided above must be referenced when zonoLab is used in published work. This toolbox is distributed without any warranty and, therefore, the user is responsible for assessing the correctness of the software.

Cite

Please cite the following publication if you publish work based on the zonoLAB toolbox:

For general background on hybrid zonotopes, refer to the following publication:

Additional References

More information on the hybrid zonotopes and applications can be found in the following publications:

Dissertations:

zonolab's People

Contributors

jonaswagner2826 avatar jkoeln avatar jruths avatar david-gostin avatar jchenutd avatar tbird0335 avatar tannerjaykogel avatar

Stargazers

Yanyan Shi avatar  avatar  avatar Matt Boler avatar Luka Bostick avatar  avatar Yuhao Zhang avatar Sam Akinwande avatar Tadashi avatar Hongliang Li avatar Josh Robbins avatar loizoshad avatar

Watchers

Tadashi avatar  avatar Herschel Pangborn avatar  avatar

zonolab's Issues

Minor typo

In hybZono.m, line 97, there is a capitalization typo for the function call "vPoly2hybZono"; the function in the toolbox is defined with lowercase "v", but this line calls capital "V".

The following code snippet should highlight the issue:

hybZono({eye(2),[1;1]})

vertex set to conZono?

I think maybe there is room for a vertex set to conZono function? Right now the vPoly2hybZono works but is not the most minimal solution we could find...

Requested functionality in supportFunc

In the old toolbox, when calling the support function on an n-dimensional hybrid zonotope, you could input a matrix of size [N n] to perform N support functions in one call. At the moment, zonoLAB only lets you input a [n 1].

Comparing Trevor's old function "supportFn" with the zonoLAB "supportFunc", it looks like this can be achieved by just doing a for-loop in the supportFunc to go through all N of the support vector directions.

3D plotting

NN_plotting_debug.zip

The attached zip file includes a matlab script and mat file. The hybZono representation of the neural network is plotting oddly. When plotted using slices, it seems like the hybZono looks like it should, so I think the issue is in the plotting. It does seem to recognize that the plot is a planar object in 3D.

ZonoLab GetLeaves Produces Infeasible Leaves

The getLeaves command will have leaves with values other than -1 or 1 as below,

image

These leaves will produce faces on the surface that are either lines or points but realtive to the reLU activations these leaves are repeated. Suggested fix is adding in the following line of code to zonoLAB/globalFunctions/solvMILP.m, "params.IntFeasTol = 1e-5;" and changing the tolerance. as below,

image

fix reduces the number of non -1 or 1s.

plotConZono2D

plotting the conZono in the attached mat file demonstrates an issue in the 2D plotting.

I found this example showed the issue when the variables indx=5 and i=11. At this iteration in the loop, a new direction is identified (angle 1.9874). In the previous iteration (still at indx=5) a direction 1.7059 was identified and added.

Old and new vertOrder, showing the new vertex at angle 1.9874 is placed "next" (after indx 5):
image

even though it is larger than the next angle at 1.7059:
image

It seems the issue is that the new directions and vertex are always placed next in the order after the vertOrder(indx) spot. I think the issue is on lines 126-127 where the order in the tree is always given as the next one, i.e., indx+1, when in fact it should be indx+something, depending on whether multiple new directions have been added since indx was last incremented?
image

conZono_2D_plotting_issue.zip

Expose tolerances for plotConZono2D

We came across a conZono that took a long time (over 5 min?) to plot with the current tolerance on line 105 (10^-6). By changing it to 10^-5 it plotted very quickly. So it would be nice to expose that tolerance to the user for adjustable levels of fidelity.

Multiple Faces returned from one conZono

Code for plotConZono3D returns multiple faces from one conZono when small planes are used to calculate the coPlanar portion of the function. Below is the code from plotConZono3D beginning at line 110.

% Continue if set is not a line segment in 3D indxPairs = [1 2; 1 3; 1 4; 2 3; 2 4; 3 4]; coPlanar = zeros(6,1); for i = 1:6 coPlanar(i) = abs(det([foundVerts(2,:)-foundVerts(1,:);extreme(indxPairs(i,1),:)-foundVerts(1,:);extreme(indxPairs(i,2),:)-foundVerts(1,:)])) <= 1e-6; end if min(coPlanar) == 1 % A planar set in 3D

Small tolerances causes points to be observed at 3-simplexes producing more faces than needed. increasing tolerance treshold mitigates the issue slightly.

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.