acerbilab / pyvbmc

PyVBMC: Variational Bayesian Monte Carlo algorithm for posterior and model inference in Python
https://acerbilab.github.io/pyvbmc/
BSD 3-Clause "New" or "Revised" License
114 stars 6 forks source link

feat: handle end of vbmc warmup #15

Closed Solosneros closed 3 years ago

Solosneros commented 3 years ago

This is the implementation of check_warmup_end_conditions which is called vbmc_warmup.m in MATLAB.

This PR is still work in progress, we need to discuss some implementation details. :)

Discussion points:

  1. I would like to add booleans like stable_count_flag that describe the conditions better instead of the below two lines in MATLAB. I need however names for the conditions as I am not fairly confident with the naming of those (e.g. what is the difference between Second requirement, also no substantial improvement of max fcn value in recent iters (unless already performing BO-like warmup) and Alternative criterion for stopping - no improvement over max fcn value
    stopWarmup = (StableCountFlag && improFcn < StopWarmupThresh) || (currentpos - pos) > options.WarmupNoImproThreshold;
    stopWarmup = stopWarmup & (optimState.N - lastDataTrim) >= 10;
  2. We could split the method into two: First one is determining if the warmup should end and the second one is doing all the setup of optim_state etc. (This means I would split at line 91 of MATLAB.)
Solosneros commented 3 years ago

Splitting warmup into two methods, one for the check of the conditions and the other one for the setup when warmup ending has been detected. Furthermore add booleans for the conditions: "condition2 is no_recent_improvement_flag condition3 is no_longterm_improvement_flag condition4 is no_recent_trim_flag"

Solosneros commented 3 years ago

I think it looks good, coverage is at 100% and I tested the major cases for the two methods. You can have a look @lacerbi. :)