Skip to content

Adaptive Multilevel Polynomial Chaos Expansion

adaptive

Adaptive multilevel polynomial chaos expansion.

This module provides a class for adaptive multilevel polynomial chaos expansion (PCE).

If the problem rates required for the MultilevelPCE class are not known, the following adaptive algorithm can be used. For an adaptive algorithm, suitable discretizations of approximative responses \(\{Q_0, \ldots, Q_L\}\) and polynomial spaces \(\{V_0, \ldots, V_L\}\) must be found for each level \(l \in \{0, \ldots, L\), for some a-priori unknown \(L \in \mathbb{N}\). Then, as for non-adaptive multilevel PCE, the telescopic sum

\[ \begin{equation} \hat{Q}_{AD} := \Pi_{V_L} Q_0 + \sum_{l=0}^L \Pi_{V_{L-l}} (Q_l - Q_{l-1}), \end{equation} \]

can be employed. The adaptive method considered here is based on the iterative construction of a downward-closed multi-index set \(I \subset \mathbb{N}_0^{d+1}\), which optimizes the ratio between gain and work of multi-indices in each iteration. Note that, compared to the index-sets considered so far, \(I\) contains multi-indices with one additional dimension. The first \(d\) entries of each multi-index in \(I\) still correspond to the polynomial space, while the last entry is used to distinguish between levels. Therefore, we refer to \(I\) as the multi-level index set. This resulting set \(I\) then defines the polynomial spaces and functions to be used on each level by slicing along the last additional dimension and expanding multi-indices using binary expansion.

Note

Instead of a tolerance \(\epsilon > 0\), the adaptive algorithm is initialized with a fixed number of iteration steps.

Classes:

Name Description
AdaptivePCE

Adaptive multilevel PCE class.

multichaos.adaptive.AdaptivePCE

Bases: base.BasePCE

Adaptive multilevel polynomial chaos expansion.

This class implements an adaptive multilevel polynomial chaos expansion using optimal weighted least squares.

Attributes:

Name Type Description
dist ot.Distribution

Input distribution.

response callable

Response function.

n_steps int

Number of adaptive steps.

multi_level_index_set np.ndarray

Multi-level index set.

C_n int

Constant for discretization tuning.

n_pow int

Power for adaptive sample size.

n callable

Adaptive sample size function.

samples np.ndarray

Samples for all levels.

evals dict

Evaluation data for all levels.

eval_times dict

Evaluation times for all levels.

gains dict

Estimated gains for all indices.

ratios dict

Estimated ratios for all indices.

construct_time list

Time for each adaptive step.

number_of_levels int

Number of levels.

Vk list

Multi-index sets for each level.

mk np.ndarray

Number of multi-indices for each level.

nl np.ndarray

Sample sizes for each level.

sample_sizes np.ndarray

Optimal sample sizes for each level.

level_estimators list

PCE estimators for each level.

output_dim int

Output dimension.

evaluation_times dict

Average evaluation times for each level.

fitting_times np.ndarray

Fitting times for each level.

__init__

__init__(dist, response, n_steps, C_n=1)

Initialize AdaptivePCE object.

Parameters:

Name Type Description Default
dist ot.Distribution

Input distribution.

required
response callable

Response function.

required
n_steps int

Number of adaptive steps.

required
C_n int

Constant for discretization tuning.

1

discretization

discretization()

Sets the discretization function.

This method sets the discretization function as \(n_l = C_n 2^l\) for level \(l \in \mathbb{N}_0\).

generate_additional_samples

generate_additional_samples(n_samples: int)

Generate additional samples.

This method generates additional samples using the arcsine distribution and stacks them in the samples attribute.

Parameters:

Name Type Description Default
n_samples int

Number of additional samples.

required

get_num_evals

get_num_evals(level: int) -> int

Return the total number of evaluations for a level.

Return the current total number of stored evaluations in self.evals[level] for a given level.

Parameters:

Name Type Description Default
level int

Level.

required

Returns:

Type Description
int

Number of evaluations.

evaluate_samples

evaluate_samples(level: int, n_samples: int)

Evaluate samples for a level.

This method evaluates n_samples samples for a given level and stores the evaluations in self.evals[level]. Additionally, the evaluation time is stored in self.eval_times[level].

Parameters:

Name Type Description Default
level int

Level.

required
n_samples int

Number of samples.

required

estimate_gain

estimate_gain(index: tuple[int]) -> float

Estimate the gain of a multi-level index.

This method estimates the gain of a multi-level index \((k, l) \in \mathbb{N}_0^{d+1}\), where \(k \in \mathbb{N}_0^d\) and \(l \in \mathbb{N}_0\), by estimating the norm of the projection of \(Q_l - Q_{l-1}\) onto \(P_k\), the binary expansion of \(k\).

Parameters:

Name Type Description Default
index tuple[int]

Multi-level index with shape (self.input_dim + 1,).

required

Returns:

Type Description
float

Estimated gain.

estimate_work

estimate_work(index: tuple[int]) -> float

Estimate the work of a multi-level index.

This method estimates the work of a multi-level index \((k, l) \in \mathbb{N}_0^{d+1}\), where \(k \in \mathbb{N}_0^d\) and \(l \in \mathbb{N}_0\), by estimating the time needed to evaluate one sample of \(Q_l - Q_{l-1}\) times the number of new samples needed.

Parameters:

Name Type Description Default
index tuple[int]

Multi-level index with shape (self.input_dim + 1,).

required

Returns:

Type Description
float

Estimated work.

construct_index_set

construct_index_set()

Construct the multi-level index set.

This method constructs a problem-dependent, downward closed multi-level index set.

initialize_levels

initialize_levels()

Initializes a PCE object on each level.

This method uses the multi_level_index_set attribute to initialize a PCE object for each level \(l \in \{0, \ldots, L\}\) and stores them in the level_estimators list attribute.

set_data

set_data()

Sets the data for each level PCE.

For level \(l=0\), the response \(Q_{n_0}\) and for the remaining \(l \in \{1, \ldots, L\}\), the response differences \(Q_{n_l} - Q_{n_{l-1}}\) are stored in the PCE objects.

compute_coefficients

compute_coefficients()

Computes the coefficients.

This method computes the PCE coefficients by running the compute_coefficients method of each level estimator. The coefficients are then aggregated using the aggregate_coefficients function.