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
This commit is contained in:
Gilles Sadowski 2012-11-09 14:57:10 +00:00
parent ca08d0e8b1
commit 3456d2a12a
3 changed files with 8 additions and 8 deletions

View File

@ -73,7 +73,7 @@ public abstract class AbstractLeastSquaresOptimizer
* in the derived class (the {@link LevenbergMarquardtOptimizer * in the derived class (the {@link LevenbergMarquardtOptimizer
* Levenberg-Marquardt optimizer} does this). * Levenberg-Marquardt optimizer} does this).
* @deprecated As of 3.1. To be removed in 4.0. Please use * @deprecated As of 3.1. To be removed in 4.0. Please use
* {@link #computeJacobian(double[])} instead. * {@link #computeWeightedJacobian(double[])} instead.
*/ */
@Deprecated @Deprecated
protected double[][] weightedResidualJacobian; protected double[][] weightedResidualJacobian;
@ -143,12 +143,12 @@ public abstract class AbstractLeastSquaresOptimizer
* *
* @throws DimensionMismatchException if the Jacobian dimension does not * @throws DimensionMismatchException if the Jacobian dimension does not
* match problem dimension. * match problem dimension.
* @deprecated As of 3.1. Please use {@link #computeJacobian(double[])} * @deprecated As of 3.1. Please use {@link #computeWeightedJacobian(double[])}
* instead. * instead.
*/ */
@Deprecated @Deprecated
protected void updateJacobian() { protected void updateJacobian() {
computeJacobian(point); computeWeightedJacobian(point);
} }
/** /**
@ -160,7 +160,7 @@ public abstract class AbstractLeastSquaresOptimizer
* match problem dimension. * match problem dimension.
* @since 3.1 * @since 3.1
*/ */
protected RealMatrix computeJacobian(double[] params) { protected RealMatrix computeWeightedJacobian(double[] params) {
++jacobianEvaluations; ++jacobianEvaluations;
final DerivativeStructure[] dsPoint = new DerivativeStructure[params.length]; final DerivativeStructure[] dsPoint = new DerivativeStructure[params.length];
@ -269,7 +269,7 @@ public abstract class AbstractLeastSquaresOptimizer
* @param cost Cost value. * @param cost Cost value.
* @since 3.1 * @since 3.1
*/ */
public void setCost(double cost) { protected void setCost(double cost) {
this.cost = cost; this.cost = cost;
} }
@ -329,7 +329,7 @@ public abstract class AbstractLeastSquaresOptimizer
public double[][] computeCovariances(double[] params, public double[][] computeCovariances(double[] params,
double threshold) { double threshold) {
// Set up the Jacobian. // Set up the Jacobian.
final RealMatrix j = computeJacobian(params); final RealMatrix j = computeWeightedJacobian(params);
// Compute transpose(J)J. // Compute transpose(J)J.
final RealMatrix jTj = j.transpose().multiply(j); final RealMatrix jTj = j.transpose().multiply(j);

View File

@ -132,7 +132,7 @@ public class GaussNewtonOptimizer extends AbstractLeastSquaresOptimizer {
// Value of the objective function at "currentPoint". // Value of the objective function at "currentPoint".
final double[] currentObjective = computeObjectiveValue(currentPoint); final double[] currentObjective = computeObjectiveValue(currentPoint);
final double[] currentResiduals = computeResiduals(currentObjective); final double[] currentResiduals = computeResiduals(currentObjective);
final RealMatrix weightedJacobian = computeJacobian(currentPoint); final RealMatrix weightedJacobian = computeWeightedJacobian(currentPoint);
current = new PointVectorValuePair(currentPoint, currentObjective); current = new PointVectorValuePair(currentPoint, currentObjective);
// build the linear problem // build the linear problem

View File

@ -318,7 +318,7 @@ public class LevenbergMarquardtOptimizer extends AbstractLeastSquaresOptimizer {
final PointVectorValuePair previous = current; final PointVectorValuePair previous = current;
// QR decomposition of the jacobian matrix // QR decomposition of the jacobian matrix
qrDecomposition(computeJacobian(currentPoint)); qrDecomposition(computeWeightedJacobian(currentPoint));
weightedResidual = weightMatrixSqrt.operate(currentResiduals); weightedResidual = weightMatrixSqrt.operate(currentResiduals);
for (int i = 0; i < nR; i++) { for (int i = 0; i < nR; i++) {