BIE::MultipleChains Class Reference

Runs the user-specified number of chains in parallel using the user-specified Monte Carlo algorithm (mca). More...

#include <MultipleChains.h>

Inheritance diagram for BIE::MultipleChains:
Collaboration diagram for BIE::MultipleChains:

List of all members.

Global variables

enum  Control { parallel, serial }
 Parallelization type. More...
static Control cntrl
 Current control.
static unsigned nfifo
 Number of states for acceptance rate queue.
static int state_iter
 Number of iterations allowed for finding a good initial state.
unsigned ncount
 Convergence check.
unsigned totalnum
 Number of accepted states.
unsigned totaltry
 Number of attempted states.
void SampleNewState (int k)
 Attempt to find a good state from the prior distribution for chain k.
void SampleNewStateParallel (int k)
 Sample new state (parallel implementation, called by generic member).
void SampleNewStateSerial (int k)
 Sample new state (serial implementation, called by generic member).

Public Member Functions

 MultipleChains (int max, int ndim, int number, MHWidth *width, BaseDataTree *d, Model *m, Integration *i, Converge *c, MixturePrior *mp, LikelihoodComputation *l, MCAlgorithm *mca)
 Constructor for top level invocation.
 MultipleChains (int max, int ndim, int number, MHWidth *width, BaseDataTree *d, Model *m, Integration *i, Converge *c, MixturePrior *mp, LikelihoodComputation *l, MCAlgorithm *mca, Simulation *last)
 Constructor for invocation at higher levels of resolution.
virtual ~MultipleChains ()
 Destructor.
virtual void Initialize ()
 Initialize all the chains.
virtual void Reinitialize (MHWidth *width, MixturePrior *mp)
 Reinitialize with new class instances.
void EnableLogging ()
 Enable caching per chain.
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 > GetStat (void)
 Return vector with fraction of acceptances for each chain.
void AdditionalInfo ()
 Print out simulation specific diagnostics.
void NewState (int Mcur, vector< double > &w, vector< vector< double > > &p)
 Initialize new state (override from Simulation).
void NewState (Chain &ch)
 Compute from a current Chain state.
void NewState (State &s)
 Compute from a supplied State vector.
void SetControl (int)
 Set global parameters.
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).
virtual void LogState (string &logfile)
 Add state to log file.
virtual void LogState (int level, int iterno, string &outfile)
 WITH level and iteration values.

Protected Member Functions

virtual void MCMethod ()
 Compute one step in the Markov Chain.
void CreateChains ()
 Create the chain structures.
void ResetChainStats ()
 For gathering diagnostic data.
void getChainCounts ()

Protected Attributes

MHWidthwidth
 The Metropolis-Hastings width instance.
bool caching
 True if chain data is to be invidually logged.
vector< int > stat0
vector< int > stat1
bool chains_initialized
 True if state values have been computed for at least the first time.
vector< unsigned char > update_flag
 State variables.
vector< unsigned char > update_flag1
 Chain values from this node need to be communicated.
vector< unsigned long > nstat0
 Swaps proposed tallied for each chain.
vector< unsigned long > nstat1
 Swaps accepted tallied for each chain.
deque< vector< unsigned char > > arate
 Acceptence rates for each chain.

Friends

class boost::serialization::access


Detailed Description

Runs the user-specified number of chains in parallel using the user-specified Monte Carlo algorithm (mca).

Each state will be written into the output log. Per chain statistics are computed and printed to stdout if the global variable mstat=1, as usual. This class will probably be used with a parallel chain convergence class such as GelmanRubinConverge.

Configuration
There are two obvious possibilities for arranging the computation.
  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.
Example
See script8 in examples/User/parallel

Member Enumeration Documentation

Parallelization type.

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


Member Function Documentation

void BIE::MultipleChains::NewState ( int  Mcur,
vector< double > &  w,
vector< vector< double > > &  p 
) [virtual]

Initialize new state (override from Simulation).

Compute from mixture cardinality, component weight vector and component parameter vectors

Reimplemented from BIE::Simulation.

void BIE::MultipleChains::SetControl ( int   ) 

Set global parameters.

Choose parallelization control (parallel=0, serial=1)

virtual void BIE::MultipleChains::LogState ( string &  logfile  )  [virtual]

Add state to log file.

WITHOUT level and iteration values

Reimplemented from BIE::Simulation.

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

Override of Simulation method to provide state specific diagnostics.

Here, the method provides mixing statistics.

Reimplemented from BIE::Simulation.

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

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

Sample new state for chain k


Member Data Documentation

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

State variables.

Chain values need to be communicated globally

unsigned BIE::MultipleChains::ncount [protected]

Convergence check.

Number of steps so far


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