In LeastSquaresProblem.Evaluation removed the getValue() method.

- The residuals are the really the values of the objective function
  that is being minimized.
- Forcing the value to be a real vector and the residual computed
  through subtraction is an unnecessary constraint. For example
  Rotation.distance() will compute a better residual than
  subtracting the quaternion elements of two rotations.
- Method was not used by any optimizer.

JIRA: MATH-1102

git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@1571306 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Luc Maisonobe 2014-02-24 14:57:44 +00:00
parent a573059d05
commit 9ac2b15e4a
6 changed files with 10 additions and 35 deletions

View File

@ -59,11 +59,6 @@ class DenseWeightedEvaluation extends AbstractEvaluation {
return this.weightSqrt.operate(this.unweighted.getResiduals());
}
/** {@inheritDoc} */
public RealVector getValue() {
return this.weightSqrt.operate(unweighted.getValue());
}
/* delegate */
/** {@inheritDoc} */

View File

@ -216,11 +216,11 @@ public class LeastSquaresFactory {
iteration,
new PointVectorValuePair(
previous.getPoint().toArray(),
previous.getValue().toArray(),
previous.getResiduals().toArray(),
false),
new PointVectorValuePair(
current.getPoint().toArray(),
current.getValue().toArray(),
current.getResiduals().toArray(),
false)
);
}
@ -344,12 +344,10 @@ public class LeastSquaresFactory {
/** the point of evaluation */
private final RealVector point;
/** value at point */
private final RealVector values;
/** deriviative at point */
private final RealMatrix jacobian;
/** reference to the observed values */
private final RealVector target;
/** the computed residuals. */
private final RealVector residuals;
/**
* Create an {@link Evaluation} with no weights.
@ -364,15 +362,9 @@ public class LeastSquaresFactory {
final RealVector target,
final RealVector point) {
super(target.getDimension());
this.values = values;
this.jacobian = jacobian;
this.target = target;
this.point = point;
}
/** {@inheritDoc} */
public RealVector getValue() {
return this.values;
this.residuals = target.subtract(values);
}
/** {@inheritDoc} */
@ -387,7 +379,7 @@ public class LeastSquaresFactory {
/** {@inheritDoc} */
public RealVector getResiduals() {
return target.subtract(this.getValue());
return this.residuals;
}
}

View File

@ -118,13 +118,6 @@ public interface LeastSquaresProblem extends OptimizationProblem<LeastSquaresPro
*/
double getRMS();
/**
* Get the weighted objective (model) function value.
*
* @return the weighted objective function value at the specified point.
*/
RealVector getValue();
/**
* Get the weighted Jacobian matrix.
*

View File

@ -76,11 +76,6 @@ class OptimumImpl implements Optimum {
return value.getRMS();
}
/** {@inheritDoc} */
public RealVector getValue() {
return value.getValue();
}
/** {@inheritDoc} */
public RealMatrix getJacobian() {
return value.getJacobian();

View File

@ -156,7 +156,7 @@ public abstract class AbstractLeastSquaresOptimizerAbstractTest {
Assert.assertEquals(0, optimum.getRMS(), TOl);
assertEquals(TOl, optimum.getPoint(), 1.5);
Assert.assertEquals(3.0, optimum.getValue().getEntry(0), TOl);
Assert.assertEquals(0.0, optimum.getResiduals().getEntry(0), TOl);
}
@Test
@ -169,7 +169,7 @@ public abstract class AbstractLeastSquaresOptimizerAbstractTest {
Assert.assertEquals(0, optimum.getRMS(), TOl);
assertEquals(TOl, optimum.getPoint(), 7, 3);
assertEquals(TOl, optimum.getValue(), 4, 6, 1);
assertEquals(TOl, optimum.getResiduals(), 0, 0, 0);
}
@Test

View File

@ -141,12 +141,12 @@ public class EvaluationTest {
.evaluate(point);
//action
RealVector value = evaluation.getValue();
RealVector residuals = evaluation.getResiduals();
RealMatrix jacobian = evaluation.getJacobian();
//verify
Assert.assertArrayEquals(evaluation.getPoint().toArray(), point.toArray(), 0);
Assert.assertArrayEquals(new double[]{12, 8}, value.toArray(), Precision.EPSILON);
Assert.assertArrayEquals(new double[]{-12, -8}, residuals.toArray(), Precision.EPSILON);
TestUtils.assertEquals(
"jacobian",
jacobian,