mirror of
https://gitlab.com/libeigen/eigen.git
synced 2026-04-10 11:34:33 +08:00
define and use struct Parameters
This commit is contained in:
@@ -17,6 +17,16 @@ public:
|
||||
UserAksed = 6
|
||||
};
|
||||
|
||||
struct Parameters {
|
||||
Parameters()
|
||||
: factor(Scalar(100.))
|
||||
, maxfev(1000)
|
||||
, xtol(ei_sqrt(epsilon<Scalar>())) {}
|
||||
Scalar factor;
|
||||
int maxfev; // maximum number of function evaluation
|
||||
Scalar xtol;
|
||||
};
|
||||
|
||||
Status solve(
|
||||
Matrix< Scalar, Dynamic, 1 > &x,
|
||||
const Scalar tol = ei_sqrt(epsilon<Scalar>())
|
||||
@@ -25,10 +35,8 @@ public:
|
||||
Matrix< Scalar, Dynamic, 1 > &x,
|
||||
int &nfev, int &njev,
|
||||
Matrix< Scalar, Dynamic, 1 > &diag,
|
||||
const int mode=1,
|
||||
const int maxfev = 1000,
|
||||
const Scalar factor = Scalar(100.),
|
||||
const Scalar xtol = ei_sqrt(epsilon<Scalar>())
|
||||
const Parameters ¶meters,
|
||||
const int mode=1
|
||||
);
|
||||
|
||||
Status solveNumericalDiff(
|
||||
@@ -39,12 +47,10 @@ public:
|
||||
Matrix< Scalar, Dynamic, 1 > &x,
|
||||
int &nfev,
|
||||
Matrix< Scalar, Dynamic, 1 > &diag,
|
||||
const Parameters ¶meters,
|
||||
const int mode=1,
|
||||
int nb_of_subdiagonals = -1,
|
||||
int nb_of_superdiagonals = -1,
|
||||
const int maxfev = 2000,
|
||||
const Scalar factor = Scalar(100.),
|
||||
const Scalar xtol = ei_sqrt(epsilon<Scalar>()),
|
||||
const Scalar epsfcn = Scalar(0.)
|
||||
);
|
||||
|
||||
@@ -68,6 +74,7 @@ HybridNonLinearSolver<FunctorType,Scalar>::solve(
|
||||
const int n = x.size();
|
||||
int nfev=0, njev=0;
|
||||
Matrix< Scalar, Dynamic, 1> diag;
|
||||
Parameters parameters;
|
||||
|
||||
/* check the input parameters for errors. */
|
||||
if (n <= 0 || tol < 0.) {
|
||||
@@ -75,15 +82,15 @@ HybridNonLinearSolver<FunctorType,Scalar>::solve(
|
||||
return ImproperInputParameters;
|
||||
}
|
||||
|
||||
parameters.maxfev = 100*(n+1);
|
||||
parameters.xtol = tol;
|
||||
diag.setConstant(n, 1.);
|
||||
return solve(
|
||||
x,
|
||||
nfev, njev,
|
||||
diag,
|
||||
2,
|
||||
(n+1)*100,
|
||||
100.,
|
||||
tol
|
||||
parameters,
|
||||
2
|
||||
);
|
||||
}
|
||||
|
||||
@@ -96,10 +103,8 @@ HybridNonLinearSolver<FunctorType,Scalar>::solve(
|
||||
int &nfev,
|
||||
int &njev,
|
||||
Matrix< Scalar, Dynamic, 1 > &diag,
|
||||
const int mode,
|
||||
const int maxfev,
|
||||
const Scalar factor,
|
||||
const Scalar xtol
|
||||
const Parameters ¶meters,
|
||||
const int mode
|
||||
)
|
||||
{
|
||||
const int n = x.size();
|
||||
@@ -133,7 +138,7 @@ HybridNonLinearSolver<FunctorType,Scalar>::solve(
|
||||
|
||||
/* check the input parameters for errors. */
|
||||
|
||||
if (n <= 0 || xtol < 0. || maxfev <= 0 || factor <= 0. )
|
||||
if (n <= 0 || parameters.xtol < 0. || parameters.maxfev <= 0 || parameters.factor <= 0. )
|
||||
return RelativeErrorTooSmall;
|
||||
if (mode == 2)
|
||||
for (j = 0; j < n; ++j)
|
||||
@@ -187,9 +192,9 @@ HybridNonLinearSolver<FunctorType,Scalar>::solve(
|
||||
|
||||
wa3 = diag.cwise() * x;
|
||||
xnorm = wa3.stableNorm();
|
||||
delta = factor * xnorm;
|
||||
delta = parameters.factor * xnorm;
|
||||
if (delta == 0.)
|
||||
delta = factor;
|
||||
delta = parameters.factor;
|
||||
}
|
||||
|
||||
/* form (q transpose)*fvec and store in qtf. */
|
||||
@@ -326,12 +331,12 @@ HybridNonLinearSolver<FunctorType,Scalar>::solve(
|
||||
|
||||
/* test for convergence. */
|
||||
|
||||
if (delta <= xtol * xnorm || fnorm == 0.)
|
||||
if (delta <= parameters.xtol * xnorm || fnorm == 0.)
|
||||
return RelativeErrorTooSmall;
|
||||
|
||||
/* tests for termination and stringent tolerances. */
|
||||
|
||||
if (nfev >= maxfev)
|
||||
if (nfev >= parameters.maxfev)
|
||||
return TooManyFunctionEvaluation;
|
||||
/* Computing MAX */
|
||||
if (Scalar(.1) * std::max(Scalar(.1) * delta, pnorm) <= epsilon<Scalar>() * xnorm)
|
||||
@@ -384,6 +389,7 @@ HybridNonLinearSolver<FunctorType,Scalar>::solveNumericalDiff(
|
||||
const int n = x.size();
|
||||
int nfev=0;
|
||||
Matrix< Scalar, Dynamic, 1> diag;
|
||||
Parameters parameters;
|
||||
|
||||
/* check the input parameters for errors. */
|
||||
if (n <= 0 || tol < 0.) {
|
||||
@@ -391,16 +397,18 @@ HybridNonLinearSolver<FunctorType,Scalar>::solveNumericalDiff(
|
||||
return ImproperInputParameters;
|
||||
}
|
||||
|
||||
parameters.maxfev = 200*(n+1);
|
||||
parameters.xtol = tol;
|
||||
|
||||
diag.setConstant(n, 1.);
|
||||
return solveNumericalDiff(
|
||||
x,
|
||||
nfev,
|
||||
diag,
|
||||
parameters,
|
||||
2,
|
||||
-1, -1,
|
||||
(n+1)*200,
|
||||
100.,
|
||||
tol, Scalar(0.)
|
||||
Scalar(0.)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -411,12 +419,10 @@ HybridNonLinearSolver<FunctorType,Scalar>::solveNumericalDiff(
|
||||
Matrix< Scalar, Dynamic, 1 > &x,
|
||||
int &nfev,
|
||||
Matrix< Scalar, Dynamic, 1 > &diag,
|
||||
const Parameters ¶meters,
|
||||
const int mode,
|
||||
int nb_of_subdiagonals,
|
||||
int nb_of_superdiagonals,
|
||||
const int maxfev,
|
||||
const Scalar factor,
|
||||
const Scalar xtol,
|
||||
const Scalar epsfcn
|
||||
)
|
||||
{
|
||||
@@ -454,7 +460,7 @@ HybridNonLinearSolver<FunctorType,Scalar>::solveNumericalDiff(
|
||||
|
||||
/* check the input parameters for errors. */
|
||||
|
||||
if (n <= 0 || xtol < 0. || maxfev <= 0 || nb_of_subdiagonals < 0 || nb_of_superdiagonals < 0 || factor <= 0. )
|
||||
if (n <= 0 || parameters.xtol < 0. || parameters.maxfev <= 0 || nb_of_subdiagonals < 0 || nb_of_superdiagonals < 0 || parameters.factor <= 0. )
|
||||
return RelativeErrorTooSmall;
|
||||
if (mode == 2)
|
||||
for (j = 0; j < n; ++j)
|
||||
@@ -514,9 +520,9 @@ HybridNonLinearSolver<FunctorType,Scalar>::solveNumericalDiff(
|
||||
|
||||
wa3 = diag.cwise() * x;
|
||||
xnorm = wa3.stableNorm();
|
||||
delta = factor * xnorm;
|
||||
delta = parameters.factor * xnorm;
|
||||
if (delta == 0.)
|
||||
delta = factor;
|
||||
delta = parameters.factor;
|
||||
}
|
||||
|
||||
/* form (q transpose)*fvec and store in qtf. */
|
||||
@@ -653,12 +659,12 @@ HybridNonLinearSolver<FunctorType,Scalar>::solveNumericalDiff(
|
||||
|
||||
/* test for convergence. */
|
||||
|
||||
if (delta <= xtol * xnorm || fnorm == 0.)
|
||||
if (delta <= parameters.xtol * xnorm || fnorm == 0.)
|
||||
return RelativeErrorTooSmall;
|
||||
|
||||
/* tests for termination and stringent tolerances. */
|
||||
|
||||
if (nfev >= maxfev)
|
||||
if (nfev >= parameters.maxfev)
|
||||
return TooManyFunctionEvaluation;
|
||||
/* Computing MAX */
|
||||
if (Scalar(.1) * std::max(Scalar(.1) * delta, pnorm) <= epsilon<Scalar>() * xnorm)
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
|
||||
|
||||
template<typename FunctorType, typename Scalar=double>
|
||||
class LevenbergMarquardt
|
||||
{
|
||||
@@ -21,6 +20,20 @@ public:
|
||||
UserAsked = 9
|
||||
};
|
||||
|
||||
struct Parameters {
|
||||
Parameters()
|
||||
: factor(Scalar(100.))
|
||||
, maxfev(400)
|
||||
, ftol(ei_sqrt(epsilon<Scalar>()))
|
||||
, xtol(ei_sqrt(epsilon<Scalar>()))
|
||||
, gtol(Scalar(0.)) { }
|
||||
Scalar factor;
|
||||
int maxfev; // maximum number of function evaluation
|
||||
Scalar ftol;
|
||||
Scalar xtol;
|
||||
Scalar gtol;
|
||||
};
|
||||
|
||||
Status minimize(
|
||||
Matrix< Scalar, Dynamic, 1 > &x,
|
||||
const Scalar tol = ei_sqrt(epsilon<Scalar>())
|
||||
@@ -31,12 +44,8 @@ public:
|
||||
int &nfev,
|
||||
int &njev,
|
||||
Matrix< Scalar, Dynamic, 1 > &diag,
|
||||
const int mode=1,
|
||||
const Scalar factor = Scalar(100.),
|
||||
const int maxfev = 400,
|
||||
const Scalar ftol = ei_sqrt(epsilon<Scalar>()),
|
||||
const Scalar xtol = ei_sqrt(epsilon<Scalar>()),
|
||||
const Scalar gtol = Scalar(0.)
|
||||
const Parameters ¶meters,
|
||||
const int mode=1
|
||||
);
|
||||
|
||||
Status minimizeNumericalDiff(
|
||||
@@ -48,12 +57,8 @@ public:
|
||||
Matrix< Scalar, Dynamic, 1 > &x,
|
||||
int &nfev,
|
||||
Matrix< Scalar, Dynamic, 1 > &diag,
|
||||
const Parameters ¶meters,
|
||||
const int mode=1,
|
||||
const Scalar factor = Scalar(100.),
|
||||
const int maxfev = 400,
|
||||
const Scalar ftol = ei_sqrt(epsilon<Scalar>()),
|
||||
const Scalar xtol = ei_sqrt(epsilon<Scalar>()),
|
||||
const Scalar gtol = Scalar(0.),
|
||||
const Scalar epsfcn = Scalar(0.)
|
||||
);
|
||||
|
||||
@@ -67,12 +72,8 @@ public:
|
||||
int &nfev,
|
||||
int &njev,
|
||||
Matrix< Scalar, Dynamic, 1 > &diag,
|
||||
const int mode=1,
|
||||
const Scalar factor = Scalar(100.),
|
||||
const int maxfev = 400,
|
||||
const Scalar ftol = ei_sqrt(epsilon<Scalar>()),
|
||||
const Scalar xtol = ei_sqrt(epsilon<Scalar>()),
|
||||
const Scalar gtol = Scalar(0.)
|
||||
const Parameters ¶meters,
|
||||
const int mode=1
|
||||
);
|
||||
|
||||
Matrix< Scalar, Dynamic, 1 > fvec;
|
||||
@@ -96,6 +97,7 @@ LevenbergMarquardt<FunctorType,Scalar>::minimize(
|
||||
Matrix< Scalar, Dynamic, Dynamic > fjac(m, n);
|
||||
Matrix< Scalar, Dynamic, 1> diag, qtf;
|
||||
VectorXi ipvt;
|
||||
Parameters parameters;
|
||||
|
||||
/* check the input parameters for errors. */
|
||||
if (n <= 0 || m < n || tol < 0.) {
|
||||
@@ -103,14 +105,16 @@ LevenbergMarquardt<FunctorType,Scalar>::minimize(
|
||||
return ImproperInputParameters;
|
||||
}
|
||||
|
||||
parameters.ftol = tol;
|
||||
parameters.xtol = tol;
|
||||
parameters.maxfev = 100*(n+1);
|
||||
|
||||
return minimize(
|
||||
x,
|
||||
nfev, njev,
|
||||
diag,
|
||||
1,
|
||||
100.,
|
||||
(n+1)*100,
|
||||
tol, tol, Scalar(0.)
|
||||
parameters,
|
||||
1
|
||||
);
|
||||
}
|
||||
|
||||
@@ -122,12 +126,8 @@ LevenbergMarquardt<FunctorType,Scalar>::minimize(
|
||||
int &nfev,
|
||||
int &njev,
|
||||
Matrix< Scalar, Dynamic, 1 > &diag,
|
||||
const int mode,
|
||||
const Scalar factor,
|
||||
const int maxfev,
|
||||
const Scalar ftol,
|
||||
const Scalar xtol,
|
||||
const Scalar gtol
|
||||
const Parameters ¶meters,
|
||||
const int mode
|
||||
)
|
||||
{
|
||||
const int n = x.size();
|
||||
@@ -156,7 +156,7 @@ LevenbergMarquardt<FunctorType,Scalar>::minimize(
|
||||
|
||||
/* check the input parameters for errors. */
|
||||
|
||||
if (n <= 0 || m < n || ftol < 0. || xtol < 0. || gtol < 0. || maxfev <= 0 || factor <= 0.)
|
||||
if (n <= 0 || m < n || parameters.ftol < 0. || parameters.xtol < 0. || parameters.gtol < 0. || parameters.maxfev <= 0 || parameters.factor <= 0.)
|
||||
return RelativeErrorTooSmall;
|
||||
|
||||
if (mode == 2)
|
||||
@@ -208,9 +208,9 @@ LevenbergMarquardt<FunctorType,Scalar>::minimize(
|
||||
|
||||
wa3 = diag.cwise() * x;
|
||||
xnorm = wa3.stableNorm();
|
||||
delta = factor * xnorm;
|
||||
delta = parameters.factor * xnorm;
|
||||
if (delta == 0.)
|
||||
delta = factor;
|
||||
delta = parameters.factor;
|
||||
}
|
||||
|
||||
/* form (q transpose)*fvec and store the first n components in */
|
||||
@@ -247,7 +247,7 @@ LevenbergMarquardt<FunctorType,Scalar>::minimize(
|
||||
|
||||
/* test for convergence of the gradient norm. */
|
||||
|
||||
if (gnorm <= gtol)
|
||||
if (gnorm <= parameters.gtol)
|
||||
return CosinusTooSmall;
|
||||
|
||||
/* rescale if necessary. */
|
||||
@@ -341,16 +341,16 @@ LevenbergMarquardt<FunctorType,Scalar>::minimize(
|
||||
|
||||
/* tests for convergence. */
|
||||
|
||||
if (ei_abs(actred) <= ftol && prered <= ftol && Scalar(.5) * ratio <= 1. && delta <= xtol * xnorm)
|
||||
if (ei_abs(actred) <= parameters.ftol && prered <= parameters.ftol && Scalar(.5) * ratio <= 1. && delta <= parameters.xtol * xnorm)
|
||||
return RelativeErrorAndReductionTooSmall;
|
||||
if (ei_abs(actred) <= ftol && prered <= ftol && Scalar(.5) * ratio <= 1.)
|
||||
if (ei_abs(actred) <= parameters.ftol && prered <= parameters.ftol && Scalar(.5) * ratio <= 1.)
|
||||
return RelativeReductionTooSmall;
|
||||
if (delta <= xtol * xnorm)
|
||||
if (delta <= parameters.xtol * xnorm)
|
||||
return RelativeErrorTooSmall;
|
||||
|
||||
/* tests for termination and stringent tolerances. */
|
||||
|
||||
if (nfev >= maxfev)
|
||||
if (nfev >= parameters.maxfev)
|
||||
return TooManyFunctionEvaluation;
|
||||
if (ei_abs(actred) <= epsilon<Scalar>() && prered <= epsilon<Scalar>() && Scalar(.5) * ratio <= 1.)
|
||||
return FtolTooSmall;
|
||||
@@ -379,6 +379,7 @@ LevenbergMarquardt<FunctorType,Scalar>::minimizeNumericalDiff(
|
||||
Matrix< Scalar, Dynamic, Dynamic > fjac(m, n);
|
||||
Matrix< Scalar, Dynamic, 1> diag, qtf;
|
||||
VectorXi ipvt;
|
||||
Parameters parameters;
|
||||
|
||||
/* check the input parameters for errors. */
|
||||
if (n <= 0 || m < n || tol < 0.) {
|
||||
@@ -386,14 +387,17 @@ LevenbergMarquardt<FunctorType,Scalar>::minimizeNumericalDiff(
|
||||
return ImproperInputParameters;
|
||||
}
|
||||
|
||||
parameters.ftol = tol;
|
||||
parameters.xtol = tol;
|
||||
parameters.maxfev = 200*(n+1);
|
||||
|
||||
return minimizeNumericalDiff(
|
||||
x,
|
||||
nfev,
|
||||
diag,
|
||||
parameters,
|
||||
1,
|
||||
100.,
|
||||
(n+1)*200,
|
||||
tol, tol, Scalar(0.), Scalar(0.)
|
||||
Scalar(0.)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -403,12 +407,8 @@ LevenbergMarquardt<FunctorType,Scalar>::minimizeNumericalDiff(
|
||||
Matrix< Scalar, Dynamic, 1 > &x,
|
||||
int &nfev,
|
||||
Matrix< Scalar, Dynamic, 1 > &diag,
|
||||
const Parameters ¶meters,
|
||||
const int mode,
|
||||
const Scalar factor,
|
||||
const int maxfev,
|
||||
const Scalar ftol,
|
||||
const Scalar xtol,
|
||||
const Scalar gtol,
|
||||
const Scalar epsfcn
|
||||
)
|
||||
{
|
||||
@@ -437,7 +437,7 @@ LevenbergMarquardt<FunctorType,Scalar>::minimizeNumericalDiff(
|
||||
|
||||
/* check the input parameters for errors. */
|
||||
|
||||
if (n <= 0 || m < n || ftol < 0. || xtol < 0. || gtol < 0. || maxfev <= 0 || factor <= 0.)
|
||||
if (n <= 0 || m < n || parameters.ftol < 0. || parameters.xtol < 0. || parameters.gtol < 0. || parameters.maxfev <= 0 || parameters.factor <= 0.)
|
||||
return RelativeErrorTooSmall;
|
||||
if (mode == 2)
|
||||
for (j = 0; j < n; ++j)
|
||||
@@ -488,9 +488,9 @@ LevenbergMarquardt<FunctorType,Scalar>::minimizeNumericalDiff(
|
||||
|
||||
wa3 = diag.cwise() * x;
|
||||
xnorm = wa3.stableNorm();
|
||||
delta = factor * xnorm;
|
||||
delta = parameters.factor * xnorm;
|
||||
if (delta == 0.)
|
||||
delta = factor;
|
||||
delta = parameters.factor;
|
||||
}
|
||||
|
||||
/* form (q transpose)*fvec and store the first n components in */
|
||||
@@ -527,7 +527,7 @@ LevenbergMarquardt<FunctorType,Scalar>::minimizeNumericalDiff(
|
||||
|
||||
/* test for convergence of the gradient norm. */
|
||||
|
||||
if (gnorm <= gtol)
|
||||
if (gnorm <= parameters.gtol)
|
||||
return CosinusTooSmall;
|
||||
|
||||
/* rescale if necessary. */
|
||||
@@ -621,16 +621,16 @@ LevenbergMarquardt<FunctorType,Scalar>::minimizeNumericalDiff(
|
||||
|
||||
/* tests for convergence. */
|
||||
|
||||
if (ei_abs(actred) <= ftol && prered <= ftol && Scalar(.5) * ratio <= 1. && delta <= xtol * xnorm)
|
||||
if (ei_abs(actred) <= parameters.ftol && prered <= parameters.ftol && Scalar(.5) * ratio <= 1. && delta <= parameters.xtol * xnorm)
|
||||
return RelativeErrorAndReductionTooSmall;
|
||||
if (ei_abs(actred) <= ftol && prered <= ftol && Scalar(.5) * ratio <= 1.)
|
||||
if (ei_abs(actred) <= parameters.ftol && prered <= parameters.ftol && Scalar(.5) * ratio <= 1.)
|
||||
return RelativeReductionTooSmall;
|
||||
if (delta <= xtol * xnorm)
|
||||
if (delta <= parameters.xtol * xnorm)
|
||||
return RelativeErrorTooSmall;
|
||||
|
||||
/* tests for termination and stringent tolerances. */
|
||||
|
||||
if (nfev >= maxfev)
|
||||
if (nfev >= parameters.maxfev)
|
||||
return TooManyFunctionEvaluation;
|
||||
if (ei_abs(actred) <= epsilon<Scalar>() && prered <= epsilon<Scalar>() && Scalar(.5) * ratio <= 1.)
|
||||
return FtolTooSmall;
|
||||
@@ -660,6 +660,7 @@ LevenbergMarquardt<FunctorType,Scalar>::minimizeOptimumStorage(
|
||||
Matrix< Scalar, Dynamic, Dynamic > fjac(m, n);
|
||||
Matrix< Scalar, Dynamic, 1> diag, qtf;
|
||||
VectorXi ipvt;
|
||||
Parameters parameters;
|
||||
|
||||
/* check the input parameters for errors. */
|
||||
if (n <= 0 || m < n || tol < 0.) {
|
||||
@@ -667,14 +668,16 @@ LevenbergMarquardt<FunctorType,Scalar>::minimizeOptimumStorage(
|
||||
return ImproperInputParameters;
|
||||
}
|
||||
|
||||
parameters.ftol = tol;
|
||||
parameters.xtol = tol;
|
||||
parameters.maxfev = 100*(n+1);
|
||||
|
||||
return minimizeOptimumStorage(
|
||||
x,
|
||||
nfev, njev,
|
||||
diag,
|
||||
1,
|
||||
100.,
|
||||
(n+1)*100,
|
||||
tol, tol, Scalar(0.)
|
||||
parameters,
|
||||
1
|
||||
);
|
||||
}
|
||||
|
||||
@@ -685,12 +688,8 @@ LevenbergMarquardt<FunctorType,Scalar>::minimizeOptimumStorage(
|
||||
int &nfev,
|
||||
int &njev,
|
||||
Matrix< Scalar, Dynamic, 1 > &diag,
|
||||
const int mode,
|
||||
const Scalar factor,
|
||||
const int maxfev,
|
||||
const Scalar ftol,
|
||||
const Scalar xtol,
|
||||
const Scalar gtol
|
||||
const Parameters ¶meters,
|
||||
const int mode
|
||||
)
|
||||
{
|
||||
const int n = x.size();
|
||||
@@ -720,7 +719,7 @@ LevenbergMarquardt<FunctorType,Scalar>::minimizeOptimumStorage(
|
||||
|
||||
/* check the input parameters for errors. */
|
||||
|
||||
if (n <= 0 || m < n || ftol < 0. || xtol < 0. || gtol < 0. || maxfev <= 0 || factor <= 0.)
|
||||
if (n <= 0 || m < n || parameters.ftol < 0. || parameters.xtol < 0. || parameters.gtol < 0. || parameters.maxfev <= 0 || parameters.factor <= 0.)
|
||||
return RelativeErrorTooSmall;
|
||||
|
||||
if (mode == 2)
|
||||
@@ -805,9 +804,9 @@ LevenbergMarquardt<FunctorType,Scalar>::minimizeOptimumStorage(
|
||||
|
||||
wa3 = diag.cwise() * x;
|
||||
xnorm = wa3.stableNorm();
|
||||
delta = factor * xnorm;
|
||||
delta = parameters.factor * xnorm;
|
||||
if (delta == 0.)
|
||||
delta = factor;
|
||||
delta = parameters.factor;
|
||||
}
|
||||
|
||||
/* compute the norm of the scaled gradient. */
|
||||
@@ -827,7 +826,7 @@ LevenbergMarquardt<FunctorType,Scalar>::minimizeOptimumStorage(
|
||||
|
||||
/* test for convergence of the gradient norm. */
|
||||
|
||||
if (gnorm <= gtol)
|
||||
if (gnorm <= parameters.gtol)
|
||||
return CosinusTooSmall;
|
||||
|
||||
/* rescale if necessary. */
|
||||
@@ -921,16 +920,16 @@ LevenbergMarquardt<FunctorType,Scalar>::minimizeOptimumStorage(
|
||||
|
||||
/* tests for convergence. */
|
||||
|
||||
if (ei_abs(actred) <= ftol && prered <= ftol && Scalar(.5) * ratio <= 1. && delta <= xtol * xnorm)
|
||||
if (ei_abs(actred) <= parameters.ftol && prered <= parameters.ftol && Scalar(.5) * ratio <= 1. && delta <= parameters.xtol * xnorm)
|
||||
return RelativeErrorAndReductionTooSmall;
|
||||
if (ei_abs(actred) <= ftol && prered <= ftol && Scalar(.5) * ratio <= 1.)
|
||||
if (ei_abs(actred) <= parameters.ftol && prered <= parameters.ftol && Scalar(.5) * ratio <= 1.)
|
||||
return RelativeReductionTooSmall;
|
||||
if (delta <= xtol * xnorm)
|
||||
if (delta <= parameters.xtol * xnorm)
|
||||
return RelativeErrorTooSmall;
|
||||
|
||||
/* tests for termination and stringent tolerances. */
|
||||
|
||||
if (nfev >= maxfev)
|
||||
if (nfev >= parameters.maxfev)
|
||||
return TooManyFunctionEvaluation;
|
||||
if (ei_abs(actred) <= epsilon<Scalar>() && prered <= epsilon<Scalar>() && Scalar(.5) * ratio <= 1.)
|
||||
return FtolTooSmall;
|
||||
|
||||
Reference in New Issue
Block a user