-
Notifications
You must be signed in to change notification settings - Fork 135
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Metropolis Algorithm for MCMC #1262
Conversation
Job Test CentOS 7 on 8f116ea : invalidated by @wangcj05 conda error when setting python environment |
framework/Samplers/MCMC/MCMC.py
Outdated
|
||
def localInputAndChecks(self, xmlNode, paramInput): | ||
""" | ||
unfortunately-named method that serves as a pass-through for input reading. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unfortunately-named method? O_o
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
10:1 says I wrote the original version this was copied from ... heh
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
else: | ||
self._proposal[var] = None | ||
# TargetEvaluation Node (Required) | ||
targetEval = paramInput.findFirst('TargetEvaluation') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe the AdaptiveSampler does this for you, so it should not be needed here if you call the base class, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Currently, the adaptive sampler using following lines to define and retrieve TargetEvaluation:
self.addAssemblerObject('TargetEvaluation', 'n')
...
self._targetEvaluation = self.assemblerDict['TargetEvaluation'][0][3]
Which in my opinion should be changed to use
self.retrieveObjectFromAssemblerDict
@wangcj05 I like the generality of allowing the user to use any distribution for the proposal (following the general metropolis-hasting algo), but I am afraid that we will "pay" this generality in terms of convergence issues and/or unexpected behavior. For example, how do we handle the discrete distributions here? Multivariates? |
@wangcj05 as during our conversation, if we limit the usability of the proposal distributions and check the truncability, I am good for the merge |
framework/Distributions.py
Outdated
@@ -439,6 +439,15 @@ def pdf(self,x): | |||
returnPdf = self._distribution.pdf(x) | |||
return returnPdf | |||
|
|||
def logpdf(self,x): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am having my revenge here: should it be logPdf?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed.
framework/Samplers/MCMC/MCMC.py
Outdated
""" | ||
descr = r""" | ||
\section{Markov Chain Monte Carlo} \label{sec:MCMC} | ||
The Markov chain Monte Carlo (MCMC) is another important entity in the RAVEN framework. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
... is another important sampler ...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
framework/Samplers/MCMC/MCMC.py
Outdated
|
||
def localFinalizeActualSampling(self, jobObject, model, myInput): | ||
""" | ||
General function (available to all samplers) that finalize the sampling |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
finalizes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
@ In, externalSeeding, int, optional, external seed | ||
@ In, solutionExport, DataObject, optional, a PointSet to hold the solution | ||
@ Out, None | ||
""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a generic question: does this MCMC method allow the user to use a chain generated in the past that needs to be augmented?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the answer for this question is No for current implementation. This seems to me similar to Restart option.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No restart?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you try a test for it?
I have completed a first round of comments; I need a bit more time to think more about it |
@alfoa I have added the checks for Distributions. Only continuous distribution is allowed. |
@mandd I have addressed your comments. |
@ In, externalSeeding, int, optional, external seed | ||
@ In, solutionExport, DataObject, optional, a PointSet to hold the solution | ||
@ Out, None | ||
""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No restart?
@ In, externalSeeding, int, optional, external seed | ||
@ In, solutionExport, DataObject, optional, a PointSet to hold the solution | ||
@ Out, None | ||
""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you try a test for it?
mean: [5, 5], cov=[[1, 0.9], [0.9, 1]] | ||
Both input parameters have the standard normal distribution as their prior distribution. | ||
The proposal distributions for the input variables are also standard normal distribution. | ||
"TargetEvaluation" is used to collect the inputs and outputs from the likelihood model. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
since this goes into a latex file, I would use the `` '' construct for the quotes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
@wangcj05 do you want to develop the restart here or in another PR? |
I have updated the Metropolis Sampler with the restart capability. The original test has also been updated with the restart. |
@alfoa I have addressed all your comments, restart is now tested, and the tests are green now. |
Pull Request Description
What issue does this change request address? (Use "#" before the issue to link it, i.e., #42.)
close #1260
This PR will also update the submodule ID of LOGOS. Recent changes in RAVEN dependencies file structure caused the failure of LOGOS regression test. This has been recently fixed in LOGOS. see issue #1114
In addition, this PR also make some improvement on the restart capability (see #1280), this is because metadata is required for several Samplers when restarted is requested.
Implementation of Markov Chain Monte Carlo algorithm, i.e. Metropolis Algorithm.
What are the significant changes in functionality due to this change request?
For Change Control Board: Change Request Review
The following review must be completed by an authorized member of the Change Control Board.
<internalParallel>
to True.raven/tests/framework/user_guide
andraven/docs/workshop
) have been changed, the associated documentation must be reviewed and assured the text matches the example.