Closed Jammy2211 closed 3 years ago
Sorry about the delay in getting back to you. This might be due to the more complicated internal logic related to sample_initial
and sample_batch
. Let me look into it tomorrow/Friday and see what I can find.
Hi @Jammy2211
If you want to run dynamic nested sampling in a loop you should be doing something like this: rather than do run_nested in a loop (as run_nested indeed does the initial sampling + batches)
import xtest_dyn
import dynesty
sampler = dynesty.DynamicNestedSampler(xtest_dyn.loglike_egg,
xtest_dyn.prior_transform_egg,
2,
nlive=500)
sampler.run_nested(maxcall=1000)
for i in range(100):
sampler.add_batch(nlive=250, maxcall=1000)
The code shown above requires the most recent version of dynesty (from github main)
For the setup I am using, I have the
run_nested
method in a for loop and call it multiple times for a set number of iterations:The reason I do this is because the
do_stuff
function above gives me on-the-fly visualization, results, etc and it allows me to cancel the job and resume where I left off (using a pickled Dynesty sampler instance).The above code seems to work fine for the Static sampler and I have been using it for a long time with no issue.
However, I just had a go at using the Dynamic sampler (which I typically have not used much) and have found that encasing it in the loop above does not seem to be valid. Specifically, after the first
run_nested
call runs for a total ofiterations_per_call
, the subsequent calls do not do any new samplings.I can reduce this problem down to simply running
run_nested
for the Dynamic sampler twice, back to back, and noting that the second call does not update the sampling. The only way to get the Dynamic sampler to run for a large number of calls is therefore settingiterations_per_call
very high and disabling on-the-fly outputs.My question is, does this behaviour make sense and if so, is there any easy way I can get on the fly behaviour from the Dynamic sampler? Or should I disable this feature for that sampler.