CleaningStrategy

class CleaningStrategy(*args)

Cleaning truncation strategy.

Available constructors:

CleaningStrategy(orthogonalBasis, maximumDimension)

CleaningStrategy(orthogonalBasis, maximumDimension, verbose)

CleaningStrategy(orthogonalBasis, maximumDimension, maximumSize, significanceFactor)

CleaningStrategy(orthogonalBasis, maximumDimension, maximumSize, significanceFactor, verbose)

Parameters
orthogonalBasisOrthogonalBasis

An OrthogonalBasis.

maximumDimensionpositive int

Maximum index that can be used by the EnumerateFunction to determine the last term of the basis.

maximumSizepositve int

Parameter that characterizes the cleaning strategy. It represents the number of efficient coefficients of the basis. Its default value is set to 20.

significanceFactorfloat

Parameter used as a threshold for selecting the efficient coefficients of the basis. The real threshold represents the multiplication of the significanceFactor with the maximum magnitude of the current determined coefficients. Its default value is equal to 1e^{-4}.

verbosebool

Used for the online monitoring of the current basis updates (removed or added coefficients).

Notes

The cleaning strategy aims at building a PC expansion containing at most P significant coefficients, i.e. at most P significant basis functions. It proceeds as follows:

  • Generate an initial PC basis made of the P first polynomials (according to the adopted EnumerateFunction), or equivalently an initial set of indices K = \{0, \ldots, P-1\}.

  • Discard from the basis all those polynomials \Psi_j associated with insignificance coefficients, i.e. the coefficients that satisfy:

|a_j| \leq \epsilon \times \max_{ k \in K } |a_k|

where \epsilon is the significance factor, default is \epsilon = 10^{-4}.

  • Add the next basis term \Psi_{k+1} to the current basis K.

  • Reiterate the procedure until either P terms have been retained or if the given maximum index P_{max} has been reached.

Examples

>>> import openturns as ot
>>> ot.RandomGenerator.SetSeed(0)
>>> # Define the model
>>> inputDim = 1
>>> model = ot.SymbolicFunction(['x'], ['x*sin(x)'])
>>> # Create the input distribution
>>> distribution = ot.ComposedDistribution([ot.Uniform()]*inputDim)
>>> # Construction of the multivariate orthonormal basis
>>> polyColl = [0.0]*inputDim
>>> for i in range(distribution.getDimension()):
...     polyColl[i] = ot.StandardDistributionPolynomialFactory(distribution.getMarginal(i))
>>> enumerateFunction = ot.LinearEnumerateFunction(inputDim)
>>> productBasis = ot.OrthogonalProductPolynomialFactory(polyColl, enumerateFunction)
>>> # Truncature strategy of the multivariate orthonormal basis
>>> # We want to select, among the maximumDimension = 100 first polynomials of
>>> # the multivariate basis, those which have the maximumSize = 20 most 
>>> # significant contribution (greatest coefficients), with respect to the 
>>> # significance factor = 10^-4.
>>> maximumDimension = 100
>>> maximumSize = 20
>>> significanceFactor = 1e-4
>>> adaptiveStrategy = ot.CleaningStrategy(productBasis, maximumDimension,
...                                          maximumSize, significanceFactor)

Methods

computeInitialBasis(self)

Compute initial basis for the approximation.

getBasis(self)

Accessor to the underlying orthogonal basis.

getClassName(self)

Accessor to the object’s name.

getCurrentVectorIndex(self)

Accessor to the current vector index.

getId(self)

Accessor to the object’s id.

getMaximumDimension(self)

Accessor to the maximum dimension of the orthogonal basis.

getMaximumSize(self)

Accessor to the maximum size of the orthogonal basis.

getName(self)

Accessor to the object’s name.

getPsi(self)

Accessor to the orthogonal polynomials of the basis.

getShadowedId(self)

Accessor to the object’s shadowed id.

getSignificanceFactor(self)

Accessor to the significance factor.

getVerbose(self)

Accessor to the verbose.

getVisibility(self)

Accessor to the object’s visibility state.

hasName(self)

Test if the object is named.

hasVisibleName(self)

Test if the object has a distinguishable name.

setMaximumDimension(self, maximumDimension)

Accessor to the maximum dimension of the orthogonal basis.

setMaximumSize(self, maximumSize)

Accessor to the maximum size of the orthogonal basis.

setName(self, name)

Accessor to the object’s name.

setShadowedId(self, id)

Accessor to the object’s shadowed id.

setSignificanceFactor(self, significanceFactor)

Accessor to the significance factor.

setVerbose(self, verbose)

Accessor to the verbose.

setVisibility(self, visible)

Accessor to the object’s visibility state.

updateBasis(self, alpha_k, residual, …)

Update the basis for the next iteration of approximation.

__init__(self, \*args)

Initialize self. See help(type(self)) for accurate signature.

computeInitialBasis(self)

Compute initial basis for the approximation.

See also

getPsi
getBasis(self)

Accessor to the underlying orthogonal basis.

Returns
basisOrthogonalBasis

Orthogonal basis of which the adaptive strategy is based.

getClassName(self)

Accessor to the object’s name.

Returns
class_namestr

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

getCurrentVectorIndex(self)

Accessor to the current vector index.

Returns
indexinteger

Current index of the basis term.

getId(self)

Accessor to the object’s id.

Returns
idint

Internal unique identifier.

getMaximumDimension(self)

Accessor to the maximum dimension of the orthogonal basis.

Returns
Pinteger

Maximum dimension of the truncated basis.

getMaximumSize(self)

Accessor to the maximum size of the orthogonal basis.

Returns
sizeinteger

Maximum number of significant terms of the basis.

See also

setMaximumSize
getName(self)

Accessor to the object’s name.

Returns
namestr

The name of the object.

getPsi(self)

Accessor to the orthogonal polynomials of the basis.

Returns
polynomialslist of polynomials

Sequence of P analytical polynomials.

Notes

The method computeInitialBasis() must be applied first.

Examples

>>> import openturns as ot
>>> productBasis = ot.OrthogonalProductPolynomialFactory([ot.HermiteFactory()])
>>> adaptiveStrategy = ot.FixedStrategy(productBasis, 3)
>>> adaptiveStrategy.computeInitialBasis()
>>> print(adaptiveStrategy.getPsi())
[1,x0,-0.707107 + 0.707107 * x0^2]
getShadowedId(self)

Accessor to the object’s shadowed id.

Returns
idint

Internal unique identifier.

getSignificanceFactor(self)

Accessor to the significance factor.

Returns
factorfloat

Value of the significance factor.

getVerbose(self)

Accessor to the verbose.

Returns
verbosebool

Return if the online monitoring of the current basis updates is enabled or not.

See also

setVerbose
getVisibility(self)

Accessor to the object’s visibility state.

Returns
visiblebool

Visibility flag.

hasName(self)

Test if the object is named.

Returns
hasNamebool

True if the name is not empty.

hasVisibleName(self)

Test if the object has a distinguishable name.

Returns
hasVisibleNamebool

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

setMaximumDimension(self, maximumDimension)

Accessor to the maximum dimension of the orthogonal basis.

Parameters
Pinteger

Maximum dimension of the truncated basis.

setMaximumSize(self, maximumSize)

Accessor to the maximum size of the orthogonal basis.

Parameters
sizeinteger

Maximum number of significant terms of the basis.

See also

getMaximumSize
setName(self, name)

Accessor to the object’s name.

Parameters
namestr

The name of the object.

setShadowedId(self, id)

Accessor to the object’s shadowed id.

Parameters
idint

Internal unique identifier.

setSignificanceFactor(self, significanceFactor)

Accessor to the significance factor.

Parameters
factorfloat

Value of the significance factor.

setVerbose(self, verbose)

Accessor to the verbose.

Parameters
verbosebool

Enable the online monitoring of the current basis updates or not.

See also

getVerbose
setVisibility(self, visible)

Accessor to the object’s visibility state.

Parameters
visiblebool

Visibility flag.

updateBasis(self, alpha_k, residual, relativeError)

Update the basis for the next iteration of approximation.

Notes

No changes are made to the basis in the fixed strategy.