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

Improve argument processing of tranquilo #446

Closed janosg closed 1 year ago

janosg commented 1 year ago

Problems

  1. The default configuration of tranquilo is quite complex. This is easiest shown with an example: The default target_sample_size depends on the model_type; The default model_type depends on the functype. But the model_type can also be overwritten by the user. If so, we need to check that the user specified a valid model type before we can create the default target_sample_size. I.e. everything is entangled and the order of processing stuff has to be chosen very carefully.
  2. The default values are not collected in one place.
  3. The namespace of the main tranquilo function is cluttered with stuff that was only needed to initialize the main components; It is hard to tell which variables will get used later on and which can be easily changed.

Solution

Alternatives

We could use dags to figure out the order of everything, but we currently do not have dags as a dependency and we don't need it anywhere else. In any case, the current PR gets us closer to a situation where we could use dags.

To-Do

Discuss

codecov[bot] commented 1 year ago

Codecov Report

Merging #446 (bf07d2a) into main (91ffcb8) will increase coverage by 0.05%. The diff coverage is 99.69%.

@@            Coverage Diff             @@
##             main     #446      +/-   ##
==========================================
+ Coverage   92.99%   93.05%   +0.05%     
==========================================
  Files         247      250       +3     
  Lines       18482    18597     +115     
==========================================
+ Hits        17188    17305     +117     
+ Misses       1294     1292       -2     
Impacted Files Coverage Δ
...sts/optimization/subsolvers/test_gqtpar_lambdas.py 100.00% <ø> (ø)
...optimization/tranquilo/test_acceptance_decision.py 100.00% <ø> (ø)
tests/optimization/tranquilo/test_rho_noise.py 100.00% <ø> (ø)
src/estimagic/optimization/tranquilo/options.py 99.18% <98.92%> (-0.82%) :arrow_down:
...agic/optimization/tranquilo/acceptance_decision.py 96.87% <100.00%> (ø)
...c/optimization/tranquilo/acceptance_sample_size.py 95.45% <100.00%> (ø)
...timagic/optimization/tranquilo/aggregate_models.py 97.67% <100.00%> (+10.17%) :arrow_up:
...imagic/optimization/tranquilo/estimate_variance.py 100.00% <100.00%> (ø)
.../estimagic/optimization/tranquilo/filter_points.py 79.83% <100.00%> (+0.16%) :arrow_up:
src/estimagic/optimization/tranquilo/fit_models.py 84.51% <100.00%> (-1.85%) :arrow_down:
... and 10 more

... and 4 files with indirect coverage changes

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.