queso-0.50.1
Private Attributes | List of all members
QUESO::StatisticalInverseProblem< P_V, P_M > Class Template Reference

This templated class represents a Statistical Inverse Problem. More...

#include <StatisticalInverseProblem.h>

Collaboration diagram for QUESO::StatisticalInverseProblem< P_V, P_M >:
Collaboration graph
[legend]

Public Member Functions

Constructor/Destructor methods
 StatisticalInverseProblem (const char *prefix, const SipOptionsValues *alternativeOptionsValues, const BaseVectorRV< P_V, P_M > &priorRv, const BaseScalarFunction< P_V, P_M > &likelihoodFunction, GenericVectorRV< P_V, P_M > &postRv)
 Constructor. More...
 
 ~StatisticalInverseProblem ()
 Destructor. More...
 
Statistical methods
bool computeSolutionFlag () const
 Whether or not compute the solution. More...
 
void solveWithBayesMetropolisHastings (const MhOptionsValues *alternativeOptionsValues, const P_V &initialValues, const P_M *initialProposalCovMatrix)
 Solves the problem through Bayes formula and a Metropolis-Hastings algorithm. More...
 
void solveWithBayesMLSampling ()
 Solves with Bayes Multi-Level (ML) sampling. More...
 
const BaseVectorRV< P_V, P_M > & priorRv () const
 Returns the Prior RV; access to private attribute m_priorRv. More...
 
const GenericVectorRV< P_V, P_M > & postRv () const
 Returns the Posterior RV; access to private attribute m_postrRv. More...
 
double logEvidence () const
 Returns the logarithm value of the evidence. Related to ML. More...
 
double meanLogLikelihood () const
 Returns the mean of the logarithm value of the likelihood. Related to ML. More...
 
double eig () const
 

Private Attributes

const BaseEnvironmentm_env
 
const BaseVectorRV< P_V, P_M > & m_priorRv
 
const BaseScalarFunction< P_V,
P_M > & 
m_likelihoodFunction
 
GenericVectorRV< P_V, P_M > & m_postRv
 
VectorSet< P_V, P_M > * m_solutionDomain
 
BaseJointPdf< P_V, P_M > * m_solutionPdf
 
BaseVectorMdf< P_V, P_M > * m_subSolutionMdf
 
BaseVectorCdf< P_V, P_M > * m_subSolutionCdf
 
BaseVectorRealizer< P_V, P_M > * m_solutionRealizer
 
MetropolisHastingsSG< P_V, P_M > * m_mhSeqGenerator
 
MLSampling< P_V, P_M > * m_mlSampler
 
BaseVectorSequence< P_V, P_M > * m_chain
 
ScalarSequence< double > * m_logLikelihoodValues
 
ScalarSequence< double > * m_logTargetValues
 
SipOptionsValues m_alternativeOptionsValues
 
StatisticalInverseProblemOptionsm_optionsObj
 

I/O methods

void print (std::ostream &os) const
 TODO: Prints the sequence. More...
 
std::ostream & operator<< (std::ostream &os, const StatisticalInverseProblem< P_V, P_M > &obj)
 

Detailed Description

template<class P_V, class P_M>
class QUESO::StatisticalInverseProblem< P_V, P_M >

This templated class represents a Statistical Inverse Problem.

This class is templated on the type 'P_V' of vector and type 'P_M' of matrix, where 'P_' stands for 'parameter'. Some templated classes might also use 'Q_V' and 'Q_M' when referring to a vector type and a matrix type, where 'Q_' stands for 'quantities of interest'. Conceptually, a statistical inverse problem has two input entities and one output entity.
The input entities of a statistical inverse problem are:

  1. the prior RV, an instance of class 'BaseVectorRV<P_V,P_M>', and
  2. the likelihood function, an instance of class 'BaseScalarFunction<P_V,P_M>'.

Let $ \pi()$ denote the mathematical likelihood function and $ x $ denote a vector of parameters. The likelihood function object stores the routine that computes $ \pi(x) $ and whatever data necessary by such routine. The routine in the likelihood function object can compute either the actual value $ \pi(x) $ or the value $ \ln[\pi(x)] $. See files 'basic/inc/ScalarFunction.h' and 'stats/inc/JointPdf.h' for more details.
The output entity of a statistical inverse problem is the posterior RV, another instance of class 'BaseVectorRV<P_V,P_M>', which stores the solution according to the Bayesian approach. Upon return from a solution operation, the posterior RV is available through the operation 'postRv()'. Such posterior RV is able to provide:

  1. a joint pdf (up to a multiplicative constant) through the operation 'postRv().pdf()', which returns an instance of the class 'BaseJointPdf<P_V,P_M>', and
  2. a vector realizer through the operation 'postRv().realizer()', which returns an instance of the class 'BaseVectorRealizer<P_V,P_M>'.

Definition at line 80 of file StatisticalInverseProblem.h.

Constructor & Destructor Documentation

template<class P_V , class P_M >
QUESO::StatisticalInverseProblem< P_V, P_M >::StatisticalInverseProblem ( const char *  prefix,
const SipOptionsValues alternativeOptionsValues,
const BaseVectorRV< P_V, P_M > &  priorRv,
const BaseScalarFunction< P_V, P_M > &  likelihoodFunction,
GenericVectorRV< P_V, P_M > &  postRv 
)

Constructor.

Requirements: 1) the image set of the vector random variable 'priorRv', 2) the domain set of the likelihood function 'likelihoodFunction' and 3) the image set of the vector random variable 'postRv' should belong to vector spaces of equal dimensions. If the requirements are satisfied, the constructor then reads input options that begin with the string '<prefix>ip_'. If no options input file is provided, the construction assigns alternativeOptionsValues to the options of the SIP.

Parameters
prefixThe prefix
alternativeOptionsValuesOptions (if no input file)
priorRvThe prior RV
likelihoodFunctionThe likelihood function
postRvThe posterior RV

Definition at line 33 of file StatisticalInverseProblem.C.

References UQ_FATAL_TEST_MACRO.

39  :
40  m_env (priorRv.env()),
41  m_priorRv (priorRv),
42  m_likelihoodFunction (likelihoodFunction),
43  m_postRv (postRv),
44  m_solutionDomain (NULL),
45  m_solutionPdf (NULL),
46  m_subSolutionMdf (NULL),
47  m_subSolutionCdf (NULL),
48  m_solutionRealizer (NULL),
49  m_mhSeqGenerator (NULL),
50  m_mlSampler (NULL),
51  m_chain (NULL),
52  m_logLikelihoodValues (NULL),
53  m_logTargetValues (NULL),
55  m_optionsObj (NULL)
56 {
57 #ifdef QUESO_MEMORY_DEBUGGING
58  std::cout << "Entering Sip" << std::endl;
59 #endif
60  if (m_env.subDisplayFile()) {
61  *m_env.subDisplayFile() << "Entering StatisticalInverseProblem<P_V,P_M>::constructor()"
62  << ": prefix = " << prefix
63  << ", alternativeOptionsValues = " << alternativeOptionsValues
64  << ", m_env.optionsInputFileName() = " << m_env.optionsInputFileName()
65  << std::endl;
66  }
67 
68  if (alternativeOptionsValues) m_alternativeOptionsValues = *alternativeOptionsValues;
69  if (m_env.optionsInputFileName() == "") {
70  m_optionsObj = new StatisticalInverseProblemOptions(m_env,prefix,m_alternativeOptionsValues);
71  }
72  else {
73  m_optionsObj = new StatisticalInverseProblemOptions(m_env,prefix);
75  }
76 #ifdef QUESO_MEMORY_DEBUGGING
77  std::cout << "In Sip, finished scanning options" << std::endl;
78 #endif
79 
80  UQ_FATAL_TEST_MACRO(priorRv.imageSet().vectorSpace().dimLocal() != likelihoodFunction.domainSet().vectorSpace().dimLocal(),
81  m_env.worldRank(),
82  "StatisticalInverseProblem<P_V,P_M>::constructor()",
83  "'priorRv' and 'likelihoodFunction' are related to vector spaces of different dimensions");
84 
85  UQ_FATAL_TEST_MACRO(priorRv.imageSet().vectorSpace().dimLocal() != postRv.imageSet().vectorSpace().dimLocal(),
86  m_env.worldRank(),
87  "StatisticalInverseProblem<P_V,P_M>::constructor()",
88  "'priorRv' and 'postRv' are related to vector spaces of different dimensions");
89 
90  if (m_env.subDisplayFile()) {
91  *m_env.subDisplayFile() << "Leaving StatisticalInverseProblem<P_V,P_M>::constructor()"
92  << ": prefix = " << m_optionsObj->m_prefix
93  << std::endl;
94  }
95 
96  return;
97 }
MetropolisHastingsSG< P_V, P_M > * m_mhSeqGenerator
const BaseVectorRV< P_V, P_M > & m_priorRv
BaseVectorSequence< P_V, P_M > * m_chain
void scanOptionsValues()
It scans the option values from the options input file.
GenericVectorRV< P_V, P_M > & m_postRv
int worldRank() const
Returns the process world rank.
Definition: Environment.C:235
BaseJointPdf< P_V, P_M > * m_solutionPdf
std::ofstream * subDisplayFile() const
Access function for m_subDisplayFile (displays file on stream).
Definition: Environment.C:305
ScalarSequence< double > * m_logLikelihoodValues
BaseVectorCdf< P_V, P_M > * m_subSolutionCdf
virtual const VectorSpace< V, M > & vectorSpace() const =0
Vector space to which this set belongs to. See template specialization.
StatisticalInverseProblemOptions * m_optionsObj
unsigned int dimLocal() const
Definition: VectorSpace.C:199
const BaseEnvironment & env() const
QUESO environment; access to private attribute m_env.
Definition: VectorRV.C:72
std::string optionsInputFileName() const
Access to the attribute m_optionsInputFileName, which stores the name of the input file passed by the...
Definition: Environment.C:341
#define UQ_FATAL_TEST_MACRO(test, givenRank, where, what)
Definition: Defines.h:222
const VectorSet< V, M > & imageSet() const
Image set of the vector RV; access to private attribute m_imageSet.
Definition: VectorRV.C:79
BaseVectorRealizer< P_V, P_M > * m_solutionRealizer
const VectorSet< V, M > & domainSet() const
Access to the protected attribute m_domainSet: domain set of the scalar function. ...
ScalarSequence< double > * m_logTargetValues
BaseVectorMdf< P_V, P_M > * m_subSolutionMdf
const BaseScalarFunction< P_V, P_M > & m_likelihoodFunction
template<class P_V , class P_M >
QUESO::StatisticalInverseProblem< P_V, P_M >::~StatisticalInverseProblem ( )

Destructor.

Definition at line 101 of file StatisticalInverseProblem.C.

102 {
103  if (m_chain) {
104  m_chain->clear();
105  delete m_chain;
106  }
107  if (m_logLikelihoodValues) {
109  delete m_logLikelihoodValues;
110  }
111  if (m_logTargetValues) {
113  delete m_logTargetValues;
114  }
115  if (m_mlSampler ) delete m_mlSampler;
116  if (m_mhSeqGenerator ) delete m_mhSeqGenerator;
118  if (m_subSolutionCdf ) delete m_subSolutionCdf;
119  if (m_subSolutionMdf ) delete m_subSolutionMdf;
120  if (m_solutionPdf ) delete m_solutionPdf;
121  if (m_solutionDomain ) delete m_solutionDomain;
122  if (m_optionsObj ) delete m_optionsObj;
123 }
MetropolisHastingsSG< P_V, P_M > * m_mhSeqGenerator
BaseVectorSequence< P_V, P_M > * m_chain
BaseJointPdf< P_V, P_M > * m_solutionPdf
ScalarSequence< double > * m_logLikelihoodValues
BaseVectorCdf< P_V, P_M > * m_subSolutionCdf
void clear()
Clears the sequence of scalars.
StatisticalInverseProblemOptions * m_optionsObj
BaseVectorRealizer< P_V, P_M > * m_solutionRealizer
ScalarSequence< double > * m_logTargetValues
void clear()
Reset the values and the size of the sequence of vectors.
BaseVectorMdf< P_V, P_M > * m_subSolutionMdf

Member Function Documentation

template<class P_V, class P_M>
bool QUESO::StatisticalInverseProblem< P_V, P_M >::computeSolutionFlag ( ) const

Whether or not compute the solution.

template<class P_V , class P_M >
double QUESO::StatisticalInverseProblem< P_V, P_M >::eig ( ) const

Definition at line 376 of file StatisticalInverseProblem.C.

References UQ_FATAL_TEST_MACRO.

377 {
379  m_env.worldRank(),
380  "StatisticalInverseProblem<P_V,P_M>::eig()",
381  "m_mlSampler is NULL");
382  return m_mlSampler->eig();
383 }
int worldRank() const
Returns the process world rank.
Definition: Environment.C:235
#define UQ_FATAL_TEST_MACRO(test, givenRank, where, what)
Definition: Defines.h:222
template<class P_V , class P_M >
double QUESO::StatisticalInverseProblem< P_V, P_M >::logEvidence ( ) const

Returns the logarithm value of the evidence. Related to ML.

Definition at line 356 of file StatisticalInverseProblem.C.

References UQ_FATAL_TEST_MACRO.

357 {
359  m_env.worldRank(),
360  "StatisticalInverseProblem<P_V,P_M>::logEvidence()",
361  "m_mlSampler is NULL");
362  return m_mlSampler->logEvidence();
363 }
int worldRank() const
Returns the process world rank.
Definition: Environment.C:235
#define UQ_FATAL_TEST_MACRO(test, givenRank, where, what)
Definition: Defines.h:222
template<class P_V , class P_M >
double QUESO::StatisticalInverseProblem< P_V, P_M >::meanLogLikelihood ( ) const

Returns the mean of the logarithm value of the likelihood. Related to ML.

Definition at line 366 of file StatisticalInverseProblem.C.

References UQ_FATAL_TEST_MACRO.

367 {
369  m_env.worldRank(),
370  "StatisticalInverseProblem<P_V,P_M>::meanLogLikelihood()",
371  "m_mlSampler is NULL");
372  return m_mlSampler->meanLogLikelihood();
373 }
int worldRank() const
Returns the process world rank.
Definition: Environment.C:235
#define UQ_FATAL_TEST_MACRO(test, givenRank, where, what)
Definition: Defines.h:222
template<class P_V , class P_M >
const GenericVectorRV< P_V, P_M > & QUESO::StatisticalInverseProblem< P_V, P_M >::postRv ( ) const

Returns the Posterior RV; access to private attribute m_postrRv.

The Posterior RV contains the solution of the Bayes problem.

Definition at line 350 of file StatisticalInverseProblem.C.

351 {
352  return m_postRv;
353 }
GenericVectorRV< P_V, P_M > & m_postRv
template<class P_V , class P_M >
void QUESO::StatisticalInverseProblem< P_V, P_M >::print ( std::ostream &  os) const

TODO: Prints the sequence.

Todo:
: implement me!

Definition at line 387 of file StatisticalInverseProblem.C.

388 {
389  return;
390 }
template<class P_V , class P_M >
const BaseVectorRV< P_V, P_M > & QUESO::StatisticalInverseProblem< P_V, P_M >::priorRv ( ) const

Returns the Prior RV; access to private attribute m_priorRv.

Definition at line 343 of file StatisticalInverseProblem.C.

344 {
345  return m_priorRv;
346 }
const BaseVectorRV< P_V, P_M > & m_priorRv
template<class P_V , class P_M >
void QUESO::StatisticalInverseProblem< P_V, P_M >::solveWithBayesMetropolisHastings ( const MhOptionsValues alternativeOptionsValues,
const P_V &  initialValues,
const P_M *  initialProposalCovMatrix 
)

Solves the problem through Bayes formula and a Metropolis-Hastings algorithm.

  Requirements: 1) 'initialValues' should have the same number of components as member variable
 'm_priorRv' and 2) if 'initialProposalCovMatrix' is not NULL, it should be square and its size 
 should be equal to the size of 'initialValues'. If the requirements are satisfied, this methods
 checks the member flag 'm_computeSolution' (one of the options read from the input file during 
 construction). If the flag is 'false', the operation returns immediately, computing nothing; 
 otherwise, the operation sets the member variable 'm_postRv' accordingly. The operation:
  1. sets the pdf of 'm_postRv' equal to an instance of 'BayesianJointPdf<P_V,P_M>',
  2. instantiates 'SequenceOfVectors<P_V,P_M>' (the chain),
  3. instantiates 'MetropolisHastingsSG<P_V,P_M>' (the Metropolis-Hastings algorithm),
  4. populates the chain with the Metropolis-Hastings algorithm, and
  5. sets the realizer of 'm_postRv' with the contents of the chain.

Definition at line 127 of file StatisticalInverseProblem.C.

References QUESO::InstantiateIntersection(), UQ_FATAL_TEST_MACRO, and UQ_SIP_FILENAME_FOR_NO_FILE.

131 {
132  //grvy_timer_begin("BayesMetropolisHastings"); TODO: revisit timing output
133  //std::cout << "proc " << m_env.fullRank() << ", HERE sip 000" << std::endl;
134  m_env.fullComm().Barrier();
135  //std::cout << "proc " << m_env.fullRank() << ", HERE sip 001" << std::endl;
136  m_env.fullComm().syncPrintDebugMsg("Entering StatisticalInverseProblem<P_V,P_M>::solveWithBayesMetropolisHastings()",1,3000000);
137 
138  if (m_optionsObj->m_ov.m_computeSolution == false) {
139  if ((m_env.subDisplayFile())) {
140  *m_env.subDisplayFile() << "In StatisticalInverseProblem<P_V,P_M>::solveWithBayesMetropolisHastings()"
141  << ": avoiding solution, as requested by user"
142  << std::endl;
143  }
144  return;
145  }
146  if ((m_env.subDisplayFile())) {
147  *m_env.subDisplayFile() << "In StatisticalInverseProblem<P_V,P_M>::solveWithBayesMetropolisHastings()"
148  << ": computing solution, as requested by user"
149  << std::endl;
150  }
151 
152  UQ_FATAL_TEST_MACRO(m_priorRv.imageSet().vectorSpace().dimLocal() != initialValues.sizeLocal(),
153  m_env.worldRank(),
154  "StatisticalInverseProblem<P_V,P_M>::solveWithBayesMetropolisHastings()",
155  "'m_priorRv' and 'initialValues' should have equal dimensions");
156 
157  if (initialProposalCovMatrix) {
158  UQ_FATAL_TEST_MACRO(m_priorRv.imageSet().vectorSpace().dimLocal() != initialProposalCovMatrix->numRowsLocal(),
159  m_env.worldRank(),
160  "StatisticalInverseProblem<P_V,P_M>::solveWithBayesMetropolisHastings()",
161  "'m_priorRv' and 'initialProposalCovMatrix' should have equal dimensions");
162  UQ_FATAL_TEST_MACRO(initialProposalCovMatrix->numCols() != initialProposalCovMatrix->numRowsGlobal(),
163  m_env.worldRank(),
164  "StatisticalInverseProblem<P_V,P_M>::solveWithBayesMetropolisHastings()",
165  "'initialProposalCovMatrix' should be a square matrix");
166  }
167 
168  if (m_mlSampler ) delete m_mlSampler;
169  if (m_mhSeqGenerator ) delete m_mhSeqGenerator;
171  if (m_subSolutionCdf ) delete m_subSolutionCdf;
172  if (m_subSolutionMdf ) delete m_subSolutionMdf;
173  if (m_solutionPdf ) delete m_solutionPdf;
174  if (m_solutionDomain ) delete m_solutionDomain;
175 
176  P_V numEvaluationPointsVec(m_priorRv.imageSet().vectorSpace().zeroVector());
177  numEvaluationPointsVec.cwSet(250.);
178 
179  // Compute output pdf up to a multiplicative constant: Bayesian approach
181 
182  m_solutionPdf = new BayesianJointPdf<P_V,P_M>(m_optionsObj->m_prefix.c_str(),
183  m_priorRv.pdf(),
185  1.,
187 
188  m_postRv.setPdf(*m_solutionPdf);
189 
190  // Compute output realizer: Metropolis-Hastings approach
191  m_chain = new SequenceOfVectors<P_V,P_M>(m_postRv.imageSet().vectorSpace(),0,m_optionsObj->m_prefix+"chain");
192  m_logLikelihoodValues = new ScalarSequence<double> (m_env,0,m_optionsObj->m_prefix+"logLike" );
193  m_logTargetValues = new ScalarSequence<double> (m_env,0,m_optionsObj->m_prefix+"logTarget");
194  m_mhSeqGenerator = new MetropolisHastingsSG<P_V,P_M>(m_optionsObj->m_prefix.c_str(), // dakota
195  alternativeOptionsValues,
196  m_postRv,
197  initialValues,
198  initialProposalCovMatrix);
199 
200  m_mhSeqGenerator->generateSequence(*m_chain,
201  NULL, //m_logLikelihoodValues,
202  NULL);//m_logTargetValues);
203 
204  m_solutionRealizer = new SequentialVectorRealizer<P_V,P_M>(m_optionsObj->m_prefix.c_str(),
205  *m_chain);
206 
207  m_postRv.setRealizer(*m_solutionRealizer);
208 
209  m_env.fullComm().syncPrintDebugMsg("In StatisticalInverseProblem<P_V,P_M>::solveWithBayesMetropolisHastings(), code place 1",3,3000000);
210  //m_env.fullComm().Barrier();
211 
212  // Compute output mdf: uniform sampling approach
213 #ifdef UQ_ALSO_COMPUTE_MDFS_WITHOUT_KDE
214  m_subMdfGrids = new ArrayOfOneDGrids <P_V,P_M>((m_optionsObj->m_prefix+"Mdf_").c_str(),m_postRv.imageSet().vectorSpace());
215  m_subMdfValues = new ArrayOfOneDTables<P_V,P_M>((m_optionsObj->m_prefix+"Mdf_").c_str(),m_postRv.imageSet().vectorSpace());
216  m_chain->subUniformlySampledMdf(numEvaluationPointsVec, // input
217  *m_subMdfGrids, // output
218  *m_subMdfValues); // output
219  m_subSolutionMdf = new SampledVectorMdf<P_V,P_M>(m_optionsObj->m_prefix.c_str(),
220  *m_subMdfGrids,
221  *m_subMdfValues);
222  m_postRv.setMdf(*m_subSolutionMdf);
223 
226  if (m_env.subRank() == 0) {
227  // Write data output file
228  if (m_env.subDisplayFile()) {
229  *m_env.subDisplayFile() << "Opening data output file '" << m_optionsObj->m_ov.m_dataOutputFileName
230  << "' for calibration problem with problem with prefix = " << m_optionsObj->m_prefix
231  << std::endl;
232  }
233 
234  // Open file
235  // Always write at the end of an eventual pre-existing file
236  std::ofstream* ofsvar = new std::ofstream((m_optionsObj->m_ov.m_dataOutputFileName+"_sub"+m_env.subIdString()+".m").c_str(), std::ofstream::out | std::ofstream::in | std::ofstream::ate);
237  if ((ofsvar == NULL ) ||
238  (ofsvar->is_open() == false)) {
239  delete ofsvar;
240  ofsvar = new std::ofstream((m_optionsObj->m_ov.m_dataOutputFileName+"_sub"+m_env.subIdString()+".m").c_str(), std::ofstream::out | std::ofstream::trunc);
241  }
242  UQ_FATAL_TEST_MACRO((ofsvar && ofsvar->is_open()) == false,
243  m_env.worldRank(),
244  "StatisticalInverseProblem<P_V,P_M>::solveWithBayesMetropolisHastings()",
245  "failed to open file");
246 
247  m_postRv.mdf().print(*ofsvar);
248 
249  // Close file
250  //ofsvar->close();
251  delete ofsvar;
252  if (m_env.subDisplayFile()) {
253  *m_env.subDisplayFile() << "Closed data output file '" << m_optionsObj->m_ov.m_dataOutputFileName
254  << "' for calibration problem with problem with prefix = " << m_optionsObj->m_prefix
255  << std::endl;
256  }
257  }
258  }
259 #endif
260  if (m_env.subDisplayFile()) {
261  *m_env.subDisplayFile() << std::endl;
262  }
263 
264  m_env.fullComm().syncPrintDebugMsg("Leaving StatisticalInverseProblem<P_V,P_M>::solveWithBayesMetropolisHastings()",1,3000000);
265  m_env.fullComm().Barrier();
266  // grvy_timer_end("BayesMetropolisHastings"); TODO: revisit timers
267  return;
268 }
MetropolisHastingsSG< P_V, P_M > * m_mhSeqGenerator
const BaseVectorRV< P_V, P_M > & m_priorRv
void setPdf(BaseJointPdf< V, M > &pdf)
Sets the PDF of this vector RV to pdf.
BaseVectorSequence< P_V, P_M > * m_chain
const BaseJointPdf< V, M > & pdf() const
Posterior Density Function of the vector RV; access to private attribute m_pdf.
Definition: VectorRV.C:86
GenericVectorRV< P_V, P_M > & m_postRv
int worldRank() const
Returns the process world rank.
Definition: Environment.C:235
BaseJointPdf< P_V, P_M > * m_solutionPdf
std::ofstream * subDisplayFile() const
Access function for m_subDisplayFile (displays file on stream).
Definition: Environment.C:305
ScalarSequence< double > * m_logLikelihoodValues
const V & zeroVector() const
Returns a vector filled with zeros.
Definition: VectorSpace.C:218
BaseVectorCdf< P_V, P_M > * m_subSolutionCdf
const MpiComm & fullComm() const
Access function for MpiComm full communicator.
Definition: Environment.C:247
virtual const VectorSpace< V, M > & vectorSpace() const =0
Vector space to which this set belongs to. See template specialization.
StatisticalInverseProblemOptions * m_optionsObj
unsigned int dimLocal() const
Definition: VectorSpace.C:199
#define UQ_FATAL_TEST_MACRO(test, givenRank, where, what)
Definition: Defines.h:222
const VectorSet< V, M > & imageSet() const
Image set of the vector RV; access to private attribute m_imageSet.
Definition: VectorRV.C:79
BaseVectorRealizer< P_V, P_M > * m_solutionRealizer
void syncPrintDebugMsg(const char *msg, unsigned int msgVerbosity, unsigned int numUSecs) const
Synchronizes all the processes and print debug message.
Definition: MpiComm.C:234
void Barrier() const
Pause every process in *this communicator until all the processes reach this point.
Definition: MpiComm.C:143
const VectorSet< V, M > & domainSet() const
Access to the protected attribute m_domainSet: domain set of the scalar function. ...
ScalarSequence< double > * m_logTargetValues
VectorSet< V, M > * InstantiateIntersection(const VectorSet< V, M > &domain1, const VectorSet< V, M > &domain2)
This method calculates the intersection of domain1 and domain2.
#define UQ_SIP_FILENAME_FOR_NO_FILE
std::set< unsigned int > m_dataOutputAllowedSet
BaseVectorMdf< P_V, P_M > * m_subSolutionMdf
const BaseScalarFunction< P_V, P_M > & m_likelihoodFunction
template<class P_V , class P_M >
void QUESO::StatisticalInverseProblem< P_V, P_M >::solveWithBayesMLSampling ( )

Solves with Bayes Multi-Level (ML) sampling.

Definition at line 272 of file StatisticalInverseProblem.C.

References QUESO::InstantiateIntersection().

273 {
274  m_env.fullComm().Barrier();
275  m_env.fullComm().syncPrintDebugMsg("Entering StatisticalInverseProblem<P_V,P_M>::solveWithBayesMLSampling()",1,3000000);
276 
277  if (m_optionsObj->m_ov.m_computeSolution == false) {
278  if ((m_env.subDisplayFile())) {
279  *m_env.subDisplayFile() << "In StatisticalInverseProblem<P_V,P_M>::solveWithBayesMLSampling()"
280  << ": avoiding solution, as requested by user"
281  << std::endl;
282  }
283  return;
284  }
285  if ((m_env.subDisplayFile())) {
286  *m_env.subDisplayFile() << "In StatisticalInverseProblem<P_V,P_M>::solveWithBayesMLSampling()"
287  << ": computing solution, as requested by user"
288  << std::endl;
289  }
290 
291  if (m_mlSampler ) delete m_mlSampler;
292  if (m_mhSeqGenerator ) delete m_mhSeqGenerator;
294  if (m_subSolutionCdf ) delete m_subSolutionCdf;
295  if (m_subSolutionMdf ) delete m_subSolutionMdf;
296  if (m_solutionPdf ) delete m_solutionPdf;
297  if (m_solutionDomain ) delete m_solutionDomain;
298 
299  P_V numEvaluationPointsVec(m_priorRv.imageSet().vectorSpace().zeroVector());
300  numEvaluationPointsVec.cwSet(250.);
301 
302  // Compute output pdf up to a multiplicative constant: Bayesian approach
304 
305  m_solutionPdf = new BayesianJointPdf<P_V,P_M>(m_optionsObj->m_prefix.c_str(),
306  m_priorRv.pdf(),
308  1.,
310 
311  m_postRv.setPdf(*m_solutionPdf);
312 
313  // Compute output realizer: ML approach
314  m_chain = new SequenceOfVectors<P_V,P_M>(m_postRv.imageSet().vectorSpace(),0,m_optionsObj->m_prefix+"chain");
315  m_mlSampler = new MLSampling<P_V,P_M>(m_optionsObj->m_prefix.c_str(),
316  //m_postRv,
317  m_priorRv,
319  // initialValues,
320  // initialProposalCovMatrix);
321 
322  m_mlSampler->generateSequence(*m_chain,
323  NULL,
324  NULL);
325 
326  m_solutionRealizer = new SequentialVectorRealizer<P_V,P_M>(m_optionsObj->m_prefix.c_str(),
327  *m_chain);
328 
330 
331  if (m_env.subDisplayFile()) {
332  *m_env.subDisplayFile() << std::endl;
333  }
334 
335  m_env.fullComm().syncPrintDebugMsg("Leaving StatisticalInverseProblem<P_V,P_M>::solveWithBayesMLSampling()",1,3000000);
336  m_env.fullComm().Barrier();
337 
338  return;
339 }
MetropolisHastingsSG< P_V, P_M > * m_mhSeqGenerator
const BaseVectorRV< P_V, P_M > & m_priorRv
void setPdf(BaseJointPdf< V, M > &pdf)
Sets the PDF of this vector RV to pdf.
BaseVectorSequence< P_V, P_M > * m_chain
const BaseJointPdf< V, M > & pdf() const
Posterior Density Function of the vector RV; access to private attribute m_pdf.
Definition: VectorRV.C:86
GenericVectorRV< P_V, P_M > & m_postRv
BaseJointPdf< P_V, P_M > * m_solutionPdf
std::ofstream * subDisplayFile() const
Access function for m_subDisplayFile (displays file on stream).
Definition: Environment.C:305
const V & zeroVector() const
Returns a vector filled with zeros.
Definition: VectorSpace.C:218
BaseVectorCdf< P_V, P_M > * m_subSolutionCdf
const MpiComm & fullComm() const
Access function for MpiComm full communicator.
Definition: Environment.C:247
virtual const VectorSpace< V, M > & vectorSpace() const =0
Vector space to which this set belongs to. See template specialization.
StatisticalInverseProblemOptions * m_optionsObj
const VectorSet< V, M > & imageSet() const
Image set of the vector RV; access to private attribute m_imageSet.
Definition: VectorRV.C:79
void setRealizer(BaseVectorRealizer< V, M > &realizer)
Sets the realizer of this vector RV to realizer.
BaseVectorRealizer< P_V, P_M > * m_solutionRealizer
void syncPrintDebugMsg(const char *msg, unsigned int msgVerbosity, unsigned int numUSecs) const
Synchronizes all the processes and print debug message.
Definition: MpiComm.C:234
void Barrier() const
Pause every process in *this communicator until all the processes reach this point.
Definition: MpiComm.C:143
const VectorSet< V, M > & domainSet() const
Access to the protected attribute m_domainSet: domain set of the scalar function. ...
VectorSet< V, M > * InstantiateIntersection(const VectorSet< V, M > &domain1, const VectorSet< V, M > &domain2)
This method calculates the intersection of domain1 and domain2.
BaseVectorMdf< P_V, P_M > * m_subSolutionMdf
const BaseScalarFunction< P_V, P_M > & m_likelihoodFunction

Friends And Related Function Documentation

template<class P_V, class P_M>
std::ostream& operator<< ( std::ostream &  os,
const StatisticalInverseProblem< P_V, P_M > &  obj 
)
friend

Definition at line 150 of file StatisticalInverseProblem.h.

151  {
152  obj.print(os);
153  return os;
154  }

Member Data Documentation

template<class P_V, class P_M>
SipOptionsValues QUESO::StatisticalInverseProblem< P_V, P_M >::m_alternativeOptionsValues
private

Definition at line 175 of file StatisticalInverseProblem.h.

template<class P_V, class P_M>
BaseVectorSequence<P_V,P_M>* QUESO::StatisticalInverseProblem< P_V, P_M >::m_chain
private

Definition at line 171 of file StatisticalInverseProblem.h.

template<class P_V, class P_M>
const BaseEnvironment& QUESO::StatisticalInverseProblem< P_V, P_M >::m_env
private

Definition at line 157 of file StatisticalInverseProblem.h.

template<class P_V, class P_M>
const BaseScalarFunction<P_V,P_M>& QUESO::StatisticalInverseProblem< P_V, P_M >::m_likelihoodFunction
private

Definition at line 160 of file StatisticalInverseProblem.h.

template<class P_V, class P_M>
ScalarSequence<double>* QUESO::StatisticalInverseProblem< P_V, P_M >::m_logLikelihoodValues
private

Definition at line 172 of file StatisticalInverseProblem.h.

template<class P_V, class P_M>
ScalarSequence<double>* QUESO::StatisticalInverseProblem< P_V, P_M >::m_logTargetValues
private

Definition at line 173 of file StatisticalInverseProblem.h.

template<class P_V, class P_M>
MetropolisHastingsSG<P_V,P_M>* QUESO::StatisticalInverseProblem< P_V, P_M >::m_mhSeqGenerator
private

Definition at line 169 of file StatisticalInverseProblem.h.

template<class P_V, class P_M>
MLSampling<P_V,P_M>* QUESO::StatisticalInverseProblem< P_V, P_M >::m_mlSampler
private

Definition at line 170 of file StatisticalInverseProblem.h.

template<class P_V, class P_M>
StatisticalInverseProblemOptions* QUESO::StatisticalInverseProblem< P_V, P_M >::m_optionsObj
private

Definition at line 176 of file StatisticalInverseProblem.h.

template<class P_V, class P_M>
GenericVectorRV<P_V,P_M>& QUESO::StatisticalInverseProblem< P_V, P_M >::m_postRv
private

Definition at line 161 of file StatisticalInverseProblem.h.

template<class P_V, class P_M>
const BaseVectorRV<P_V,P_M>& QUESO::StatisticalInverseProblem< P_V, P_M >::m_priorRv
private

Definition at line 159 of file StatisticalInverseProblem.h.

template<class P_V, class P_M>
VectorSet<P_V,P_M>* QUESO::StatisticalInverseProblem< P_V, P_M >::m_solutionDomain
private

Definition at line 163 of file StatisticalInverseProblem.h.

template<class P_V, class P_M>
BaseJointPdf<P_V,P_M>* QUESO::StatisticalInverseProblem< P_V, P_M >::m_solutionPdf
private

Definition at line 164 of file StatisticalInverseProblem.h.

template<class P_V, class P_M>
BaseVectorRealizer<P_V,P_M>* QUESO::StatisticalInverseProblem< P_V, P_M >::m_solutionRealizer
private

Definition at line 167 of file StatisticalInverseProblem.h.

template<class P_V, class P_M>
BaseVectorCdf<P_V,P_M>* QUESO::StatisticalInverseProblem< P_V, P_M >::m_subSolutionCdf
private

Definition at line 166 of file StatisticalInverseProblem.h.

template<class P_V, class P_M>
BaseVectorMdf<P_V,P_M>* QUESO::StatisticalInverseProblem< P_V, P_M >::m_subSolutionMdf
private

Definition at line 165 of file StatisticalInverseProblem.h.


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

Generated on Thu Apr 23 2015 19:18:37 for queso-0.50.1 by  doxygen 1.8.5