LevelSet

class LevelSet(*args)

Level set.

Available constructors:

LevelSet(dim=1)

LevelSet(function=ot.SymbolicFunction([‘x’], [‘1.0’]), level=0.0)

Parameters:

dim : int, dim \geq 0

Dimension of the LevelSet.

function : NumericalMathFunction

A function such that: f: \Rset^{dim} \mapsto \Rset defining the LevelSet.

level : float

Level s defining the LevelSet.

Notes

A LevelSet is a Domain defined as follows:

\{ \vect{x} \in \Rset^{dim} \, | \, f(\vect{x}) \leq s \}

Examples

>>> import openturns as ot
>>> function = ot.SymbolicFunction(['x1', 'x2'], ['x1^4 + x2^4'])
>>> s = 1.0
>>> levelSet = ot.LevelSet(function, s)

Methods

contains(point) Check if the given point is inside of the domain.
getClassName() Accessor to the object’s name.
getDimension() Get the dimension of the domain.
getFunction() Get the function defining the level set.
getId() Accessor to the object’s id.
getLevel() Get the level defining the level set.
getLowerBound() Get the lower bound of the domain.
getName() Accessor to the object’s name.
getNumericalVolume() Get the volume of the domain.
getShadowedId() Accessor to the object’s shadowed id.
getUpperBound() Get the upper bound of the domain.
getVisibility() Accessor to the object’s visibility state.
getVolume() Get the geometric volume of the domain.
hasName() Test if the object is named.
hasVisibleName() Test if the object has a distinguishable name.
intersect(other) Return the levelSet equals to the intersection between the LevelSet and another one.
isEmpty() Test whether the domain is empty or not.
isNumericallyEmpty() Check if the domain is numerically empty.
join(other) Return the levelSet equals to the union between the LevelSet and another one.
numericallyContains(point) Check if the given point is inside of the discretization of the domain.
setFunction(function) Set the function defining the level set.
setLevel(level) Set the level defining the level set.
setLowerBound(bound) Set the lower bound of the bounding box.
setName(name) Accessor to the object’s name.
setShadowedId(id) Accessor to the object’s shadowed id.
setUpperBound(bound) Set the upper bound of the bounding box.
setVisibility(visible) Accessor to the object’s visibility state.
__init__(*args)
contains(point)

Check if the given point is inside of the domain.

Parameters:

point : sequence of float

Point with the same dimension as the current domain’s dimension.

Returns:

isInside : bool

Flag telling whether the given point is inside of the domain.

getClassName()

Accessor to the object’s name.

Returns:

class_name : str

The object class name (object.__class__.__name__).

getDimension()

Get the dimension of the domain.

Returns:

dim : int

Dimension of the domain.

getFunction()

Get the function defining the level set.

Returns:

function : NumericalMathFunction

A function such that: f: \Rset^{dim} \mapsto \Rset defining the LevelSet.

Examples

>>> import openturns as ot
>>> function = ot.SymbolicFunction(['x'], ['3*x-1'])
>>> levelSet = ot.LevelSet(function, 0.0)
>>> print(levelSet.getFunction().getEvaluation())
[x]->[3*x-1]
getId()

Accessor to the object’s id.

Returns:

id : int

Internal unique identifier.

getLevel()

Get the level defining the level set.

Returns:

level : float

Level s defining the LevelSet.

Examples

>>> import openturns as ot
>>> function = ot.SymbolicFunction(['x'], ['3*x-1'])
>>> levelSet = ot.LevelSet(function, 0.0)
>>> print(levelSet.getLevel())
0.0
getLowerBound()

Get the lower bound of the domain.

Returns:

lower : NumericalPoint

The lower bound of an axes-aligned bounding box of the domain.

getName()

Accessor to the object’s name.

Returns:

name : str

The name of the object.

getNumericalVolume()

Get the volume of the domain.

Returns:

volume : float

Volume of the underlying mesh which is the discretization of the domain. For now, by default, it is equal to the geometrical volume.

getShadowedId()

Accessor to the object’s shadowed id.

Returns:

id : int

Internal unique identifier.

getUpperBound()

Get the upper bound of the domain.

Returns:

upper : NumericalPoint

The upper bound of an axes-aligned bounding box of the domain.

getVisibility()

Accessor to the object’s visibility state.

Returns:

visible : bool

Visibility flag.

getVolume()

Get the geometric volume of the domain.

Returns:

volume : float

Geometrical volume of the domain.

hasName()

Test if the object is named.

Returns:

hasName : bool

True if the name is not empty.

hasVisibleName()

Test if the object has a distinguishable name.

Returns:

hasVisibleName : bool

True if the name is not empty and not the default one.

intersect(other)

Return the levelSet equals to the intersection between the LevelSet and another one.

Parameters:

otherLevelSet :

A LevelSet defined by (f_2, s_2).

Returns:

levelSet : LevelSet

levelSet equals to the intersection between the LevelSet and otherLevelSet i.e. levelSet is defined by: \{\vect{x} \in \Rset^{dim} | f(\vect{x}) \leq s \, \mbox{and} \, f_2(\vect{x}) \leq s_2\}.

Examples

>>> import openturns as ot
>>> # First level set
>>> function = ot.SymbolicFunction(['x'], ['3*x-1'])
>>> levelSet1 = ot.LevelSet(function, 0.5)
>>> # Second level set
>>> function = ot.SymbolicFunction(['x'], ['x'])
>>> levelSet2 = ot.LevelSet(function, 0.5)
>>> # Intersection between levelSet1 and levelSet2
>>> intersection = levelSet1.intersect(levelSet2)
>>> # Tests
>>> print(intersection.contains([1.0]))
False
>>> print(intersection.contains([0.25]))
True
isEmpty()

Test whether the domain is empty or not.

Returns:

isInside : bool

True if the interior of the geometric domain is empty.

isNumericallyEmpty()

Check if the domain is numerically empty.

Returns:

isInside : bool

Flag telling whether the domain is numerically empty, i.e. if its numerical volume is inferior or equal to \epsilon (defined in the ResourceMap: \epsilon = DomainImplementation-SmallVolume).

Examples

>>> import openturns as ot
>>> domain = ot.Domain([1.0, 2.0], [1.0, 2.0]) 
>>> print(domain.isNumericallyEmpty())
True
join(other)

Return the levelSet equals to the union between the LevelSet and another one.

Parameters:

otherLevelSet :

A LevelSet defined by (f_2, s_2).

Returns:

levelSet : LevelSet

levelSet equals to the union between the LevelSet and otherLevelSet i.e. levelSet is defined by: \{\vect{x} \in \Rset^{dim} | f(\vect{x}) \leq s \, \mbox{or} \, f_2(\vect{x}) \leq s_2\}.

Examples

>>> import openturns as ot
>>> # First level set
>>> function = ot.SymbolicFunction(['x'], ['3*x-1'])
>>> levelSet1 = ot.LevelSet(function, 0.0)
>>> # Second level set
>>> function = ot.SymbolicFunction(['x'], ['x'])
>>> levelSet2 = ot.LevelSet(function, 0.0)
>>> # Union between levelSet1 and levelSet2
>>> join = levelSet1.join(levelSet2)
>>> # Tests
>>> print(join.contains([0.5]))
False
>>> print(join.contains([0.25]))
True
numericallyContains(point)

Check if the given point is inside of the discretization of the domain.

Parameters:

point : sequence of float

Point with the same dimension as the current domain’s dimension.

Returns:

isInside : bool

Flag telling whether the point is inside the discretized domain associated to the domain. For now, by default, the discretized domain is equal to the geometrical domain.

setFunction(function)

Set the function defining the level set.

Parameters:

function : NumericalMathFunction

A function such that: f: \Rset^{dim} \mapsto \Rset defining the LevelSet.

Examples

>>> import openturns as ot
>>> levelSet = ot.LevelSet()
>>> function = ot.SymbolicFunction(['x'], ['3*x-1'])
>>> levelSet.setFunction(function)
setLevel(level)

Set the level defining the level set.

Parameters:

level : float

Level s defining the LevelSet.

Examples

>>> import openturns as ot
>>> levelSet = ot.LevelSet()
>>> levelSet.setLevel(3.0)
setLowerBound(bound)

Set the lower bound of the bounding box.

Parameters:

bound : sequence of floats

Lower bound of the bounding box of the level set. It allows to clip the level set.

setName(name)

Accessor to the object’s name.

Parameters:

name : str

The name of the object.

setShadowedId(id)

Accessor to the object’s shadowed id.

Parameters:

id : int

Internal unique identifier.

setUpperBound(bound)

Set the upper bound of the bounding box.

Parameters:

bound : sequence of floats

Upper bound of the bounding box of the level set. It allows to clip the level set.

setVisibility(visible)

Accessor to the object’s visibility state.

Parameters:

visible : bool

Visibility flag.