From c67afb1e7127e3914f4f254c4fcc70acb6f5df43 Mon Sep 17 00:00:00 2001 From: Val Erastov Date: Fri, 9 Sep 2016 11:12:31 -0700 Subject: [PATCH] cleanup dog_leg --- web/app/math/optim.js | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/web/app/math/optim.js b/web/app/math/optim.js index 9336ab7c..2ae4becd 100644 --- a/web/app/math/optim.js +++ b/web/app/math/optim.js @@ -298,14 +298,7 @@ var dog_leg = function (subsys, rough) { var h_gn = vec(xsize); var h_dl = vec(xsize); - var r0 = vec(csize); - subsys.fillParams(x); - -// subsys.setParams(vec(xsize)); -// subsys.calcResidual(r0); - - subsys.setParams(x); var err = subsys.calcResidual(fx); subsys.fillJacobian(Jx); @@ -326,7 +319,6 @@ var dog_leg = function (subsys, rough) { } var g = n.dot(n.transpose(Jx), fx); - // get the infinity norm fx_inf and g_inf var g_inf = n.norminf(g); var fx_inf = n.norminf(fx); @@ -341,16 +333,15 @@ var dog_leg = function (subsys, rough) { while (returnCode === 0) { optim.DEBUG_HANDLER(iter, err); - // check if finished - if (fx_inf <= tolf) { // Success + if (fx_inf <= tolf) { returnCode = 1; - } else if (g_inf <= tolg) {// Success too + } else if (g_inf <= tolg) { returnCode = 1; } else if (delta <= tolx * (tolx + n.norm2(x))) { returnCode = 3; } else if (iter >= iterLimit) { returnCode = 4; - } else if (err > divergingLim || err != err) { // check for diverging and NaN + } else if (err > divergingLim || err != err) { returnCode = 6; } else { @@ -359,7 +350,7 @@ var dog_leg = function (subsys, rough) { h_gn = lsolve(Jx, n.mul(fx, -1)); //LU-Decomposition -// h_gn = lusolve(Jx, n.mul(fx, -1)); + //h_gn = lusolve(Jx, n.mul(fx, -1)); //Conjugate gradient method //h_gn = cg(Jx, h_gn, n.mul(fx, -1), 1e-8, iterLimit);