Intersection#

Module for the Intersection Operation.

class Intersection(geometries)[source]#

Bases: OperationInterface

Implementation of the intersection operation between of a list of domains.

Given two sets \(A\) and \(B\), define the intersection of the two sets as:

\[A \cap B = \{x \mid x \in A \land x \in B\},\]

where \(x\) is a point in \(\mathbb{R}^N\).

Initialization of the Intersection class.

Parameters:

geometries (list[DomainInterface]) – A list of instances of the DomainInterface class on which the intersection 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 intersection of the domains
>>> intersection = Intersection([ellipsoid1, ellipsoid2])
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 is False.

Returns:

True if the point is inside the domain, False otherwise.

Return type:

bool

sample(n, mode='random', variables='all')[source]#

Sampling routine.

Parameters:
  • n (int) – Number of points to sample.

  • mode (str) – Sampling method. Default is random. Available modes: random sampling, random;

  • variables (list[str]) – variables to be sampled. Default is all.

Raises:

NotImplementedError – If the sampling method is not implemented.

Returns:

Sampled points.

Return type:

LabelTensor

Example:
>>> # Create two Cartesian domains
>>> cartesian1 = CartesianDomain({'x': [0, 2], 'y': [0, 2]})
>>> cartesian2 = CartesianDomain({'x': [1, 3], 'y': [1, 3]})
>>> # Define the intersection of the domains
>>> intersection = Intersection([cartesian1, cartesian2])
>>> # Sample
>>> intersection.sample(n=5)
    LabelTensor([[1.7697, 1.8654],
                [1.2841, 1.1208],
                [1.7289, 1.9843],
                [1.3332, 1.2448],
                [1.9902, 1.4458]])
>>> len(intersection.sample(n=5)
    5