From 3456d2a12a0bc2455cc5d076cde12151a1cfa57b Mon Sep 17 00:00:00 2001 From: Gilles Sadowski Date: Fri, 9 Nov 2012 14:57:10 +0000 Subject: [PATCH] MATH-887 Renamed "computeJacobian" to "computeWeightedJacobian" to relect what is actually done. Made "setCost" a "protected" method (as it should only be modified according to the optimum found by the subclass's algorithm (defined in "doOptimize()"). git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@1407478 13f79535-47bb-0310-9956-ffa450edef68 --- .../general/AbstractLeastSquaresOptimizer.java | 12 ++++++------ .../optimization/general/GaussNewtonOptimizer.java | 2 +- .../general/LevenbergMarquardtOptimizer.java | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/main/java/org/apache/commons/math3/optimization/general/AbstractLeastSquaresOptimizer.java b/src/main/java/org/apache/commons/math3/optimization/general/AbstractLeastSquaresOptimizer.java index c89d38acd..7ac41666d 100644 --- a/src/main/java/org/apache/commons/math3/optimization/general/AbstractLeastSquaresOptimizer.java +++ b/src/main/java/org/apache/commons/math3/optimization/general/AbstractLeastSquaresOptimizer.java @@ -73,7 +73,7 @@ public abstract class AbstractLeastSquaresOptimizer * in the derived class (the {@link LevenbergMarquardtOptimizer * Levenberg-Marquardt optimizer} does this). * @deprecated As of 3.1. To be removed in 4.0. Please use - * {@link #computeJacobian(double[])} instead. + * {@link #computeWeightedJacobian(double[])} instead. */ @Deprecated protected double[][] weightedResidualJacobian; @@ -143,12 +143,12 @@ public abstract class AbstractLeastSquaresOptimizer * * @throws DimensionMismatchException if the Jacobian dimension does not * match problem dimension. - * @deprecated As of 3.1. Please use {@link #computeJacobian(double[])} + * @deprecated As of 3.1. Please use {@link #computeWeightedJacobian(double[])} * instead. */ @Deprecated protected void updateJacobian() { - computeJacobian(point); + computeWeightedJacobian(point); } /** @@ -160,7 +160,7 @@ public abstract class AbstractLeastSquaresOptimizer * match problem dimension. * @since 3.1 */ - protected RealMatrix computeJacobian(double[] params) { + protected RealMatrix computeWeightedJacobian(double[] params) { ++jacobianEvaluations; final DerivativeStructure[] dsPoint = new DerivativeStructure[params.length]; @@ -269,7 +269,7 @@ public abstract class AbstractLeastSquaresOptimizer * @param cost Cost value. * @since 3.1 */ - public void setCost(double cost) { + protected void setCost(double cost) { this.cost = cost; } @@ -329,7 +329,7 @@ public abstract class AbstractLeastSquaresOptimizer public double[][] computeCovariances(double[] params, double threshold) { // Set up the Jacobian. - final RealMatrix j = computeJacobian(params); + final RealMatrix j = computeWeightedJacobian(params); // Compute transpose(J)J. final RealMatrix jTj = j.transpose().multiply(j); diff --git a/src/main/java/org/apache/commons/math3/optimization/general/GaussNewtonOptimizer.java b/src/main/java/org/apache/commons/math3/optimization/general/GaussNewtonOptimizer.java index e4bc54a00..bd2f7cda4 100644 --- a/src/main/java/org/apache/commons/math3/optimization/general/GaussNewtonOptimizer.java +++ b/src/main/java/org/apache/commons/math3/optimization/general/GaussNewtonOptimizer.java @@ -132,7 +132,7 @@ public class GaussNewtonOptimizer extends AbstractLeastSquaresOptimizer { // Value of the objective function at "currentPoint". final double[] currentObjective = computeObjectiveValue(currentPoint); final double[] currentResiduals = computeResiduals(currentObjective); - final RealMatrix weightedJacobian = computeJacobian(currentPoint); + final RealMatrix weightedJacobian = computeWeightedJacobian(currentPoint); current = new PointVectorValuePair(currentPoint, currentObjective); // build the linear problem diff --git a/src/main/java/org/apache/commons/math3/optimization/general/LevenbergMarquardtOptimizer.java b/src/main/java/org/apache/commons/math3/optimization/general/LevenbergMarquardtOptimizer.java index cff13271b..491ec93a0 100644 --- a/src/main/java/org/apache/commons/math3/optimization/general/LevenbergMarquardtOptimizer.java +++ b/src/main/java/org/apache/commons/math3/optimization/general/LevenbergMarquardtOptimizer.java @@ -318,7 +318,7 @@ public class LevenbergMarquardtOptimizer extends AbstractLeastSquaresOptimizer { final PointVectorValuePair previous = current; // QR decomposition of the jacobian matrix - qrDecomposition(computeJacobian(currentPoint)); + qrDecomposition(computeWeightedJacobian(currentPoint)); weightedResidual = weightMatrixSqrt.operate(currentResiduals); for (int i = 0; i < nR; i++) {