Estimate only a selection of orbital parameters with the BatchLeastSquareEstimator
Hello! Here is the issue linked to the following discussion on the forum.
Lately, we have been encountering this error when trying to estimate only a selection of orbital parameters with the BatchLeastSquareEstimator :
java.lang.IndexOutOfBoundsException: Index: 1, Size: 1
at java.util.ArrayList.rangeCheck(ArrayList.java:657)
at java.util.ArrayList.get(ArrayList.java:433)
at java.util.Collections$UnmodifiableList.get(Collections.java:1309)
at org.orekit.estimation.leastsquares.AbstractBatchLSModel.fetchEvaluatedMeasurement(AbstractBatchLSModel.java:462)
at org.orekit.estimation.leastsquares.MeasurementHandler.handleStep(MeasurementHandler.java:94)
at org.orekit.propagation.PropagatorsParallelizer$SinglePropagatorHandler.handleStep(PropagatorsParallelizer.java:276)
at org.orekit.propagation.integration.AbstractIntegratedPropagator$AdaptedStepHandler.handleStep(AbstractIntegratedPropagator.java:958)
It happens when estimating only the semi-major axis for example. Here is the test that is inspired from the BatchLSEstimatorTest to reproduce this issue:
public void testEstimateOnlyOneOrbitalParameter() {
Context context = EstimationTestUtils.eccentricContext("regular-data:potential:tides");
final NumericalPropagatorBuilder propagatorBuilder =
context.createBuilder(OrbitType.KEPLERIAN, PositionAngle.TRUE, true,
1.0e-6, 60.0, 1.0);
// create perfect PV measurements
final Propagator propagator = EstimationTestUtils.createPropagator(context.initialOrbit,
propagatorBuilder);
final List<ObservedMeasurement<?>> measurements =
EstimationTestUtils.createMeasurements(propagator,
new PVMeasurementCreator(),
0.0, 1.0, 300.0);
// select only the first orbital parameter
boolean[] orbitalParametersEstimated = new boolean[]{true, false, false, false, false, false};
List<ParameterDriversList.DelegatingDriver> orbitalElementsDrivers = propagatorBuilder.getOrbitalParametersDrivers().getDrivers();
IntStream.range(0, orbitalParametersEstimated.length).forEach(i -> orbitalElementsDrivers.get(i).setSelected(orbitalParametersEstimated[i]));
//create the estimator
final BatchLSEstimator estimator = new BatchLSEstimator(new LevenbergMarquardtOptimizer(),
propagatorBuilder);
for (final ObservedMeasurement<?> measurement : measurements) {
estimator.addMeasurement(measurement);
}
estimator.setParametersConvergenceThreshold(1.0e-2);
estimator.setMaxIterations(10);
estimator.setMaxEvaluations(20);
estimator.estimate();
I was wondering if it comes not from line 462 of the class AbstractBatchLSModel class (fetchEvaluatedMeasurement method) :
for (int j = 0; j < dMdY0.getColumnDimension(); ++j) {
final ParameterDriver driver = selectedOrbitalDrivers.getDrivers().get(j);
(...)
}
dMdY0.getColumnDimension() seems to be always equals to 6, which is not necessarily the case of the number of selected orbital drivers.
Thank you very much for your help,
Have a good day!