Convert all algorithm documentation to the new format.#690
Open
janosg wants to merge 1 commit into
Open
Conversation
|
Check out this pull request on See visual diffs & provide feedback on Jupyter Notebooks. Powered by ReviewNB |
Codecov Report✅ All modified and coverable lines are covered by tests.
... and 2 files with indirect coverage changes 🚀 New features to boost your workflow:
|
51d4bec to
cde6d90
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Previously, algorithm documentation was in algrithms.md; Now it's in docstrings of the algorithm classes. The details of the new format are documented here. During conversion, we discovered and fixed the following issues:
1. Errors in the old documentation (corrected)
scipy
trust_constr's general nonlinear constraints are not supported yet by optimagic".
All three have
supports_nonlinear_constraints=Truetoday. The new docstringsinstead explain how optimagic converts equality constraints to inequality pairs
for COBYLA (which natively only handles inequalities).
scipy_newton_cg. The warning advised refining "an optimumfound with Powell" with another optimizer — it meant an optimum found with
newton_cg.
scipy_direct. The old text claimed the volume toleranceepsdefaults to 1e-6, "differing from scipy's default 1e-4". The actual optimagicdefault is
CONVERGENCE_FTOL_REL = 2e-9.scipy_truncated_newtonwas documented withstopping.maxiter, but the class only hasstopping_maxfun;scipy_ls_lmwasdocumented with
tr_solver/tr_solver_options, which only exist on the trf anddogbox least-squares solvers. Dropped.
finitie_difference_precision; several places where optimagic defaultssilently differ from SciPy are now stated explicitly (Nelder-Mead ftol 1e-8 vs
SciPy 1e-4, SLSQP 1e-8 vs 1e-6, BFGS xrtol 1e-5 vs 0, trust_constr xtol 1e-5 vs
1e-8, dual_annealing maxfun 1e6 vs 1e7, differential_evolution atol 1e-8 vs 0).
nlopt
"nonlinear equality (but not inequality) constraints". NLopt supports the
opposite: nonlinear inequality (not equality) constraints. In optimagic, MMA
gets equalities via conversion to inequality pairs, and CCSAQ currently exposes no
nonlinear constraints at all (
supports_nonlinear_constraints=False).nlopt_lbfgs, but the registeredalgorithm name is
nlopt_lbfgsb.nlopt_tnewtonis not preconditioned. The old text described it as"preconditioned truncated Newton"; the wrapped variant is
LD_TNEWTON, the plainvariant without preconditioning or restarting (those are separate NLopt variants).
and omitted "DIRECT_NOSCAL". The code maps six combinations, and
random_search=Trueonly takes effect together withlocally_biased=True(nowdocumented on the field).
violated" no longer matches NLopt's documentation ("bounds emulated by variable
transformation"). The warning that optimagic disables bounds for PRAXIS is kept.
a local optimum from any feasible starting point); removed an unsourced "<10
past updates" claim for LBFGS storage; numerous typos (Nedler-Mead, alggorithm,
faunction, a
:cite:role missing its colon).pygmo
parameters but at least X". The code (
get_population_size) uses10 * (n_params + 1), clipped below at the algorithm-specific minimum.ftol/xtoldescriptions swapped for sade, cmaes and xnes — a known pagmodocumentation bug that had been copied into algorithms.md. Verified against
cmaes.cpp/de.cpp: ftol is flatness of the population's fitness values, xtol isflatness in parameter space.
pygmo_de.weight_coefficientdocumented as range [0, 2], pagmo enforces [0, 1];pygmo_sga.mutation_polynomial_distribution_indexdocumented "[0, 1], default 1",pagmo enforces [1, 100];
pygmo_sga.selection_tournament_sizedefault is 2, not 1.max_n_trials(optimagic 1 vs pygmo 20), mbhstopping_max_inner_runs_without_improvement(30 vs 5), simulated_annealingend temperature (0.01 vs 0.1, must be below the start temperature).
.. note:directive (single colon); GWO section typos ("usinng", "pased","shokingly") and its criticism of the algorithm is now attributed to the pagmo
developers rather than "our opinion";
batch_evaluatorbullets dropped for gacoand pso_gen (the classes only have
n_cores).ipopt
linear_solverdefault. The old text said the default is"ma27" while its own value list said "mumps (default)". The code default is
"mumps".acceptable_dual_inf_tolmismatch. The old text documented Ipopt's default1e+10, but the code passes 1e-10 (see code bugs below). The docstring now
documents the actual behavior and flags the deviation.
theta_max_facthad been fused into thewatchdog_trial_iter_maxbullet;recalc_y_feas_tolwas mislabeled.resto_failure_feasibility_threshold. Old text said 0; thewrapper maps
Noneto100 * convergence_ftol_rel.filter_margin_fact), "10-06" → 1e-6 (sigma_min),"bound_mult"→"bound-mult"(the code's Literal),adaptive_mu_kkterror_red_iterslabeled float but is an int; word typos("lwer", "bunded", "brrier"). Deviations from Ipopt defaults now flagged
(
convergence_ftol_rel2e-9 vs Ipopttol1e-8;stopping_maxiter1,000,000 vsIpopt 3000).
NAG (DFO-LS, Py-BOBYQA)
seek_global_optimumrestriction was wrong. Old text: "Only applies for noisycriterion functions." Py-BOBYQA's documentation demonstrates it on noise-free
functions; the actual requirement is finite lower and upper bounds.
fast-start method "if
len(x) >= number of root contributions". DFO-LS documentsthe opposite (
use_full_rank_interpdefaults to True iff m >= n), i.e. "jacobian"is default when the number of residuals is at least the number of parameters.
code is
"trustregion".:ref:pointers for options whose default constants no longer live inalgo_options.py; descriptions are now inline on the fields.fides
trustregion.subspace_dimensionwas documented asdefaulting to "2D"; the optimagic default is
"full"(the fides package itselfdefaults to "2D"). Similarly, optimagic defaults
stepback_strategyto"truncate"while fides defaults to"reflect". Both deviations are now stated.trustregion.refine_stepbackandtrustregion.scaled_gradient_as_possible_stepbackwere documented but are notfields of the class.
(
Optimizer.check_convergence) and written as math blocks.TAO pounders
outdated mirror; petsc4py is developed as part of PETSc.
are floats and the code disables on any falsy value; correct advice is "set to
zero to disable".
\epsilon,X0→X_0).Own optimizers (bhhh, neldermead_parallel, pounders)
"contributions" entry) replaced by the current
@om.mark.likelihoodinterface;"only vaid" typo.
documenting nonexistent
criterion/xparameters;adaptiveadapts the simplexparameters to the problem dimension (Gao–Han), not to "simplex size"; the code's
capping of
n_coresatn_params - 1is now documented.convergence.gtol_reldefault written as "1-8" instead of 1e-8;trustregion_expansion_factor_successfulwas described as a "Shrinking factor" —it is an expansion factor; the documented literal "steihaug-toint" is actually
"steihaug_toint"; old option namestrustregion_threshold_successful/..._very_successfulare nowtrustregion_threshold_acceptance/..._successfuland are documented under the current names; the documentedbatch_evaluatoroption no longer exists (onlyn_cores).Other documentation fixes
nevergrad_wizard/nevergrad_portfoliodropdowns were broken. Theyreferenced classes that no longer exist (
NevergradWizard,Wizard,NevergradPortfolio,Portfolio, includingfrom ... import Wizardusageexamples). The algorithms are registered as
nevergrad_ngoptandnevergrad_meta; dropdowns renamed and examples rewritten using the string-basedoptimizeroption.how_to_add_optimizers.ipynbcrashed the docs build. Its example@mark.minimizercall was missing the now-requiredneeds_boundsandsupports_infinite_boundsarguments. Also fixed its dead cross-referencealgo_options_docs→algo_options.section). Documented from scratch based on the tranquilo paper (Gabler, Gsell,
Mensinger, Petrosyan 2024) and the tranquilo 0.1.1 source.