|Synopsis:||Posterior/likelihood maximization (i.e. -log(post) and chi^2 minimization).|
BOBYQA tends to work better on Cosmological problems with the default settings.
If you use BOBYQA, please cite it as:
C. Cartis, J. Fiala, B. Marteau, L. Roberts, “Improving the Flexibility and Robustness of Model-Based Derivative-Free Optimization Solvers” (arXiv:1804.00154)
C. Cartis, L. Roberts, O. Sheridan-Methven, “Escaping local minima with derivative-free methods: a numerical investigation” (arXiv:1812.11343)
M.J.D. Powell, “The BOBYQA Algorithm for Bound Constrained Optimization without Derivatives”, (Technical Report 2009/NA06, DAMTP, University of Cambridge)
If you use scipy, you can find the appropriate references here.
It works more effectively when run on top of a Monte Carlo sample: just change the sampler
minimize with the desired options, and it will use as a starting point the
maximum a posteriori (MAP) or best fit (maximum likelihood, o minimal \(\chi^2\))
found so far, as well as the covariance matrix of the sample for rescaling of the
As text output, it produces two different files:
[output prefix].minimum.txt, in the same format as Cobaya samples, but containing a single line.
[output prefix].minimum, the equivalent GetDist-formatted file.
ignore_prior: True, those files are named
.bestfit[.txt] instead of
and contain the best-fit (maximum of the likelihood) instead of the MAP
(maximum of the posterior).
When called from a Python script, Cobaya’s
run function returns the updated info
and the products described below in the method
It is recommended to run a couple of parallel MPI processes: it will finally pick the best among the results.
Since Cobaya is often used on likelihoods featuring numerical noise (e.g. Cosmology),
we have reduced the default accuracy criterion for the minimizers, so that they
converge in a limited amount of time. If your posterior is fast to evaluate, you may
want to refine the convergence parameters (see
override options in the
Options and defaults¶
Simply copy this block in your input
yaml file and modify whatever options you want (you can delete the rest).
# Default arguments for the -logposterior/chi^2 minimizer sampler: minimize: # Method: bobyqa|scipy method: bobyqa # Minimizes the full posterior (False) or just the likelihood (True) # Likelihood maximization is subject to prior bounds! ignore_prior: False # Maximum number of iterations (default: practically infinite) max_evals: 1e6d # Treatment of unbounded parameters: confidence level to use # (Use with care if there are likelihood modes close to the edge of the prior) confidence_for_unbounded: 0.9999995 # 5 sigmas of the prior # Override keyword arguments for `scipy.optimize.minimize()` or `pybobyqa.solve()` # scipy: # - https://docs.scipy.org/doc/scipy/reference/generated/scipy.optimize.minimize.html # - options for individual methods override_scipy: # option: value # bobyqa: # - https://numericalalgorithmsgroup.github.io/pybobyqa/build/html/userguide.html # - https://numericalalgorithmsgroup.github.io/pybobyqa/build/html/advanced.html override_bobyqa: # option: value # Relaxed convergence criterion for numerically-noisiy likelihoods rhoend: 0.05
minimize(info_sampler, model, output, resume=False, modules=None)¶
Prepares the arguments for scipy.minimize.
Determines success (or not), chooses best (if MPI) and produces output (if requested).
Returns a dictionary containing:
OnePointthat maximizes the posterior or likelihood (depending on
result_object: instance of results class of scipy or pyBOBYQA.
M: inverse of the affine transform matrix (see below).
Noneif no transformation applied.
X0: offset of the affine transform matrix (see below)
Noneif no transformation applied.
X0are returned, this means that the minimizer has been working on an affine-transformed parameter space \(x^\prime\), from which the real space points can be obtained as \(x = M x^\prime + X_0\). This inverse transformation needs to be applied to the coordinates appearing inside the