random_events.polytope#

Exceptions#

NoOptimalSolutionError

Exception raised when the solver does not find an optimal solution.

Classes#

Polytope

Extension of the polytope class from the polytope library.

Module Contents#

exception random_events.polytope.NoOptimalSolutionError#

Bases: Exception

Exception raised when the solver does not find an optimal solution.

class random_events.polytope.Polytope(A=np.array([]), b=np.array([]), minrep=False, chebR=0, chebX=None, fulldim=None, volume=None, vertices=None, normalize=True)#

Bases: polytope.Polytope

Extension of the polytope class from the polytope library.

This class enables conversion to simple events and provides the inner box and outer box approximation from https://cse.lab.imtlucca.it/~bemporad/publications/papers/compgeom-boxes.pdf.

classmethod from_polytope(polytope_: polytope.Polytope) typing_extensions.Self#

Create a polytope from a polytope object.

Parameters:

polytope – The polytope object.

classmethod from_2d_points(points: numpy.ndarray) typing_extensions.Self#

Create a polytope from a set of 2D points, by computing the convex hull of the points and then creating the linear inequalities from the convex hull.

Parameters:

points – A numpy array with shape (n, 2) containing the points.

inner_box_approximation(minimum_volume: float = 0.1) random_events.product_algebra.Event#

Compute an inner box approximation of the polytope.

Similar to algorithm 5.

Parameters:

minimum_volume – The minimum volume (epsilon) for the approximation.

If a box is created in the induction with lower volume than epsilon, it will not be split further.

Returns:

The inner box approximation of the polytope as a random event.

as_box_polytope() typing_extensions.Self#
Returns:

The polytope as box polytope.

copy()#

Return copy of this Polytope.

split_on_axis_value(axis: int, value: numpy.ndarray) typing_extensions.Tuple[typing_extensions.Self, typing_extensions.Self]#

Split the polytope on a specific axis and value.

Parameters:
  • axis – The axis to split on.

  • value – The value to split on.

Returns:

The left and right split of the polytope.

outer_box_approximation(minimum_volume: float = 0.1) random_events.product_algebra.Event#

Compute an outer box approximation of the polytope. This implements Algorithm 6 in https://cse.lab.imtlucca.it/~bemporad/publications/papers/compgeom-boxes.pdf

Parameters:

minimum_volume – The minimum volume (epsilon) for the approximation.

Returns:

The outer box approximation of the polytope as a random event.

maximum_inner_box() typing_extensions.Self#

Compute the maximum single inner box approximation of the polytope.

This implements Algorithm 2 in https://cse.lab.imtlucca.it/~bemporad/publications/papers/compgeom-boxes.pdf

Returns:

The maximum inner box of the polytope.

to_simple_event() random_events.product_algebra.SimpleEvent#

Convert the polytope to a simple event by using its bounding box.