use of org.hipparchus.optim.nonlinear.vector.leastsquares.LeastSquaresOptimizer.Optimum in project Orekit by CS-SI.
the class EstimationTestUtils method checkFit.
/**
* Checker for batch LS estimator validation
* @param context Context used for the test
* @param estimator Batch LS estimator
* @param iterations Number of iterations expected
* @param evaluations Number of evaluations expected
* @param expectedRMS Expected RMS value
* @param rmsEps Tolerance on expected RMS
* @param expectedMax Expected weighted residual maximum
* @param maxEps Tolerance on weighted residual maximum
* @param expectedDeltaPos Expected position difference between estimated orbit and initial orbit
* @param posEps Tolerance on expected position difference
* @param expectedDeltaVel Expected velocity difference between estimated orbit and initial orbit
* @param velEps Tolerance on expected velocity difference
* @throws OrekitException
*/
public static void checkFit(final Context context, final BatchLSEstimator estimator, final int iterations, final int evaluations, final double expectedRMS, final double rmsEps, final double expectedMax, final double maxEps, final double expectedDeltaPos, final double posEps, final double expectedDeltaVel, final double velEps) throws OrekitException {
final Orbit estimatedOrbit = estimator.estimate()[0].getInitialState().getOrbit();
final Vector3D estimatedPosition = estimatedOrbit.getPVCoordinates().getPosition();
final Vector3D estimatedVelocity = estimatedOrbit.getPVCoordinates().getVelocity();
Assert.assertEquals(iterations, estimator.getIterationsCount());
Assert.assertEquals(evaluations, estimator.getEvaluationsCount());
Optimum optimum = estimator.getOptimum();
Assert.assertEquals(iterations, optimum.getIterations());
Assert.assertEquals(evaluations, optimum.getEvaluations());
int k = 0;
double sum = 0;
double max = 0;
for (final Map.Entry<ObservedMeasurement<?>, EstimatedMeasurement<?>> entry : estimator.getLastEstimations().entrySet()) {
final ObservedMeasurement<?> m = entry.getKey();
final EstimatedMeasurement<?> e = entry.getValue();
final double[] weight = m.getBaseWeight();
final double[] sigma = m.getTheoreticalStandardDeviation();
final double[] observed = m.getObservedValue();
final double[] theoretical = e.getEstimatedValue();
for (int i = 0; i < m.getDimension(); ++i) {
final double weightedResidual = weight[i] * (theoretical[i] - observed[i]) / sigma[i];
++k;
sum += weightedResidual * weightedResidual;
max = FastMath.max(max, FastMath.abs(weightedResidual));
}
}
Assert.assertEquals(expectedRMS, FastMath.sqrt(sum / k), rmsEps);
Assert.assertEquals(expectedMax, max, maxEps);
Assert.assertEquals(expectedDeltaPos, Vector3D.distance(context.initialOrbit.getPVCoordinates().getPosition(), estimatedPosition), posEps);
Assert.assertEquals(expectedDeltaVel, Vector3D.distance(context.initialOrbit.getPVCoordinates().getVelocity(), estimatedVelocity), velEps);
}
Aggregations