Description
Many implemented optimisers provide stopping criteria based on the difference between the last two parameter sets (abs(x[i] - x[i - 1]
) or the last two function evaluations (abs(f[i] - f[i - 1])
). When comparing methods from PINTS with other methods, it is useful to have something similar.
How do people define xtol and ftol?
Absolute versus relative
Occasionally, relative differences are used, e.g. abs(f[i] - f[i - 1]) / f[i]
.
- In matlab the interpretation of xtol and ftol depends on the method. See here and this per-method table
- In scipy the existence of xtol and ftol and their implementation is method dependent. E.g. absolute for Nelder mead, relative for Powell, not at all for CG
- In nlopt users can add both https://nlopt.readthedocs.io/en/latest/NLopt_Python_Reference/#stopping-criteria
Scalar xtol?
In nlopt, xtol can be a scalar, in matlab it looks like it needs to have size n_parameters
.
AND vs OR
In scipy's Nelder-mead, xtol AND ftol must be met. Everywhere else they are independent stopping criteria https://stackoverflow.com/questions/43644797/what-is-xtol-for-in-minimizemethod-nelder-mead
Proposal
- Add xtol and ftol as separate, independent criteria (so OR, not AND)
- They will not be set by default, so users can enable them (or disable them) for methods and problems where they think this is appropriate
- Adding relative versions means doubling the workload, and dealing with the case where x or f has 0 at its optimum. The only benefit is that the user can write
set_xtol(generic_tol)
instead ofset_xtol(abs_tol / sensible_scaling_value)
. I propose we do absolute only, leaving scaling to the user (who has the info needed for this decision) - Similarly, allowing a scalar xtol is more implementation/documentation/tests/maintenance/room-for-bugs, all for the sake of a user writing
set_xtol(tol)
instead ofset_xtol([tol] * n_parameters)
. So xtol always n_parameters, ftol always scalar.
Both matlab and scipy seem to be phasing out the "xtol"/"ftol" terminology (i.e. scipy is using xatol/ratol when relative, matlab is saying "StepTolerance"/"FunctionTolerance", so might follow that and
- Call the methods
set_step_tolerance
andset_function_tolerance
. The current names aremax_iterations
,max_evaluations
,max_unchanged_iterations
, andthreshold
(stop iff < threshold
). So could haveset_step_tolerance
andset_tolerance
instead? Orset_min_step
andset_min_change
?