Skip to content

Commit 8af1b66

Browse files
committed
Avoiding infinity loop if for example lambda hits infinity.
1 parent 461e3af commit 8af1b66

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/main/java/net/finmath/optimizer/LevenbergMarquardt.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -757,7 +757,7 @@ private void updateParameterTest() throws SolverException {
757757
* where H = J^T J is the Hessian approximation and b = J^T (y-f(x)) and \Delta x is the parameterIncrement
758758
*/
759759
boolean hessianInvalid = true;
760-
while (hessianInvalid) {
760+
while (hessianInvalid && Double.isFinite(lambda)) {
761761
hessianInvalid = false;
762762
// Build matrix H (Hessian approximation), that is H = J^T J
763763
for (int i = 0; i < parameterCurrent.length; i++) {
@@ -800,7 +800,8 @@ private void updateParameterTest() throws SolverException {
800800

801801
try {
802802
// Calculate new increment
803-
parameterIncrement = LinearAlgebra.solveLinearEquationSymmetric(hessianMatrix, beta);
803+
// parameterIncrement = LinearAlgebra.solveLinearEquationSymmetric(hessianMatrix, beta);
804+
parameterIncrement = LinearAlgebra.solveLinearEquationSVD(hessianMatrix, beta);
804805
} catch (final Exception e) {
805806
// Matrix not invertable, increase lambda
806807
hessianInvalid = true;

0 commit comments

Comments
 (0)