mathnet / mathnet-numerics

Math.NET Numerics
http://numerics.mathdotnet.com
MIT License
3.44k stars 891 forks source link

Fix LevenbergMarquardtMinimizer stopping condition #1066

Open diluculo opened 4 months ago

diluculo commented 4 months ago

addressing issue #1061

diluculo commented 4 months ago

@jkalias, thank you for your prompt response.

While I may not have a concrete test case to demonstrate the issue, it's essential to highlight that the standard Levenberg-Marquardt (LEVM) stopping criterion is ||ΔP|| <= xTol * (||P|| + xTol). Please refer to the stopping criteria as defined on page 26 of Madsen 2004

image

The original buggy code, using P.DotProduct(P), unintentionally produces an early stopping effect. For instance, let's dig into the details of the BoxBod_LM_Der() unit test, specifically examining the section where the condition parameters < upper, scales is applied.

Result P.DotProduct(P) P.L2Norm() Expected
Iteration 16 20
P[0] 213.80940888 213.80940889 213.80940889
P[1] 0.54723748553 0.54723748542 0.54723748542