random_events.polytope
======================

.. py:module:: random_events.polytope


Exceptions
----------

.. autoapisummary::

   random_events.polytope.NoOptimalSolutionError


Classes
-------

.. autoapisummary::

   random_events.polytope.Polytope


Module Contents
---------------

.. py:exception:: NoOptimalSolutionError

   Bases: :py:obj:`Exception`


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


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

   Bases: :py:obj:`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.


   .. py:method:: from_polytope(polytope_: polytope.Polytope) -> typing_extensions.Self
      :classmethod:


      Create a polytope from a polytope object.

      :param polytope_: The polytope object.



   .. py:method:: from_2d_points(points: numpy.ndarray) -> typing_extensions.Self
      :classmethod:


      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.

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



   .. py:method:: 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.

      :param 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.

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



   .. py:method:: as_box_polytope() -> typing_extensions.Self

      :return: The polytope as box polytope.



   .. py:method:: copy()

      Return copy of this Polytope.



   .. py:method:: 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.

      :param axis: The axis to split on.
      :param value: The value to split on.

      :return: The left and right split of the polytope.



   .. py:method:: 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

      :param minimum_volume: The minimum volume (epsilon) for the approximation.

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



   .. py:method:: 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

      :return: The maximum inner box of the polytope.



   .. py:method:: to_simple_event() -> random_events.product_algebra.SimpleEvent

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



