BIE::DifferentialEvolution Class Reference

Implements the Differential Evolution (DE) algorithm following the manuscript of Cajo J. More...

#include <DifferentialEvolution.h>

Inheritance diagram for BIE::DifferentialEvolution:
Collaboration diagram for BIE::DifferentialEvolution:

List of all members.

Global variables

enum  Control { parallel, serial }
 Parallelization type. More...
enum  Distrib { uniform, gaussian, cauchy }
 Symmetric distribution. More...
static Control cntrl
 Current control.
static int minmc
 Minimum number of chains.
static int state_iter
 Number of iterations allowed for finding a good initial state.
static double tiny
 Small pos double "machine" constant (default: double=1.0e-12).
static unsigned jfreq
 Frequency in steps for setting $gamma=1$ (default: 10).
static bool linear
 Use linear or logit mapping for variables (default: false).
static unsigned nfifo
 Number of states for acceptance rate queue.

Public Member Functions

 DifferentialEvolution (int max, int ndim, int number, string deinit, BaseDataTree *d, Model *m, Integration *i, Converge *c, MixturePrior *mp, LikelihoodComputation *l, MCAlgorithm *mca, Simulation *last=0)
 Constructor for top level invocation.
virtual ~DifferentialEvolution ()
 Destructor.
virtual void Initialize ()
 Initialize all the chains.
virtual void Reinitialize (MHWidth *width, MixturePrior *mp)
 Reinitialize with new class instances.
void PrintState ()
 Print current state (override).
virtual void PrintStepDiagnostic ()
 override of Simulation method to provide diagnostics specific to DifferentialEvolution
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 NewNumber (int)
 Specify the number of desired chains.
void NewGamma (double p)
 Change the shift length from the default.
void EnableLogging ()
 Enable caching per chain.
void SetLinearMapping (bool b)
 Change mapping from logit to linear (or vice versa).
void SetJumpFreq (int n)
 Change jump frequency for multimodel mixing (default: 10).
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 the state from the Chain value.
void NewState (State &s)
 Compute the state from the State value.
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)

Protected Member Functions

virtual void MCMethod ()
 The Markov Chain implementation.
void CreateChains ()
 Create the chain structures.
void SampleNewState (int k)
 Attempt to find a good state from the prior distribution for chain k.
void SampleNewStateParallel (int k)
 Use the parallel version (called by SampleNewState()).
void NewStateSerialInit ()
 Serial sampling init.
void SampleNewStateSerial (int k)
 Use the serial version (called by SampleNewState()).
void NewStateSerialStatus ()
 Check the status of the initialization.
void TrialState (int zero, int one, int two)
 Compute the trial state from the selected particles.
void InitializeSampler (string epsfile)
 Initialize the random part of the sampler from the input file.
double Logit (double x)
 Logit distribution.
double InverseLogit (double q)
 The inverse Logit distribution.
double Map (double x, double a, double b)
 Map from finite to infinite interval.
double InverseMap (double q, double a, double b)
 Map from infinite back to the finite interval.
void ResetChainStats ()
 For gathering diagnostic data.

Protected Attributes

MHWidthwidth
 The Metropolis-Hastings width instance.
double gamma0
 The default (not mode-swapping) value for the proposal direction magntiude.
double gamma
 The current value of gamma.
unsigned ncount
 Internal counter for mode swapping.
bool caching
 Used to flag logging of each chain state.
vector< Random * > distrib
 Random distribution for parameters when generating trial states.
vector< unsigned short > fail
 Status vector for sampling new states.
Chain chainT
 Trial Chain instance.
Uniform * unit
 Unit interval variates.
bool chains_initialized
 True if state values have been computed for at least the first time.
vector< double > _lower
 Lower limit on values imposed by prior.
vector< double > _upper
 Upper limit on values imposed by prior.
double _minw
 Lower limit on weights imposed by prior.
double _maxw
 Upper limit on weights imposed by prior.
unsigned int R0
 State variables.
vector< unsigned char > update_flag
 Does the chain need to be updated?
vector< unsigned char > update_flag1
 For MPI, chains that need to be updated on each node.
vector< unsigned long > nstat0
 Tally of proposals for each chain.
vector< unsigned long > nstat1
 Tally of accepted proposals for each chain.
deque< vector< unsigned char > > arate
 Used to compute chain acceptence rates.
int Ntot
 Maximum dimension of the state vector.
vector< double > philower
 Minimum allowed value for the parameter vector.
vector< double > phiupper
 Maximum allowed value for the parameter vector.
int totalnum
 Convergence check.
int totaltry

Friends

class boost::serialization::access


Detailed Description

Implements the Differential Evolution (DE) algorithm following the manuscript of Cajo J.

F. Ter Braak (Stat Comput 2006, 16:239-249)

Intro
Differential evolution uses parallel running Markov Chains with overdispersed initial conditions to set width of the proposal function. It, therefore, is adaptatively capable of handling nondifferentiable, nonlinear and multimodal objective functions.
Brief description
The algorithm works as follows. At each iteration, sometimes called a generation in the DE literature, new state vectors are shifted by the difference of a random selection of state vectors chosen from other chain plus a random variate chosen from a "background" distribution with unbounded support.
Parameters
The shift length is determined from the optimal estimate of the unimodal Gaussian (Roberts and Rosenthal 2001) to be:

\[ \gamma //! = {2.38\over\sqrt{(2d)}} //! \]

where $d$ is the number of dimensions. This can be changed manually using the NewGamma member. In particular, the default value of $\gamma$ may need to be reduced from the optimal to achieve a healthy acceptence rate for proposed new states.

Input file
The fourth parameter is string value for the file containing the chain-independent random variate parameters. The first line is the distribution type followed by the width of the symmetric sampling distribution for the weight parameters. Each successive line describes specifies sampling distribution for each parameter in the mixture model and contains four values: the symmetric sampling distribution, the width, and the upper and lower limit for the parameter. The available symmetric distributions are listed in the enum Distrib.
Parameter range mapping
All finite parameters ranges $(a, b)$ may be mapped using a Logit function, e.g.

\[ //! q = M(x, a, b) = \log\left( {x-a\over b-x} \right) //! \]

and

\[ //! M^{-1}(q, a, b) = {b + ae^{-q}\over 1+e^{-q}}. //! \]

A standard linear mapping is better under many situations so linear mapping is the default (see SetLinearMapping).

Control methods
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 script27 in examples/Splats/parallel

Member Enumeration Documentation

Parallelization type.

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

Symmetric distribution.

Enumerator:
uniform  uniform distribution centered at zero.
gaussian  Normal distribution with given sigma.
cauchy  Cauchy distribution with given scale.


Constructor & Destructor Documentation

BIE::DifferentialEvolution::DifferentialEvolution ( int  max,
int  ndim,
int  number,
string  deinit,
BaseDataTree d,
Model m,
Integration i,
Converge c,
MixturePrior mp,
LikelihoodComputation l,
MCAlgorithm mca,
Simulation last = 0 
)

Constructor for top level invocation.

Constructor for multiple-level invocation


Member Function Documentation

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

Initialize new state (override from Simulation).

Compute the state from the cardinality, weights and parameters

Reimplemented from BIE::Simulation.

void BIE::DifferentialEvolution::SetControl ( int   ) 

Set global parameters.

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

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

override of Simulation method to provide state specific diagnostics.

Here, the method provides mixing statistics.

Reimplemented from BIE::Simulation.

void BIE::DifferentialEvolution::InitializeSampler ( string  epsfile  )  [protected]

Initialize the random part of the sampler from the input file.

Parameters:
epsfile 


Member Data Documentation

unsigned int BIE::DifferentialEvolution::R0 [protected]

State variables.

The index of the current fiducial chain


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