Union#
Module for the Union Operation.
- class Union(geometries)[source]#
Bases:
OperationInterface
Implementation of the union operation between of a list of domains.
Given two sets \(A\) and \(B\), define the union of the two sets as:
\[A \cup B = \{x \mid x \in A \lor x \in B\},\]where \(x\) is a point in \(\mathbb{R}^N\).
Initialization of the
Union
class.- Parameters:
geometries (list[DomainInterface]) – A list of instances of the
DomainInterface
class on which the union operation is performed.- Example:
>>> # Create two ellipsoid domains >>> ellipsoid1 = EllipsoidDomain({'x': [-1, 1], 'y': [-1, 1]}) >>> ellipsoid2 = EllipsoidDomain({'x': [0, 2], 'y': [0, 2]}) >>> # Define the union of the domains >>> union = Union([ellipsoid1, ellipsoid2])
- property sample_modes#
List of available sampling modes.
- is_inside(point, check_border=False)[source]#
Check if a point is inside the resulting domain.
- Parameters:
point (LabelTensor) – Point to be checked.
check_border (bool) – If
True
, the border is considered inside the domain. Default isFalse
.
- Returns:
True
if the point is inside the domain,False
otherwise.- Return type:
- sample(n, mode='random', variables='all')[source]#
Sampling routine.
- Parameters:
- Returns:
Sampled points.
- Return type:
- Example:
>>> # Create two cartesian domains >>> cartesian1 = CartesianDomain({'x': [0, 2], 'y': [0, 2]}) >>> cartesian2 = CartesianDomain({'x': [1, 3], 'y': [1, 3]}) >>> # Define the union of the domains >>> union = Union([cartesian1, cartesian2]) >>> # Sample >>> union.sample(n=5) LabelTensor([[1.2128, 2.1991], [1.3530, 2.4317], [2.2562, 1.6605], [0.8451, 1.9878], [1.8623, 0.7102]]) >>> len(union.sample(n=5) 5