optimagic-dev / optimagic

optimagic is a Python package for numerical optimization. It is a unified interface to optimizers from SciPy, NlOpt and other packages. optimagic's minimize function works just like SciPy's, so you don't have to adjust your code. You simply get more optimizers for free. On top you get diagnostic tools, parallel numerical derivatives and more.
https://optimagic.readthedocs.io/
MIT License
270 stars 30 forks source link

Add documentation on convergence report, how to retrieve info when optimisation failed #406

Open hmgaudecker opened 2 years ago

hmgaudecker commented 2 years ago

Related to #405: While that particular issue is somewhat fides-specific, the broader point relates to interpreting the convergence report produced by estimagic:

Maximize with 95 free parameters terminated unsuccessfully after 2802 iterations.

The value of criterion improved from -1184865.5053305852 to -1029883.7752618275.

Independent of the convergence criteria used by fides, the strength of convergence
can be assessed by the following criteria:

                             one_step     five_steps 
relative_criterion_change  1.066e-10**   8.185e-08*  
relative_params_change     6.457e-08*    1.441e-07*  
absolute_criterion_change  0.0001098       0.08429   
absolute_params_change     2.969e-08*    5.068e-08*  

(***: change <= 1e-10, **: change <= 1e-8, *: change <= 1e-5. Change refers to a 
change between accepted steps. The first column only considers the last step.
The second column considers the last five steps.)

In particular, it would be good to have a page in the docs containing:

While looking the API of OptimizeResult: I think I would find it helpful if it also contained any flags / defaults used like max_iterations. While flags set by users should be easy to retrieve usually it is also trivial to store them there. Not sure about defaults, the cost of extracting them is likely higher but so is the return (e.g., I set stopping_max_iterations myself but I would have no idea about how to extract the maximum number of function evaluations).