Commit 0e95e5ed authored by Bryan Cazabonne's avatar Bryan Cazabonne
Browse files

Finally removed the unneeded AnalyticalKalmanModel class.

parent 9075a928
Pipeline #1669 passed with stages
in 20 minutes and 34 seconds
/* Copyright 2002-2022 CS GROUP
* Licensed to CS GROUP (CS) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* CS licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.orekit.estimation.leastsquares;
import java.util.List;
import org.orekit.estimation.measurements.ObservedMeasurement;
import org.orekit.orbits.Orbit;
import org.orekit.propagation.MatricesHarvester;
import org.orekit.propagation.Propagator;
import org.orekit.propagation.conversion.OrbitDeterminationPropagatorBuilder;
import org.orekit.propagation.integration.AbstractJacobiansMapper;
import org.orekit.utils.ParameterDriversList;
/**
* Bridge between {@link ObservedMeasurement measurements} and {@link
* org.hipparchus.optim.nonlinear.vector.leastsquares.LeastSquaresProblem
* least squares problems}.
* @author Luc Maisonobe
* @author Bryan Cazabonne
* @author Thomas Paulet
* @since 11.1
*/
public class AnalyticalBatchLSModel extends AbstractBatchLSModel {
/** Name of the State Transition Matrix state. */
private static final String STM_NAME = AnalyticalBatchLSModel.class.getName() + "-derivatives";
/** Simple constructor.
* @param propagatorBuilders builders to use for propagation
* @param measurements measurements
* @param estimatedMeasurementsParameters estimated measurements parameters
* @param observer observer to be notified at model calls
*/
public AnalyticalBatchLSModel(final OrbitDeterminationPropagatorBuilder[] propagatorBuilders,
final List<ObservedMeasurement<?>> measurements,
final ParameterDriversList estimatedMeasurementsParameters,
final ModelObserver observer) {
// call super constructor
super(propagatorBuilders, measurements, estimatedMeasurementsParameters, observer);
}
/** {@inheritDoc} */
@Override
protected MatricesHarvester configureHarvester(final Propagator propagator) {
return propagator.setupMatricesComputation(STM_NAME, null, null);
}
/** {@inheritDoc} */
@Override
@Deprecated
protected AbstractJacobiansMapper configureDerivatives(final Propagator propagators) {
// This deprecated method is replaced by configureHarvester() method
// Therefore there is no risk to return a null value here
return null;
}
/** {@inheritDoc} */
@Override
protected Orbit configureOrbits(final MatricesHarvester harvester,
final Propagator propagator) {
return propagator.getInitialState().getOrbit();
}
}
......@@ -56,7 +56,7 @@ public class BatchLSModel extends AbstractBatchLSModel {
/** {@inheritDoc} */
@Override
protected MatricesHarvester configureHarvester(final Propagator propagator) {
return ((NumericalPropagator) propagator).setupMatricesComputation(STM_NAME, null, null);
return propagator.setupMatricesComputation(STM_NAME, null, null);
}
/** {@inheritDoc} */
......
......@@ -75,7 +75,7 @@ public class DSSTBatchLSModel extends AbstractBatchLSModel {
/** {@inheritDoc} */
@Override
protected MatricesHarvester configureHarvester(final Propagator propagator) {
return ((DSSTPropagator) propagator).setupMatricesComputation(STM_NAME, null, null);
return propagator.setupMatricesComputation(STM_NAME, null, null);
}
/** {@inheritDoc} */
......
......@@ -23,7 +23,7 @@ import org.hipparchus.util.FastMath;
import org.orekit.attitudes.AttitudeProvider;
import org.orekit.attitudes.InertialProvider;
import org.orekit.estimation.leastsquares.AbstractBatchLSModel;
import org.orekit.estimation.leastsquares.AnalyticalBatchLSModel;
import org.orekit.estimation.leastsquares.BatchLSModel;
import org.orekit.estimation.leastsquares.ModelObserver;
import org.orekit.estimation.measurements.ObservedMeasurement;
import org.orekit.estimation.sequential.AbstractKalmanModel;
......@@ -269,7 +269,7 @@ public class BrouwerLyddanePropagatorBuilder extends AbstractPropagatorBuilder i
final List<ObservedMeasurement<?>> measurements,
final ParameterDriversList estimatedMeasurementsParameters,
final ModelObserver observer) {
return new AnalyticalBatchLSModel(builders, measurements, estimatedMeasurementsParameters, observer);
return new BatchLSModel(builders, measurements, estimatedMeasurementsParameters, observer);
}
/** {@inheritDoc} */
......
......@@ -21,7 +21,7 @@ import java.util.List;
import org.orekit.attitudes.AttitudeProvider;
import org.orekit.attitudes.InertialProvider;
import org.orekit.estimation.leastsquares.AbstractBatchLSModel;
import org.orekit.estimation.leastsquares.AnalyticalBatchLSModel;
import org.orekit.estimation.leastsquares.BatchLSModel;
import org.orekit.estimation.leastsquares.ModelObserver;
import org.orekit.estimation.measurements.ObservedMeasurement;
import org.orekit.estimation.sequential.AbstractKalmanModel;
......@@ -214,7 +214,7 @@ public class EcksteinHechlerPropagatorBuilder extends AbstractPropagatorBuilder
final List<ObservedMeasurement<?>> measurements,
final ParameterDriversList estimatedMeasurementsParameters,
final ModelObserver observer) {
return new AnalyticalBatchLSModel(builders, measurements, estimatedMeasurementsParameters, observer);
return new BatchLSModel(builders, measurements, estimatedMeasurementsParameters, observer);
}
/** {@inheritDoc} */
......
......@@ -21,7 +21,7 @@ import java.util.List;
import org.orekit.attitudes.AttitudeProvider;
import org.orekit.attitudes.InertialProvider;
import org.orekit.estimation.leastsquares.AbstractBatchLSModel;
import org.orekit.estimation.leastsquares.AnalyticalBatchLSModel;
import org.orekit.estimation.leastsquares.BatchLSModel;
import org.orekit.estimation.leastsquares.ModelObserver;
import org.orekit.estimation.measurements.ObservedMeasurement;
import org.orekit.estimation.sequential.AbstractKalmanModel;
......@@ -97,7 +97,7 @@ public class KeplerianPropagatorBuilder extends AbstractPropagatorBuilder implem
final List<ObservedMeasurement<?>> measurements,
final ParameterDriversList estimatedMeasurementsParameters,
final ModelObserver observer) {
return new AnalyticalBatchLSModel(builders, measurements, estimatedMeasurementsParameters, observer);
return new BatchLSModel(builders, measurements, estimatedMeasurementsParameters, observer);
}
/** {@inheritDoc} */
......
......@@ -22,7 +22,7 @@ import org.orekit.annotation.DefaultDataContext;
import org.orekit.attitudes.InertialProvider;
import org.orekit.data.DataContext;
import org.orekit.estimation.leastsquares.AbstractBatchLSModel;
import org.orekit.estimation.leastsquares.AnalyticalBatchLSModel;
import org.orekit.estimation.leastsquares.BatchLSModel;
import org.orekit.estimation.leastsquares.ModelObserver;
import org.orekit.estimation.measurements.ObservedMeasurement;
import org.orekit.estimation.sequential.AbstractKalmanModel;
......@@ -220,7 +220,7 @@ public class TLEPropagatorBuilder extends AbstractPropagatorBuilder implements O
final List<ObservedMeasurement<?>> measurements,
final ParameterDriversList estimatedMeasurementsParameters,
final ModelObserver observer) {
return new AnalyticalBatchLSModel(builders, measurements, estimatedMeasurementsParameters, observer);
return new BatchLSModel(builders, measurements, estimatedMeasurementsParameters, observer);
}
@Override
......
/* Copyright 2002-2022 CS GROUP
* Licensed to CS GROUP (CS) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* CS licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.orekit.estimation.leastsquares;
import static org.junit.Assert.assertEquals;
import java.util.List;
import java.util.Map;
import org.hipparchus.geometry.euclidean.threed.Vector3D;
import org.hipparchus.linear.ArrayRealVector;
import org.hipparchus.linear.RealMatrix;
import org.hipparchus.linear.RealVector;
import org.hipparchus.util.Incrementor;
import org.hipparchus.util.Pair;
import org.junit.Assert;
import org.junit.Test;
import org.orekit.estimation.TLEContext;
import org.orekit.estimation.TLEEstimationTestUtils;
import org.orekit.estimation.measurements.EstimatedMeasurement;
import org.orekit.estimation.measurements.ObservedMeasurement;
import org.orekit.estimation.measurements.PVMeasurementCreator;
import org.orekit.orbits.Orbit;
import org.orekit.propagation.Propagator;
import org.orekit.propagation.analytical.tle.TLEPropagator;
import org.orekit.propagation.conversion.TLEPropagatorBuilder;
import org.orekit.utils.ParameterDriver;
import org.orekit.utils.ParameterDriversList;
public class AnalyticalBatchLSModelTest {
@Test
public void testPerfectValue() {
final TLEContext context = TLEEstimationTestUtils.eccentricContext("regular-data:potential:tides");
final TLEPropagatorBuilder propagatorBuilder =
context.createBuilder(1.0e-6, 60.0, 0.001);
final TLEPropagatorBuilder[] builders = { propagatorBuilder };
// create perfect PV measurements
final Propagator propagator = TLEEstimationTestUtils.createPropagator(TLEPropagator.selectExtrapolator(context.initialTLE).getInitialState().getOrbit(),
propagatorBuilder);
final List<ObservedMeasurement<?>> measurements =
TLEEstimationTestUtils.createMeasurements(propagator,
new PVMeasurementCreator(),
0.0, 1.0, 300.0);
final ParameterDriversList estimatedMeasurementsParameters = new ParameterDriversList();
for (ObservedMeasurement<?> measurement : measurements) {
for (final ParameterDriver driver : measurement.getParametersDrivers()) {
if (driver.isSelected()) {
estimatedMeasurementsParameters.add(driver);
}
}
}
// create model
final ModelObserver modelObserver = new ModelObserver() {
/** {@inheritDoc} */
@Override
public void modelCalled(final Orbit[] newOrbits,
final Map<ObservedMeasurement<?>, EstimatedMeasurement<?>> newEvaluations) {
Orbit initialOrbit = TLEPropagator.selectExtrapolator(context.initialTLE).getInitialState().getOrbit();
Assert.assertEquals(1, newOrbits.length);
Assert.assertEquals(0,
context.initialTLE.getDate().durationFrom(newOrbits[0].getDate()),
Double.MIN_VALUE);
Assert.assertEquals(0,
Vector3D.distance(initialOrbit.getPVCoordinates().getPosition(),
newOrbits[0].getPVCoordinates().getPosition()),
4.97e-6);
Assert.assertEquals(measurements.size(), newEvaluations.size());
}
};
final AnalyticalBatchLSModel model = new AnalyticalBatchLSModel(builders, measurements, estimatedMeasurementsParameters, modelObserver);
model.setIterationsCounter(new Incrementor(100));
model.setEvaluationsCounter(new Incrementor(100));
// Test forward propagation flag to true
assertEquals(true, model.isForwardPropagation());
// evaluate model on perfect start point
final double[] normalizedProp = propagatorBuilder.getSelectedNormalizedParameters();
final double[] normalized = new double[normalizedProp.length + estimatedMeasurementsParameters.getNbParams()];
System.arraycopy(normalizedProp, 0, normalized, 0, normalizedProp.length);
int i = normalizedProp.length;
for (final ParameterDriver driver : estimatedMeasurementsParameters.getDrivers()) {
normalized[i++] = driver.getNormalizedValue();
}
Pair<RealVector, RealMatrix> value = model.value(new ArrayRealVector(normalized));
int index = 0;
for (ObservedMeasurement<?> measurement : measurements) {
for (int k = 0; k < measurement.getDimension(); ++k) {
// the value is already a weighted residual
Assert.assertEquals(0.0, value.getFirst().getEntry(index++), 4.75e-5);
}
}
Assert.assertEquals(index, value.getFirst().getDimension());
}
@Test
public void testBackwardPropagation() {
final TLEContext context = TLEEstimationTestUtils.eccentricContext("regular-data:potential:tides");
final TLEPropagatorBuilder propagatorBuilder =
context.createBuilder(1.0e-6, 60.0, 0.001);
final TLEPropagatorBuilder[] builders = { propagatorBuilder };
// create perfect PV measurements
final Propagator propagator = TLEEstimationTestUtils.createPropagator(TLEPropagator.selectExtrapolator(context.initialTLE).getInitialState().getOrbit(),
propagatorBuilder);
final List<ObservedMeasurement<?>> measurements =
TLEEstimationTestUtils.createMeasurements(propagator,
new PVMeasurementCreator(),
0.0, -1.0, 300.0);
final ParameterDriversList estimatedMeasurementsParameters = new ParameterDriversList();
for (ObservedMeasurement<?> measurement : measurements) {
for (final ParameterDriver driver : measurement.getParametersDrivers()) {
if (driver.isSelected()) {
estimatedMeasurementsParameters.add(driver);
}
}
}
// create model
final ModelObserver modelObserver = new ModelObserver() {
/** {@inheritDoc} */
@Override
public void modelCalled(final Orbit[] newOrbits,
final Map<ObservedMeasurement<?>, EstimatedMeasurement<?>> newEvaluations) {
// Do nothing here
}
};
final AnalyticalBatchLSModel model = new AnalyticalBatchLSModel(builders, measurements, estimatedMeasurementsParameters, modelObserver);
// Test forward propagation flag to false
assertEquals(false, model.isForwardPropagation());
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment