Exclusion#

Module for Exclusion class.

class Exclusion(geometries)[source]#

Bases: OperationInterface

PINA implementation of Exclusion of Domains. Given two sets \(A\) and \(B\) then the domain difference is defined as:

\[A \setminus B = \{x \mid x \in A \land x \in B \land x \not\in (A \lor B)\},\]

with \(x\) a point in \(\mathbb{R}^N\) and \(N\) the dimension of the geometry space.

Parameters:

geometries (list) – A list of geometries from pina.geometry such as EllipsoidDomain or CartesianDomain.

Example:
>>> # Create two ellipsoid domains
>>> ellipsoid1 = EllipsoidDomain({'x': [-1, 1], 'y': [-1, 1]})
>>> ellipsoid2 = EllipsoidDomain({'x': [0, 2], 'y': [0, 2]})
>>> # Create a Exclusion of the ellipsoid domains
>>> exclusion = Exclusion([ellipsoid1, ellipsoid2])
is_inside(point, check_border=False)[source]#

Check if a point is inside the Exclusion domain.

Parameters:
  • point (torch.Tensor) – Point to be checked.

  • check_border (bool) – If True, the border is considered inside.

Returns:

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

Return type:

bool

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

Sample routine for Exclusion domain.

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

  • mode (str) – Mode for sampling, defaults to random. Available modes include: random.

  • variables (str | list[str]) – Variables to be sampled, defaults to all.

Returns:

Returns LabelTensor of n 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]})
>>> # Create a Exclusion of the ellipsoid domains
>>> Exclusion = Exclusion([cartesian1, cartesian2])
>>> # Sample
>>> Exclusion.sample(n=5)
    LabelTensor([[2.4187, 1.5792],
                [2.7456, 2.3868],
                [2.3830, 1.7037],
                [0.8636, 1.8453],
                [0.1978, 0.3526]])
>>> len(Exclusion.sample(n=5)
    5