Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Naming for "xtol" and "ftol" criteria in PINTS (max_unchanged_iterations) #1509

Open
MichaelClerx opened this issue Dec 5, 2023 · 5 comments
Assignees

Comments

@MichaelClerx
Copy link
Member

MichaelClerx commented Dec 5, 2023

As part of #1502 I'm wondering what to do about the names of the stopping criteria based on a minimum change per iteration

At the moment we have set_max_unchanged_iterations, which sets an ftol type criterion (stop when the best function value changes by less than X for N iterations). I'm adding one that sets an xtol type criterion (stop when the best parameter value changes by less than X for N iterations). Current names in some software:

Stop when Matlab Scipy (fmin) nlopt pycma PINTS
f(x) change < t FunctionTolerance, TolFun ftol ftol tolfun unchanged_iterations
x change < t StepTolerance, TolX xtol xtol tolx ?
f(x) < t stopval ftarget threshold

I'd gone for unmoved_iterations but initial feedback says no. So now thinking we (deprecate and) rename the unchanged_iterations methods to something that includes the word function?

@MichaelClerx
Copy link
Member Author

MichaelClerx commented Dec 5, 2023

Highly used function though, so would love input from as many @pints-team/devs as possible!

@chonlei @DavAug @FarmHJ who else uses optimisers?

@MichaelClerx MichaelClerx self-assigned this Dec 5, 2023
@EricWay1024
Copy link

Honestly speaking the name set_max_unchanged_iterations was a bit confusing when I first looked at it, so I think it could be a good idea to rename it to something like set_function_tolerance_iterations while naming the xtol method as set_parameter_tolerance_iterations.

@Rebecca-Rumney
Copy link

I have been using scipy optimisation, and fmin is a legacy function. The current minimize function uses fatol and xatol for absolute differences and uses ftol and xtol for relative differences. If we then use ftol and xtol, people used to scipy might think we mean the relative differences not absolute. Looking at NLOpt, they use ftol_rel and ftol_abs to differentiate.

Although I do agree, set_max_unchanged_iterations is a little confusing on what it is setting.

@DavAug
Copy link
Member

DavAug commented Dec 5, 2023

As part of #1502 I'm wondering what to do about the names of the stopping criteria based on a minimum change per iteration

At the moment we have set_max_unchanged_iterations, which sets an ftol type criterion (stop when the best function value changes by less than X for N iterations). I'm adding one that sets an xtol type criterion (stop when the best parameter value changes by less than X for N iterations). Current names in some software:

Stop when Matlab Scipy (fmin) nlopt pycma PINTS
f(x) change < t FunctionTolerance, TolFun ftol ftol tolfun unchanged_iterations
x change < t StepTolerance, TolX xtol xtol tolx ?
f(x) < t stopval ftarget threshold

I'd gone for unmoved_iterations but initial feedback says no. So now thinking we (deprecate and) rename the unchanged_iterations methods to something that includes the word function?

Thank you Michael for working on this!

I may be alone on this, but I actually find the set method to max_unchanged_iterations quite clear. Perhaps, the missing information is just that this relates to the stopping criterion.

So, I am wondering whether set_stopping_criteria would do the trick, complemented by a detailed doc string (given that stopping criteria could mean anything)? The arguments to this method could be function_threshold, parameter_threshold, and n_iterations. The max_unchanged_iterations could then, perhaps, also be replaced by a stopping_criteria method which returns all three values in a meaningful way.

Looking forward to hearing your thoughts! :)

@mjowen
Copy link

mjowen commented Dec 6, 2023

I'd avoid being too similar to the ftol and xtol (or xatol and fatol) standards as I think they carry the implication of checking with the previous iteration rather than the default in pints of 200 iterations ago.
I don't think anywhere (apart from pints) has a method for specifying the number of iterations in these types of termination criteria.

So, I am wondering whether set_stopping_criteria would do the trick, complemented by a detailed doc string (given that stopping criteria could mean anything)? The arguments to this method could be function_threshold, parameter_threshold, and n_iterations. The max_unchanged_iterations could then, perhaps, also be replaced by a stopping_criteria method which returns all three values in a meaningful way.

I like the idea of keeping it all isolated to a single function. Makes it clear that if you're using multiple termination criteria then they should stack rather than override each other.
Threshold gives me the implication that it would terminate when f is less than function_threshold rather than the change in f. I'd probably go for function_tolerance and parameter_tolerance to be in place of max_unchanged_iterations and max_unmoved_iterations, a buffer (or function_buffer and parameter_buffer) as the number of unchanged iterations and then its clearly separated from a max_iterations termination criteria

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants