Skip to content

Commit

Permalink
Handle limit case in LM
Browse files Browse the repository at this point in the history
  • Loading branch information
ocommowi committed Nov 12, 2018
1 parent 2a21515 commit 7e50f42
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include <animaBoundedLevenbergMarquardtOptimizer.h>
#include <animaBaseTensorTools.h>
#include <vnl_qr.h>
#include <limits>

namespace anima
{
Expand Down Expand Up @@ -73,6 +74,7 @@ void BoundedLevenbergMarquardtOptimizer::StartOptimization()
while (!stopConditionReached)
{
++numIterations;
std::cout << numIterations << " " << m_LambdaParameter << std::endl;

// Solve (JtJ + lambda I) x = - Jt r
workMatrix = derivativeSquared;
Expand Down Expand Up @@ -243,7 +245,7 @@ bool BoundedLevenbergMarquardtOptimizer::CheckConditions(unsigned int numIterati
if (numIterations == m_NumberOfIterations)
return true;

if (m_LambdaParameter == 0.0)
if ((m_LambdaParameter == 0.0)||(m_LambdaParameter >= std::numeric_limits<double>::max() / 2.0))
return true;

double normDiffParams = 0.0;
Expand Down

0 comments on commit 7e50f42

Please sign in to comment.