BradGreig / Hybrid21CM

1 stars 3 forks source link

MCMC continue_sampling with different chain #17

Closed steven-murray closed 5 years ago

steven-murray commented 5 years ago

At the moment, when using "continue_sampling" in the run_mcmc function, if the model_name is the same, and the file is found, the MCMC will proceed with very minimal checks, including: make sure blob names are the same, make sure number of parameters are the same.

Therefore it is very easy to continue a chain with a very different model, making the chain completely inconsistent.

It's not clear to me what the best way to deal with this is. One way would be to save the entire LikelihoodComputationChain along with the actual chain each time, which would allow to compare the chain, and ensure that relevant parts are exactly the same.

Maybe it's not that important, and the user should just be careful, but I don't usually like that approach :-). Because I know how uncareful I can be with the code that I wrote.

steven-murray commented 5 years ago

This should be fixed in de284c6628b0a938d72e2e4ad2c24b87eaaf1a3e, which also fixes https://github.com/BradGreig/Hybrid21CM/issues/11.

Basically, before any MCMC is run (only with the run_mcmc function), a YAML file is output which saves all parameters of the chain -- all cores, likelihoods and their contents -- to a YAML file. This is reasonably human-readable, and includes all cosmo, astro, user, flag params, as well as other MCMC diagnostic info. This can also be read in directly as a chain object, which may be nice for if you need to generate the likelihood at some particular set of parameters after you've finished the chain.