mirror of
https://github.com/apache/commons-math.git
synced 2025-02-08 11:05:56 +00:00
MATH-993
Moved convergence check block to allow returning before an exception would be raised. git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@1497713 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
1e6e14cb5f
commit
74e699d076
@ -51,6 +51,10 @@ If the output is not quite correct, check for invisible trailing spaces!
|
||||
</properties>
|
||||
<body>
|
||||
<release version="x.y" date="TBD" description="TBD">
|
||||
<action dev="erans" type="fix" issue="MATH-993">
|
||||
In "GaussNewtonOptimizer", check for convergence before updating the
|
||||
parameters estimation for the next iteration.
|
||||
</action>
|
||||
<action dev="luc" type="add" issue="MATH-967" due-to="Oleksandr Kornieiev">
|
||||
Added midpoint integration method.
|
||||
</action>
|
||||
|
@ -139,6 +139,15 @@ public class GaussNewtonOptimizer extends AbstractLeastSquaresOptimizer {
|
||||
}
|
||||
}
|
||||
|
||||
// Check convergence.
|
||||
if (previous != null) {
|
||||
converged = checker.converged(getIterations(), previous, current);
|
||||
if (converged) {
|
||||
setCost(computeCost(currentResiduals));
|
||||
return current;
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
// solve the linearized least squares problem
|
||||
RealMatrix mA = new BlockRealMatrix(a);
|
||||
@ -153,15 +162,6 @@ public class GaussNewtonOptimizer extends AbstractLeastSquaresOptimizer {
|
||||
} catch (SingularMatrixException e) {
|
||||
throw new ConvergenceException(LocalizedFormats.UNABLE_TO_SOLVE_SINGULAR_PROBLEM);
|
||||
}
|
||||
|
||||
// Check convergence.
|
||||
if (previous != null) {
|
||||
converged = checker.converged(getIterations(), previous, current);
|
||||
if (converged) {
|
||||
setCost(computeCost(currentResiduals));
|
||||
return current;
|
||||
}
|
||||
}
|
||||
}
|
||||
// Must never happen.
|
||||
throw new MathInternalError();
|
||||
|
Loading…
x
Reference in New Issue
Block a user