Multi Index Sets
Sparse grids are constructed via multi-index sets. These define a linear combination of tensor product grids, which are popular choices for approximation tasks in moderately high dimensional problems.
In the following, we consider a function $u$ with domain $\Gamma\in\mathbb{R}^n$.
Tensor Product Multi-Index Sets
A tensor product multi-index set
\[\{\alpha : \Vert \alpha \Vert_\infty \leq n + d\} \subset \N^{d}\]
is constructed using the create_tensor_miset
function.
using SparseGridsKit, Plots, LaTeXStrings
n, k = 2, 1
mi_set = create_tensor_miset(n, k)
MISet([[1, 1], [1, 2], [2, 1], [2, 2]])
The multi-index set can be viewed a vector of Vector{Integer}
representing each multi-index:
get_mi(mi_set)
4-element Vector{Vector{Int64}}:
[1, 1]
[1, 2]
[2, 1]
[2, 2]
x = getindex.(get_mi(mi_set), 1)
y = getindex.(get_mi(mi_set), 2)
scatter(x,y, xlabel=L"\beta_1", ylabel=L"\beta_2",
legend=:none,
title="Multi-Index Set", aspect_ratio=:equal)
The exponential growth in complexity with domain dimension $n$ is problematic as soon as $n$ becomes moderately large.
Smolyak Multi-Index Sets
To alleviate some of the problems of high-dimensional approximation, Smolyak type constructions are often used. The standard Smolyak multi-index sets are can be easily constructed. The multi-index set
\[\{\alpha : \Vert \alpha \Vert_1 \leq n + d\} \subset \N^{2}\]
is constructed using the following syntax.
using SparseGridsKit
n, k = 2, 1
mi_set = create_smolyak_miset(n, k)
MISet([[1, 1], [1, 2], [2, 1]])
This gives a different, smaller multi-index set than the tensor product multi-index set.
get_mi(mi_set)
3-element Vector{Vector{Int64}}:
[1, 1]
[1, 2]
[2, 1]
x = getindex.(get_mi(mi_set), 1)
y = getindex.(get_mi(mi_set), 2)
scatter(x,y, xlabel=L"\beta_1", ylabel=L"\beta_2",
legend=:none,
title="Smolyak Multi-Index Set", aspect_ratio=:equal)
Manipulating Multi-Index Sets
The multi-index set can be altered by adding additional multi-indices. Continuing using the above Smolyak example, we add the multi-index $[1, 3]$ with the add_mi
function.
mi_set_new = MISet([[1,3]])
combined_mi_set = add_mi(mi_set, mi_set_new)
x = getindex.(get_mi(combined_mi_set), 1)
y = getindex.(get_mi(combined_mi_set), 2)
scatter(x,y, xlabel=L"\beta_1", ylabel=L"\beta_2",
legend=:none,
title="Multi-Index Addition", aspect_ratio=:equal)
In Gerstner–Griebel style adaptive algorithms, the margin and reduced margin are generally required. These are easily computed using the get_margin
and get_reduced_margin
functions.
margin_set = get_margin(combined_mi_set)
x = getindex.(get_mi(margin_set), 1)
y = getindex.(get_mi(margin_set), 2)
scatter(x,y, xlabel=L"\beta_1", ylabel=L"\beta_2",
legend=:none,
title="Margin Multi-Index", aspect_ratio=:equal)
reduced_margin_set = get_reduced_margin(combined_mi_set)
x = getindex.(get_mi(reduced_margin_set), 1)
y = getindex.(get_mi(reduced_margin_set), 2)
scatter(x,y, xlabel=L"\beta_1", ylabel=L"\beta_2",
legend=:none,
title="Reduced Margin Multi-Index", aspect_ratio=:equal)
Notice how the multi-index $[2,3]$ is in the margin but not the reduced margin. Its backwards neighbour $[2,2]$ is missing from combined_mi_set
.
Function Reference
SparseGridsKit.add_mi
— Methodadd_mi(mi_set, mi_set_new)
Adds a new set of multi-indices (mi_set_new
) to an existing multi-index set (mi_set
).
Arguments
mi_set
: The original multi-index set.mi_set_new
: A newMISet
to be added to the original.
Returns
- A new
MISet
containing the combined and sorted multi-indices.
SparseGridsKit.add_mi
— Methodadd_mi(mi_set, mi_new)
Adds a single new multi-index (mi_new
) to an existing multi-index set (mi_set
).
Arguments
mi_set
: The original multi-index set.mi_new
: A new multi-index vector to be added.
Returns
- A new
MISet
containing the updated and sorted multi-indices.
SparseGridsKit.check_admissibility
— Methodcheck_admissibility(miset)
Checks the admissibility of a multi-index set miset
.
Arguments
miset
: An instance ofMISet
.
Returns
admissibile
: True or falsemi_missing
: Missing multi-indices
SparseGridsKit.check_index_admissibility
— Methodcheck_index_admissibility(miset, mi)
Checks the admissibility of a single multi-index mi
in a multi-index set miset
.
Arguments
miset
: Multi-index set.mi
: Multi-index to check or vector of multi-indices to check.
Returns
admissibile
: True or falsemi_missing
: Missing multi-indices
SparseGridsKit.create_box_miset
— Methodcreate_box_miset(n, k)
Creates a rectangular multi-index set for a given dimension (n
) and levels vector (k
).
Arguments
n
: The dimensionality of the space.k
: A vector of levels for each dimension.
SparseGridsKit.create_rule_miset
— Methodcreate_rule_miset(n, k, rule)
Creates a multi-index set for a given dimension (n
) and with rule(mi) less than or equal to k.
Arguments
n
: The dimensionality of the space.k
: Maximum for rule(mi)rule
: Rule to compute on each MI
SparseGridsKit.create_smolyak_miset
— Methodcreate_smolyak_miset(n, k)
Creates a Smolyak multi-index set for a given dimension (n
) and level (k
).
Arguments
n
: The dimensionality of the space.k
: The level of the Smolyak grid.
Returns
- An
MISet
representing the Smolyak multi-index set.
SparseGridsKit.create_tensor_miset
— Methodcreate_tensor_miset(n, k)
Creates a tensor product multi-index set for a given dimension (n
) and level (k
).
Arguments
n
: The dimensionality of the space.k
: The level of the tensor product grid.
Returns
- An
MISet
representing the tensor product multi-index set.
SparseGridsKit.create_totaldegree_miset
— Methodcreate_totaldegree_miset(n, k)
Creates a multi-index set for a given dimension (n
) and with total levels less than or equal to k.
Arguments
n
: The dimensionality of the space.k
: Total degree
SparseGridsKit.get_margin
— Methodget_margin(mi_set)
Calculates the margin of a multi-index set (mi_set
), which is the set of multi-indices that can extend the current set.
Arguments
mi_set
: An instance ofMISet
.
Returns
- An
MISet
containing the margin set.
SparseGridsKit.get_mi
— Methodget_mi(mi_set)
Retrieves the list of multi-indices from a given MISet
.
Arguments
mi_set
: An instance ofMISet
.
Returns
- A vector of multi-index vectors.
SparseGridsKit.get_n_mi
— Methodget_n_mi(mi_set)
Returns the number of multi-indices in a given MISet
.
Arguments
mi_set
: An instance ofMISet
.
Returns
- The number of multi-indices in the set.
SparseGridsKit.get_reduced_margin
— Methodget_reduced_margin(mi_set)
Calculates the reduced margin of a multi-index set (mi_set
), which removes indices already in the set.
Arguments
mi_set
: An instance ofMISet
.
Returns
- An
MISet
containing the reduced margin set.