25 #include <queso/MetropolisAdjustedLangevinTK.h> 
   26 #include <queso/GslVector.h> 
   27 #include <queso/GslMatrix.h> 
   28 #include <queso/GaussianJointPdf.h> 
   29 #include <queso/BayesianJointPdf.h> 
   33 template <
class V, 
class M>
 
   37   const std::vector<double> & scales,
 
   40   BaseTKGroup<V, M>(prefix, targetPdf.domainSet().vectorSpace(), scales),
 
   41   m_originalCovMatrix(covMatrix),
 
   42   m_targetPdf(targetPdf),
 
   52                            << 
": m_scales.size() = "                << 
m_scales.size()
 
   54                            << 
", m_rvs.size() = "                   << 
m_rvs.size()
 
   67 template <
class V, 
class M>
 
   72 template <
class V, 
class M>
 
   79 template <
class V, 
class M>
 
   88   if ((m_env.subDisplayFile()        ) &&
 
   89       (m_env.displayVerbosity() >= 10)) {
 
   90     *m_env.subDisplayFile() << 
"In MetropolisAdjustedLangevinTK<V, M>::rv1()" 
   91                             << 
", stageId = " << stageId
 
   92                             << 
": about to call m_rvs[0]->updateLawExpVector()" 
   93                             << 
", vector = " << *m_preComputingPositions[stageId] 
 
  101   return (*gaussian_rv);
 
  104 template <
class V, 
class M>
 
  113   if ((m_env.subDisplayFile()        ) &&
 
  114       (m_env.displayVerbosity() >= 10)) {
 
  115     *m_env.subDisplayFile() << 
"In MetropolisAdjustedLangevinTK<V, M>::rv2()" 
  116                             << 
", stageIds.size() = " << stageIds.size()
 
  117                             << 
", stageIds[0] = "     << stageIds[0]
 
  118                             << 
": about to call m_rvs[stageIds.size()-1]->updateLawExpVector()" 
  119                             << 
", vector = " << *m_preComputingPositions[stageIds[0]] 
 
  127   return (*gaussian_rv);
 
  130 template <
class V, 
class M>
 
  143   V grad(this->m_targetPdf.domainSet().vectorSpace().zeroVector());
 
  147   this->m_targetPdf.lnValue(position, NULL, &grad, NULL, NULL);
 
  150   grad *= 0.5 * this->m_time_step;
 
  159   return (*gaussian_rv);
 
  162 template <
class V, 
class M>
 
  166   for (
unsigned int i = 0; i < m_scales.size(); ++i) {
 
  167     double factor = 1./m_scales[i]/m_scales[i];
 
  168     if ((m_env.subDisplayFile()        ) &&
 
  169         (m_env.displayVerbosity() >= 10)) {
 
  170       *m_env.subDisplayFile() << 
"In MetropolisAdjustedLangevinTK<V, M>::updateLawCovMatrix()" 
  171                               << 
", m_scales.size() = " << m_scales.size()
 
  173                               << 
", m_scales[i] = "     << m_scales[i]
 
  174                               << 
", factor = "          << factor
 
  175                               << 
": about to call m_rvs[i]->updateLawCovMatrix()" 
  176                               << 
", covMatrix = \n" << factor*covMatrix 
 
  183 template <
class V, 
class M>
 
  187   if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 5)) {
 
  188     *m_env.subDisplayFile() << 
"Entering MetropolisAdjustedLangevinTK<V, M>::setPreComputingPosition()" 
  189                            << 
": position = " << position
 
  190                            << 
", stageId = "  << stageId
 
  196   if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 5)) {
 
  197     *m_env.subDisplayFile() << 
"In MetropolisAdjustedLangevinTK<V, M>::setPreComputingPosition()" 
  198                            << 
", position = "        << position
 
  199                            << 
", stageId = "         << stageId
 
  200                            << 
": preComputingPos = " << *m_preComputingPositions[stageId];
 
  201     if (stageId < m_scales.size()) {
 
  202       *m_env.subDisplayFile() << 
", factor = " << 1./m_scales[stageId]/m_scales[stageId];
 
  204     if (stageId < m_rvs.size()) {
 
  206       *m_env.subDisplayFile() << 
", rvCov = " << pdfPtr->
lawCovMatrix(); 
 
  208     *m_env.subDisplayFile() << std::endl;
 
  211   if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 5)) {
 
  212     *m_env.subDisplayFile() << 
"Leaving MetropolisAdjustedLangevinTK<V, M>::setPreComputingPosition()" 
  213                            << 
": position = " << position
 
  214                            << 
", stageId = "  << stageId
 
  221 template <
class V, 
class M>
 
  228 template <
class V, 
class M>
 
  235   for (
unsigned int i = 0; i < m_scales.size(); ++i) {
 
  236     double factor = 1./m_scales[i]/m_scales[i];
 
  240                                          m_vectorSpace->zeroVector(),
 
  241                                          factor*m_time_step*m_originalCovMatrix);
 
  245 template <
class V, 
class M>
 
void updateLawExpVector(const V &newLawExpVector)
Updates the vector that contains the mean values. 
 
std::ofstream * subDisplayFile() const 
Access function for m_subDisplayFile (displays file on stream). 
 
virtual void clearPreComputingPositions()
Clears the pre-computing positions m_preComputingPositions[stageId]. 
 
A class for handling Bayesian joint PDFs. 
 
void print(std::ostream &os) const 
TODO: Prints the transition kernel. 
 
virtual void print(std::ostream &os) const 
TODO: Prints the transition kernel. 
 
std::vector< const V * > m_preComputingPositions
 
void clearPreComputingPositions()
Clears the pre-computing positions m_preComputingPositions[stageId]. 
 
#define queso_require_not_equal_to(expr1, expr2)
 
bool symmetric() const 
Whether or not the matrix is symmetric. Always 'true'. 
 
#define queso_require_greater_equal(expr1, expr2)
 
std::vector< BaseVectorRV< V, M > * > m_rvs
 
#define queso_require_greater(expr1, expr2)
 
virtual bool setPreComputingPosition(const V &position, unsigned int stageId)
Sets the pre-computing positions m_preComputingPositions[stageId] with a new vector of size position...
 
#define queso_require_equal_to(expr1, expr2)
 
#define queso_require(asserted)
 
unsigned int displayVerbosity() const 
 
A class for handling Gaussian joint PDFs. 
 
This base class allows the representation of a transition kernel. 
 
This class allows the representation of the MALA transition kernel with a scaled covariance matrix fo...
 
A class representing a Gaussian vector RV. 
 
~MetropolisAdjustedLangevinTK()
Destructor. 
 
void updateLawCovMatrix(const M &covMatrix)
Scales the covariance matrix. 
 
bool setPreComputingPosition(const V &position, unsigned int stageId)
Sets the pre-computing positions m_preComputingPositions[stageId] with a new vector of size position...
 
void setRVsWithZeroMean()
Sets the mean of the RVs to zero. 
 
const BaseEnvironment & m_env
 
const GaussianVectorRV< V, M > & rv(unsigned int stageId) const 
Gaussian increment property to construct a transition kernel. 
 
MetropolisAdjustedLangevinTK(const char *prefix, const BayesianJointPdf< V, M > &targetPdf, const std::vector< double > &scales, const M &covMatrix)
Default constructor. 
 
std::vector< double > m_scales
 
const M & lawCovMatrix() const 
Returns the covariance matrix; access to protected attribute m_lawCovMatrix.