zonopy.batchZonotope#

class zonopy.batchZonotope(Z, dtype=None, device=None)[source]#

Bases: object

Batched 1D zonotope class

Batched form of the zonotope class. This class is used to represent a batch of zonotopes over arbitrary batch dimensions, where each zonotope in the batch is expanded to have the same number of generators.

This results in a Z\mathbf{Z} tensor of shape B1×B2××(N+1)×dB_1 \times B_2 \times \ldots \times (N+1) \times d.

Refer to the zonotope class for more details on zonotopes.

__init__(Z, dtype=None, device=None)[source]#

Initialize a batch zonotope

Parameters:
  • Z (torch.Tensor) – The Z\mathbf{Z} tensor of shape B1×B2××(N+1)×dB_1 \times B_2 \times \ldots \times (N+1) \times d.

  • dtype (torch.dtype, optional) – The data type of the batch zonotope. If None, the data type is inferred. Defaults to None.

  • device (str, optional) – The device of the batch zonotope. If None, the device is inferred. Defaults to None.

Raises:

AssertionError – If the rank of Z is less than 3.

Methods

__init__(Z[, dtype, device])

Initialize a batch zonotope

cpu()

Change the device of a batch zonotope to CPU

deleteZerosGenerators([sorted, sort])

delete zero vector generators self: <zonotope>

polygon([nan])

NOTE: this is unstable for zero generators converts a 2-d zonotope into a polygon as vertices self: <zonotope>

polytope([combs])

converts a zonotope from a G- to a H- representation P comb isDeg NOTE: there is a possibility with having nan value on the output, so you might wanna use nan_to_num() OR, just use python built-in max function instead of torch.max or np.max.

project([dim])

The projection of a batch zonotope onto the specified dimensions self: <batchZonotope> dim: <int> or <list> or <torch.Tensor> dimensions for prjection

reduce(order[, option])

slice(slice_dim, slice_pt)

slice zonotope on specified point in a certain dimension self: <zonotope> slice_dim: <torch.Tensor> or <list> or <int> , shape [] slice_pt: <torch.Tensor> or <list> or <float> or <int> , shape [] return <zonotope>

to([dtype, device])

Change the device and data type of a batch zonotope dtype: torch.float or torch.double device: 'cpu', 'gpu', 'cuda:0', ...

to_interval()

to_polyZonotope([dim, id])

convert zonotope to polynomial zonotope self: <zonotope> dim: <int>, dimension to take as sliceable return <polyZonotope>

Attributes

batch_shape

center

The center of a batch zonotope return <torch.Tensor> , shape [B1, B2, .

device

The device of a batch zonotope properties return 'cpu', 'cuda:0', or ...

dimension

The dimension of a batch zonotope return <int>, nx

dtype

The data type of a batch zonotope properties return torch.float or torch.double

generators

Generators of a batch zonotope return <torch.Tensor> , shape [B1, B2, .

n_generators

The number of generators of a batch zonotope return <int>, N

shape

The shape of vector elements (ex.

property batch_shape#
property center#

The center of a batch zonotope return <torch.Tensor> , shape [B1, B2, .. , Bb, nx]

cpu()[source]#

Change the device of a batch zonotope to CPU

deleteZerosGenerators(sorted=False, sort=False)[source]#

delete zero vector generators self: <zonotope>

return <zonotope>

property device#

The device of a batch zonotope properties return ‘cpu’, ‘cuda:0’, or …

property dimension#

The dimension of a batch zonotope return <int>, nx

property dtype#

The data type of a batch zonotope properties return torch.float or torch.double

property generators#

Generators of a batch zonotope return <torch.Tensor> , shape [B1, B2, .. , Bb, N, nx]

property n_generators#

The number of generators of a batch zonotope return <int>, N

polygon(nan=True)[source]#

NOTE: this is unstable for zero generators converts a 2-d zonotope into a polygon as vertices self: <zonotope>

return <torch.Tensor>, <torch.float64>

polytope(combs=None)[source]#

converts a zonotope from a G- to a H- representation P comb isDeg NOTE: there is a possibility with having nan value on the output, so you might wanna use nan_to_num() OR, just use python built-in max function instead of torch.max or np.max.

project(dim=[0, 1])[source]#

The projection of a batch zonotope onto the specified dimensions self: <batchZonotope> dim: <int> or <list> or <torch.Tensor> dimensions for prjection

return <batchZonotope>

reduce(order, option='girard')[source]#
property shape#

The shape of vector elements (ex. center) of a layer of a batch zonotope return <tuple>, (nx,)

slice(slice_dim, slice_pt)[source]#

slice zonotope on specified point in a certain dimension self: <zonotope> slice_dim: <torch.Tensor> or <list> or <int> , shape [] slice_pt: <torch.Tensor> or <list> or <float> or <int> , shape [] return <zonotope>

to(dtype=None, device=None)[source]#

Change the device and data type of a batch zonotope dtype: torch.float or torch.double device: ‘cpu’, ‘gpu’, ‘cuda:0’, …

to_interval()[source]#
to_polyZonotope(dim=None, id=None)[source]#

convert zonotope to polynomial zonotope self: <zonotope> dim: <int>, dimension to take as sliceable return <polyZonotope>