Search in sources :

Example 1 with Optimum

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);
}
Also used : Optimum(org.hipparchus.optim.nonlinear.vector.leastsquares.LeastSquaresOptimizer.Optimum) KeplerianOrbit(org.orekit.orbits.KeplerianOrbit) Orbit(org.orekit.orbits.Orbit) FieldVector3D(org.hipparchus.geometry.euclidean.threed.FieldVector3D) Vector3D(org.hipparchus.geometry.euclidean.threed.Vector3D) Map(java.util.Map) HashMap(java.util.HashMap) ObservedMeasurement(org.orekit.estimation.measurements.ObservedMeasurement) EstimatedMeasurement(org.orekit.estimation.measurements.EstimatedMeasurement)

Aggregations

HashMap (java.util.HashMap)1 Map (java.util.Map)1 FieldVector3D (org.hipparchus.geometry.euclidean.threed.FieldVector3D)1 Vector3D (org.hipparchus.geometry.euclidean.threed.Vector3D)1 Optimum (org.hipparchus.optim.nonlinear.vector.leastsquares.LeastSquaresOptimizer.Optimum)1 EstimatedMeasurement (org.orekit.estimation.measurements.EstimatedMeasurement)1 ObservedMeasurement (org.orekit.estimation.measurements.ObservedMeasurement)1 KeplerianOrbit (org.orekit.orbits.KeplerianOrbit)1 Orbit (org.orekit.orbits.Orbit)1