Doxygen
1.9.1
|
Class that enables distributed DREAM sampling with MPI. More...
#include <tsgMPISampleDream.hpp>
Public Member Functions | |
DistributedPosterior (DreamModel distributed_model, DreamLikelihood likelihood, DreamPrior prior, int num_inputs, int num_chains, int mpi_root, MPI_Comm communicator) | |
Constructor that sets the parameters for the distribued posterior. More... | |
~DistributedPosterior () | |
Destructor, unblocks the non-root ranks (if still blocked). | |
void | clear () |
Unblocks the non-root ranks, the object cannot be used after this calls (can be destroyed only). | |
operator DreamPDF () | |
Allows passing the object as an input to TasDREAM::SampleDREAM(). | |
Class that enables distributed DREAM sampling with MPI.
Models with many outputs are computationally expensive to sample when used in a Bayesian posterior. Such models can be distributed across ranks of an MPI communicator and the DREAM candidates can be computed in parallel, i.e., distributing the work. Of specific interest are posteriors with likelihood functions that can be expressed as a product (or sum) of one term per model outputs, e.g., constant or diagonal Gaussian likelihoods. The actual sampling is performed on a single rank while the values of the probability distribution at the candidate points is computed by all MPI ranks together (each ranks handling a separate set of inputs). The high-level algorithm can be expressed with two MPI calls, MPI_Bcast() all candidates to all ranks, then MPI_Reduce() the result. See TasGrid::MPIGridScatterOutputs() and TasDREAM::MPILikelihoodScatter() for ways to distribute a sparse grid model and a likelihood function.
The usage of this class is very similar to the calls to TasDREAM::posterior() template, the first two inputs are the local portions of the model and likelihood, followed by the prior which will only be used on the root rank. The other inputs define parameters of the MPI side of the algorithm. The constructor can be inlined in a call to TasDREAM::SampleDREAM().
Alternatively, the object can also be assigned to a variable:
|
inline |
Constructor that sets the parameters for the distribued posterior.
Constructs a distributed posterior object from local model and likelihood objects. See the class description for example usage, details on the parameters follow here:
form | is the same as in the call to TasDREAM::SampleDREAM() and both must match. |
distributed_model | is the local portion of the model, the sub-set of the outputs must match the set used by the likelihood. |
likelihood | is the local portion of the likelihood. Same as in the call to TasDREAM::posterior(). |
prior | will be used only by the root rank, same as in the call to TasDREAM::posterior(). |
num_inputs | must match the dimensions of the state on the root rank, since the non-root ranks do not need a valid state this parameter is used to synchronize the dimensions across all ranks. |
num_chains | same as the number set by the state, see the num_inputs. |
mpi_root | is the root process that will perform the actual sampling. |
communicator | is the communicator where all ranks reside. |