hep-mc
0.8
|
The Multi Channel integration algorithm.
In contrast to the VEGAS algorithm, which uses a product of one-dimensional PDFs, the multi channel integration algorithm uses a sum of \( M \) user-defined PDFs \( p_j ( \vec{y}) \) with automatically adapted weights \( \alpha_j \) in the form
\[ p ( \vec{y} ) = \sum_{j=1}^M \alpha_j p_j ( \vec{y} ) \text{,} \quad \int \mathrm{d}^d y \; p_j \left( \vec{y} \right) = 1 \text{,} \quad \sum_{j=1}^M \alpha_j = 1 \text{,} \]
which is used to sample the function. Multi channel integration performs better compared to VEGAS if the peak structure of the integrand does not factorize. To avoid explicitly summing over every channel* \( j \) for each randomly chosen point \( \vec{x} \in U \equiv [0,1]^d \) the MC integrator also samples over the possible channels. This leads to the final formula
\[ I = \int \mathrm{d} i \int_U \mathrm{d}^d x \; \left. \frac{f (\vec{y})}{p (\vec{y})} \right|_{\vec{y} = \vec{y}_i ( \vec{x} )} \text{,} \qquad i \sim \left\{ \alpha_1, \alpha_2, \ldots, \alpha_M \right\} \]
where the integral over the index \( i \) is understood to be a Monte Carlo summation in which the index \( i \) is randomly chosen according to the specified weights. Since the PDFs \( \left\{ p_j \right\}_{j=1}^M \) are user-defined, the user also has to specify the CDFs \( \left\{ \vec{y}_j ( \vec{x} ) \right\}_{j=1}^M \) for each channel.
The multi channel integration uses the following parameters, where T
denotes the numerical type, e.g. double
:
dimensions
determines the parameter \( d \),map_dimensions
determines the size of the vector coordinates
(see below),channels
determines \( M \), the number of channels,map
must be the function that calculates both the PDFs and the CDFs. Its declaration must be as follows:
T map( std::size_t channel, std::vector<T> const& random_numbers, std::vector<T>& coordinates, std::vector<std::size_t> const& enabled_channels, std::vector<T>& densities, hep::multi_channel_map action );
The parameter action
determines what map
should do:
action
is hep::multi_channel_map::calculate_coordinates, then the function must use random_numbers
to generate a point according to the PDF with the index given by channel
. The point itself must be written into coordinates
, whose size is already set by the parameter map_dimensions
(see above). The return value of map
is ignored.action
is hep::multi_channel_map::calculate_densities, then the map
function must generate the PDFs for the previously generated point, which can be read out of coordinates
. The PDFs must be written into densities
, whose size is determined by channels
(see above). The inverse of the return value of the map
function is multiplied with every PDF. The vector enabled_channels
stores the indices of all channels whose weights are not zero. If a weight is zero, then the PDF for this channel will be ignored; this can be used to speed up the calculation if there are many disabled channels.The reason for the having the parameter action
is that for some applications the integrand often evaluates to zero. If this happens, the densities
are not needed, and then the multi channels integrator skips the possibly costly call to the map
function with calculate_densities
.
function
must be the integrand function that is integrated over. Its declaration must be as described in Integrand Functions. The Monte Carlo point can be captured e.g. using multi_channel_point or, if function
needs access to data that has been computed already in densities
, it can be captured using multi_channel_point2. Functions | |
template<typename I , typename Checkpoint = default_multi_channel_chkpt<numeric_type_of<I>>, typename Callback = mpi_callback<Checkpoint>> | |
Checkpoint | hep::mpi_multi_channel (MPI_Comm communicator, I &&integrand, std::vector< std::size_t > const &iteration_calls, Checkpoint chkpt=make_multi_channel_chkpt< numeric_type_of< I >>(), Callback callback=mpi_callback< Checkpoint >()) |
template<typename I , typename R > | |
multi_channel_result< numeric_type_of< I > > | hep::multi_channel_iteration (I &&integrand, std::size_t calls, std::vector< numeric_type_of< I >> const &channel_weights, R &generator) |
template<typename I , typename Checkpoint = default_multi_channel_chkpt<numeric_type_of<I>>, typename Callback = callback<Checkpoint>> | |
Checkpoint | hep::multi_channel (I &&integrand, std::vector< std::size_t > const &iteration_calls, Checkpoint chkpt=make_multi_channel_chkpt< numeric_type_of< I >>(), Callback callback=callback< Checkpoint >()) |
|
inline |
MPI version of multi_channel.
|
inline |
Multi channel integrator. Integrates integrand
using iteration_calls.size()
iterations, with the number of calls for each iteration given in iteration_calls
. The integration starts from the default (empty) checkpoint, unless one is explicitly given in chkpt
. After each successful iteration the callback
function is invoked.
|
inline |
Performs exactly one iteration using with multi channel integrator of integrand
using exactly calls
number of integrand evaluations. The parameter channel_weights
must specify the weights of each channel. Note that the weights must be normalized, i.e. their sum must be one. Random numbers are drawn from generator
.