CobayaSampler / cobaya

Code for Bayesian Analysis
http://cobaya.readthedocs.io/en/latest/
Other
126 stars 125 forks source link

Store full set of minima #334

Closed ggalloni closed 10 months ago

ggalloni commented 10 months ago

Hello, I wrote an extension of the current minimization part of Cobaya to store the full set of minima from multiple initial points. I think this is valuable for the user, since, for example, the dispersion of the minima from different initial conditions represents a feedback on the precision of the minimization procedure. An example is this (Fig.4), where this very concept is applied. A similar concept is also shown in the Planck's paper here (Fig.1), where they show the effect of changing CAMB's accuracy parameters.

In #332 I already mentioned this feature, which then I decided to leave for later development since it was causing some issues. Those are fixed now and Travis passed all tests on my fork.

Summarizing the changes in minimize.py:

For what regards tests, since the default value of best_of is 2, I added to the existing test an assert statement checking that full_set_of_mins is a dictionary. Then, I added a new test checking that if a single initial point is requested full_set_of_mins = None. Tho, I had to suppress this test for the MPI-part of tests. I don't know if this is an intended behavior, but in the (weird) case in which best_of < MPI size the code will act as if best_of == MPI size. This results in having 2 initial points even when I explicitly set best_of = 1 because one test is run with MPI size = 2. It doesn't make much sense to me asking intentionally less initial points than processes, so probably this is not something to worry about. Still, it could be a good idea to add a warning in minimize.py to make sure that the user is aware of what is going on.

As stated above, Travis passed all checks on my fork, so this time I will not bother you with the debugging. Of course, let me know if the current implementation is satisfactory or if you would make any modifications.

codecov-commenter commented 10 months ago

Codecov Report

Merging #334 (7927063) into master (41143e4) will increase coverage by 0.02%. The diff coverage is 100.00%.

:exclamation: Your organization needs to install the Codecov GitHub app to enable full functionality.

@@            Coverage Diff             @@
##           master     #334      +/-   ##
==========================================
+ Coverage   84.81%   84.84%   +0.02%     
==========================================
  Files         124      124              
  Lines        9165     9169       +4     
==========================================
+ Hits         7773     7779       +6     
+ Misses       1392     1390       -2     
Files Coverage Δ
cobaya/samplers/minimize/minimize.py 95.14% <100.00%> (+0.59%) :arrow_up:

... and 1 file with indirect coverage changes