BifurcationKit.jl icon indicating copy to clipboard operation
BifurcationKit.jl copied to clipboard

Suggested ehancement for NewtonPar: stop residual theshold and relative tolerance

Open Azercoco opened this issue 9 months ago • 6 comments

In the Newton iteration, it sometimes happen for bad initial guess that the residual blow out to infinity very quickly. This may even causes NaNto occurs, causing issues down the line.

I would suggest to add in NewtonPar() a field residual_stop_threshold=Inf (default value to not change behaviour) which would automatically stop the Newton iterations if the residual exceed the threshold. Doing so would avoid blowout and in, during continuation, prevent some time waste trying to converge at bad guesses by immediately culling it.

Another improvement for NewtonPar() would be the explicitly split relative and absolute tolerance (with aTol and rTol fields). For large scale problem, it is more convenient to use relative tolerance which is less sensitive to the number of points.

Azercoco avatar Mar 20 '25 10:03 Azercoco

For residual_stop_threshold, there is already a solution. You can pass a callback to solve or a callback_newton to contination. See for example here.

You can use the predefined callbacks cbMaxNormAndΔp or cbMaxNorm or make your own

rveltz avatar Mar 20 '25 10:03 rveltz

As for abstol and reltol, that's a good idea. If you know how to modify newton, please make a PR

rveltz avatar Mar 20 '25 10:03 rveltz

is it OK for this one?

rveltz avatar Apr 04 '25 06:04 rveltz

Hi, I have started to write a PR and I saw than the Newton code is duplicated between the PALC algorithm and from the Newton solver (with the latter not using linesearch).

Could both method be merged into a single interface ?

Azercoco avatar May 15 '25 11:05 Azercoco

Great! Thank you! It is not easy to merge them, it requires a dedicated infrastructure for very little gain. I agree that conceptually, it is annoying (and for maintenance too as you observe).

rveltz avatar May 15 '25 12:05 rveltz

Hi,

Have you progressed on this?

rveltz avatar Oct 19 '25 16:10 rveltz