BIE::ParallelChains Class Reference

Implements parallel temperering or the parallel hierarchical sampler. More...

#include <ParallelChains.h>

Inheritance diagram for BIE::ParallelChains:
Collaboration diagram for BIE::ParallelChains:

List of all members.

Global variables

enum  Algorithm { standard, hierarchical }
 Algorithm types. More...
enum  Control { parallel, serial }
 Parallelization type. More...
enum  Initial { user_supplied, prior_sampled }
 Initialization type. More...
static Algorithm algo
 Current algorithm.
static Control cntrl
 Current control.
static Initial initial
 Initialization method.
static double swapprob
 Swap probability.
static double apow
 Change temperature spacing (apow=1 is geometric spacing).
static double tpow
 Scale factor $T^{tpow}$ for proposal function.
static int minmc
 Minimum number of temperature states.
static int state_iter
 Number of iterations allowed for finding a good initial state.
vector< unsigned short > fail
 Status vector for sampling new states.
void SampleNewState (int k)
 Attempt to find a good state from the prior distribution for chain k.
void SampleNewStateParallel (int k)
 Sample a new state for the kth chain (parallel version).
void SampleNewStateSerial (int k)
 Sample a new state for the kth chain (serial version).
void NewStateSerialInit ()
 Prepare for chain initialization.
void NewStateSerialStatus ()
 Check the status of the initialization.

Public Member Functions

virtual ~ParallelChains ()
 Destructor.
virtual void Initialize ()
 Initialize all the chains.
virtual void Reinitialize (MHWidth *width, MixturePrior *mp)
 Reinitialize with new class instances.
 ParallelChains (int max, int ndim, int minmc_p, double maxT, MHWidth *width, BaseDataTree *d, Model *m, Integration *i, Converge *c, MixturePrior *mp, LikelihoodComputation *l, MCAlgorithm *mca)
 Constructor.
 ParallelChains (int max, int ndim, int minmc_p, double maxT, MHWidth *width, BaseDataTree *d, Model *m, Integration *i, Converge *c, MixturePrior *mp, LikelihoodComputation *l, MCAlgorithm *mca, Simulation *last)
void NewState (int Mcur, vector< double > &w, vector< vector< double > > &p)
 Initialize new state (override from Simulation).
void NewState (Chain &ch)
void NewState (State &s)
void SetAlgorithm (int)
 Set global parameters.
void SetControl (int)
 Choose parallelization control (parallel=0, serial=1).
void SetInitial (int)
 Choose initialization type (user_supplied=0, prior_sampled=1).
void SetTempExp (double a, double t)
 Choose temperature scaling parameters.
void SetNewWidths (vector< double > *wid)
 Set chains widths to new values.
void SetNewWidths (string wid)
 Set chains widths to new values (file name input).
Members which report and diagnose current state
double GetValue ()
 Return current posterior probability value (override).
double GetPrior ()
 Return current prior value (override).
double GetLikelihood ()
 Return current likelihood probability value.
State GetState ()
 Return current state (override).
virtual void ReportState ()
 Print passed state in ascii with labels (override).
void PrintState ()
 Print current state (override).
virtual void PrintStepDiagnostic ()
 override of Simulation method to provide diagnostics specific to temperedsimulation
virtual void PrintStateDiagnostic ()
 override of Simulation method to provide state specific diagnostics.
vector< double > GetMixstat (void)
 Return vector with fraction of swaps for each chain.
vector< double > GetSweepstat (void)
 Return vector with fraction of acceptences for each chain.
void NewNumber (int)
 Specify the number of desired chains.
void NewSwapProb (double p)
 Change the swap probabability.
void EnableLogging ()
 Enable caching per chain.
void AdditionalInfo ()
 Print out simulation specific diagnostics.

Protected Member Functions

virtual void MCMethod ()
 Execute a Markov Chain step.
void CreateChains ()
 Create the chain structures.
void ResetChainStats ()
 For gathering diagnostic data.
void getChainCounts ()
 Gathers in-chain rates across all processes.

Protected Attributes

bool caching
 True if chains states are logged to files.
unsigned ncount
 Number of attempts so far.
Uniform * unit
 Unit interval variates.
bool chains_initialized
 True if state values have been computed for at least the first time.
vector< double > user_widths
 User-defined widths for MH sampling.
double MaxT
 Config parameters.
vector< unsigned char > update_flag
 State variables.
vector< unsigned char > update_flag1
 List of chains on an individual node that must sychronized.
vector< unsigned long > stat0
 Number of in-chain update attempts.
vector< unsigned long > stat1
 Number of in-chain acceptances per chain.
vector< unsigned long > nstat0
 Number of swap attempts per chain.
vector< unsigned long > nstat1
 Number of swap acceptances per chain.
vector< unsigned long > mstat0
 Number of standard MCMC updates attempted per chain.
vector< unsigned long > mstat1
 Number of standard MCMC updates accepted per chain.
int Ntot
 Maximum dimension of state vector.
int swapnum
 Convergence check.
int swaptry
 The number of attempted swaps.

Friends

class boost::serialization::access


Detailed Description

Implements parallel temperering or the parallel hierarchical sampler.

Both algorithms use an ensemble of Markov chains, run in parallel, each at a successively higher temperature. A temperature of $T=1$ is the initial cold chain.
The total number of chains is given by the maximum temperature, MaxT, for a state vector of dimension Ntot:

\[ //! Mchains = 1 + \log(MaxT)*\sqrt(Ntot) //! \]

Temperature spacing
Temperature for a chain is chosen as follows:

\[ //! T_j = T_{max}^{(j/(Mchain-1))^a}, j\in[0,Mchain-1] //! \]

  • $a=1.0$ is logarithmic (e.g pure geometric spacing). This is the default.
  • $a>1.0$ weighted towards values of $T$ smaller than geometric
  • $a<1.0$ weighted towards values of $T$ larger than geometric
  • $a=0.23$ gives values of $T$ approximately linear from 1 to $T_{max}$
  • $a<0.23$ gives values of $T$ strongly weighted toward $T_{max}$

The second exponent, $t$ is used to scale the proposal width by a power of the temperature. Gaussian scaling, the default is $t=1/2$.

The member function SetTempExp may be used to rest either or both of these parameters.

Parallel tempering (standard)
At each step, with probability swapprob, one proposes to swap the states of two adjecent temperature chains. With probability 1 - swapprob, all chains are updated at their assigned tempratures.
Parallel hierarchical sampler
At each step, one chain is proposed to be swapped with the cold chain. The remaining Mchain-2 schains are updated at their assigned tempratures.
Note:
Chain initialization The fiducial, cold chain is initialized from the user-supplied initial state file. The initialization of the warm state can be done in two way depending on the static variable initial.
  1. If initial = user_supplied, all chains are assigned the user-supplied initial value.
  2. If initial = prior_sampled, all chains but the fiducial chain have initial values sampled from the prior distribution.

Control methods

  1. The parallel likelihood classes should be used with parallel control only. The parallel likelihood classes LikelihoodComputationMPI and LikelihoodComputationMPITP assume that each process will enter the likelihood computation code.
  2. A serial likelihood class should be used with serial control only. A serial likelihood computation is only entered by the process which calls it.

Diagnostic output A call to the EnableLogging member function will cause the state of each individual chain to be logged to a separate file. The chain files will have names of the form "nametag.chainlog.k" where nametag is the global nametag variable and k is the chain number. The first five lines record the following values for each chain: the number of components in the mixture, rank of the parameter vector, the inverse temperature $\beta=1/T$, the Metropolis-Hastings width factor, and the weighting factor.

References
Geyer, C. J. 1991, "Markov chain Monte Carlo maximum likelihood." In Keramidas, E. M., editor, Computing Science and Statistics, Proceedings of the 23rd Symposium on the Interface, pages 156-163, Seattle, WA. Interface Foundation of North America.
Hukushima and Nemoto 1996, J. Phys. Soc. Japan, 65, 1604-1620.
Rigat, F. 2006, "MCMC inference using parallel hierarchical sampling," preprint.

Member Enumeration Documentation

Algorithm types.

Enumerator:
standard  standard parallel chains algorithm.
hierarchical  hierarchical parallel chains algorithm.

Parallelization type.

Enumerator:
parallel  root controls all chain updates.
serial  chains are run at each node.

Initialization type.

Enumerator:
user_supplied  initial state specified by user.
prior_sampled  initial state selected from prior.


Member Function Documentation

void BIE::ParallelChains::SetAlgorithm ( int   ) 

Set global parameters.

Choose between parallel tempering and hierachical tempering (standard=0, hierarchical=1)

void BIE::ParallelChains::SetNewWidths ( vector< double > *  wid  ) 

Set chains widths to new values.

Set chains widths to new values (vector input)

virtual void BIE::ParallelChains::PrintStateDiagnostic (  )  [virtual]

override of Simulation method to provide state specific diagnostics.

Here, the method provides mixing statistics.

Reimplemented from BIE::Simulation.

void BIE::ParallelChains::SampleNewState ( int  k  )  [protected]

Attempt to find a good state from the prior distribution for chain k.

Sample a new state for the kth chain (will select one of the two below)

void BIE::ParallelChains::ResetChainStats (  )  [protected]

For gathering diagnostic data.

Resets the counters


Member Data Documentation

double BIE::ParallelChains::MaxT [protected]

Config parameters.

Temperature for tempering ladder

vector<unsigned char> BIE::ParallelChains::update_flag [protected]

State variables.

List of chains that must be globally sychronized

Convergence check.

The number swaps


The documentation for this class was generated from the following file:

Send suggestions, questions, and feedback to WEINBERG at ASTRO dot UMASS dot EDU.
Documentation generated at Fri Mar 26 00:35:12 2010 by doxygen