Approximate Control Variate Allocation Matrices

Optimizing and constructing PACV estimators requires estimating Cov[Q0,Δ] and Cov[Δ,Δ] which depend on the statistical properties of the models being used but also on the sample alloaction how independent sample sets are shared among the sample sets Zα and Zα.

For example, when computing the mean of a scalar model when the covariance between models is given by C and the first row of C is c then

Cov[Q0,Δ]=gc
gi=Ni0NiN0Ni0NiN0,i=1,,M

and

Cov[Δ,Δ]=GC
Gij=NijNiNjNijNiNjNijNiNj+NijNiNj,i,j=1,,M

where is the Haddamard (element-wise) product.

The implementation of PACV uses allocation matrices A that encode how independent sample sets are shared among the sample sets Zα and Zα.

For example, the allocation matrix of ACVMF using M=3 low-fidelity models (GMF with recursion index (0,0,0)) is

A=[01111111000101010000010100000001]

An entry of one indicates in the ith row of the jth column indicates that the ith independent sample set is used in the corresponding set Zj if j is odd or Zj if j is even. The first column will always only contain zeros because the set Z0 is never used by ACV estimators.

Note, here we focus on how to construct and use allocation matrices for ACVMF like PACV estimtors. However, much of the discussion carries over to other estimators like those based on recursive difference and ACVIS.

The allocation matrix together with the number of points p=[p0,,pM] in the each independent sample set which we call partitions can be used to determine the number of points in the intersection of the sets Zα and Zβ, where α and β may be unstarred or starred. Intersection matrices are used to compute Cov[Q0,Δ] and Cov[Δ,Δ]. The number of intersection points can be represented by a 2(M+1)×2(M+1) matrix

B=[000000000N00N01N01N02N02N03N030N10N11N11N12N12N13N130N10N11N11N12N12N13N130N30N31N31N32N32N33N330N30N31N31N32N32N33N33]

Defining

S=Diag(p)A,

each entry of B can be computed using

Bij=k=02M+1Skjχ[Aki]

where

χ[Aki]={1Aki=10Aki=0

Note computing Cov[Q0,Δ] and Cov[Δ,Δ] also requires the number of samples Nα, Nα in each ACV sample set Zα,Zα which can be computed by simply summing the rows of S or more simply extracting the relevant entry from the diagonal of B. For example

N3=N33 and N3=N33

Finally, to compute the computational cost of the estimator we must be able to compute the number of samples per model. The number of samples of the ith

k=1Mpkχ[A2i,k+A2i+1,k]

where χ[A2i,k+A2i+1,k]=1 if A2i,k+A2i+1,k>0 and is zero otherwise.

Using our example, the intersection matrix is

p=[2,3,4,5]
S=[02222222000303030000040400000500]

So summing each column of S we have

N0=0,N0=2,N1=2,N1=5,N2=2,N2=14,N3=2,N3=9,

And

B=[00000000022222220222222202252525022222220225214290222222202252929]

The first row and column are all zero because Z0 is always empty.

As an example the thrid entry from the right on the bottom row corresponds to B75=N32 which is computed by finding the rows in R that have non zero entries which are the first three rows. Then the B75 is the sum of these rows in the 5 column of S, i.e. 2+3+4=9.

Examples of different allocation matrices

The following lists some example alloaction matrices for the parameterically defined ACV estimators based on the general structure of ACVMF.

MFMC (0,1,2)

[01111111000111110000011100000001]

(0,0,1)

[01111111000101110000010100000001]

(0,0,2)

[01111111000101110000011100000001]

(0,1,1)

[01111111000111110000010100000001]

How to construct ACVMF like allocation matrices

The following shows the general procedure to construct ACVMF like estimators for a recursion index

γ=(γ1,,γM)

As a concrete example, consider the recursion index γ=(0,0,1).

First we set A2α+1,α=1 for all α=0,,M

E.g. for (0,0,1)

[01000000000100000000010000000001]

We then set A2α,γα=1 for α=1,,M. For example,

[01101000000100100000010000000001]

And finally because ACMF always uses all independent partitions up to including γα we set Ai,k=1, for k=0,,γα and i. For example

[01111111000101110000010100000001]

The following can be used to plot the allocation matrix of any PACV estimator (not just GMF). Note we load a benchmark because it is needed to initialize the PACV estimator, but the allocation matrix is independent of any benchmark properties other than the number of models it provides

import matplotlib.pyplot as plt

from pyapprox.benchmarks import setup_benchmark
from pyapprox.multifidelity.factory import get_estimator, multioutput_stats

benchmark = setup_benchmark("tunable_model_ensemble")
model = benchmark.fun

stat = multioutput_stats["mean"](benchmark.nqoi)
stat.set_pilot_quantities(benchmark.covariance)
est = get_estimator("grd", stat, model.costs(), recursion_index=(2, 0))

ax = plt.subplots(1, 1, figsize=(8, 6))[1]
_ = est.plot_allocation(ax)
plot allocation matrices

The different colors represent different independent sample partitions. Subsets Zα or Zα having the same color, means that the same set of samples are used in each subset.

Try changing recursion index to (0, 1) or (2, 0) and the estimator from “gis” to “gmf” or” grd”

Evaluating a PACV estimator

Allocation matrices are also useful for evaluating a PACV estimator. To evaluate the ACV estimator we must construct each independent sample partition from a set of Ntot samples Ztot where

Ntot=α=0Mpα

We then must allocate each model on a subset of these samples dictated by the allocation matrix. For a model index α we must evaluate a model at a independent partition k if A2α,k=1 or A2α+1,k=1. These correspond to the sets Zα,Zα. We store these active partitions in a flattened sample array for each model ordered by increasing partition index, which is passed to each user. E.g. if the partitions 0, 1, 3 are active then we store [Z0,Z1,Z3] where the dagger indicates the samples sets are associated with partitions and not the estimator sets Zα,Zα.

The user can then evaluate each model without knowing anything about the ACV estimator sets or the independent partitions.

These model evaluations are then passed back to the estimator and internally we must assigne the values to each ACV estimator sample set. Specifically for each model α, we loop through all partition indices k and if A2α,k=1 we assign fα(Zk) to Zα similarly if A2α+1,k=1 we assign fα(Zk) to Zα.

Total running time of the script: ( 0 minutes 0.037 seconds)

Gallery generated by Sphinx-Gallery