Commit bcc5074c authored by Luc Maisonobe's avatar Luc Maisonobe
Browse files

Short-circuit matrices computation if orbits are not estimated.

parent 992ce1d1
Pipeline #1548 passed with stages
in 26 minutes and 29 seconds
......@@ -62,6 +62,11 @@ public abstract class AbstractBatchLSModel implements MultivariateJacobianFuncti
/** Builders for propagators. */
private final OrbitDeterminationPropagatorBuilder[] builders;
/** Array of each builder's selected orbit drivers.
* @since 11.1
*/
private final ParameterDriversList[] estimatedOrbitalParameters;
/** Array of each builder's selected propagation drivers. */
private final ParameterDriversList[] estimatedPropagationParameters;
......@@ -150,6 +155,7 @@ public abstract class AbstractBatchLSModel implements MultivariateJacobianFuncti
this.measurements = measurements;
this.estimatedMeasurementsParameters = estimatedMeasurementsParameters;
this.measurementParameterColumns = new HashMap<>(estimatedMeasurementsParameters.getDrivers().size());
this.estimatedOrbitalParameters = new ParameterDriversList[builders.length];
this.estimatedPropagationParameters = new ParameterDriversList[builders.length];
this.evaluations = new IdentityHashMap<>(measurements.size());
this.observer = observer;
......@@ -311,6 +317,32 @@ public abstract class AbstractBatchLSModel implements MultivariateJacobianFuncti
}
/** Get the selected orbital drivers for a propagatorBuilder.
* @param iBuilder index of the builder in the builders' array
* @return the list of selected orbital drivers for propagatorBuilder of index iBuilder
* @since 11.1
*/
public ParameterDriversList getSelectedOrbitalParametersDriversForBuilder(final int iBuilder) {
// Lazy evaluation, create the list only if it hasn't been created yet
if (estimatedOrbitalParameters[iBuilder] == null) {
// Gather the drivers
final ParameterDriversList selectedOrbitalDrivers = new ParameterDriversList();
for (final DelegatingDriver delegating : builders[iBuilder].getOrbitalParametersDrivers().getDrivers()) {
if (delegating.isSelected()) {
for (final ParameterDriver driver : delegating.getRawDrivers()) {
selectedOrbitalDrivers.add(driver);
}
}
}
// Add the list of selected orbital parameters drivers to the array
estimatedOrbitalParameters[iBuilder] = selectedOrbitalDrivers;
}
return estimatedOrbitalParameters[iBuilder];
}
/** Get the selected propagation drivers for a propagatorBuilder.
* @param iBuilder index of the builder in the builders' array
* @return the list of selected propagation drivers for propagatorBuilder of index iBuilder
......@@ -419,13 +451,15 @@ public abstract class AbstractBatchLSModel implements MultivariateJacobianFuncti
final RealMatrix dMdY = dMdC.multiply(dCdY);
// Jacobian of the measurement with respect to initial orbital state
final RealMatrix dYdY0 = harvesters[p].getStateTransitionMatrix(evaluationStates[k]);
final RealMatrix dMdY0 = dMdY.multiply(dYdY0);
for (int i = 0; i < dMdY0.getRowDimension(); ++i) {
int jOrb = orbitsStartColumns[p];
for (int j = 0; j < dMdY0.getColumnDimension(); ++j) {
final ParameterDriver driver = builders[p].getOrbitalParametersDrivers().getDrivers().get(j);
if (driver.isSelected()) {
final ParameterDriversList selectedOrbitalDrivers = getSelectedOrbitalParametersDriversForBuilder(p);
final int nbOrbParams = selectedOrbitalDrivers.getNbParams();
if (nbOrbParams > 0) {
final RealMatrix dYdY0 = harvesters[p].getStateTransitionMatrix(evaluationStates[k]);
final RealMatrix dMdY0 = dMdY.multiply(dYdY0);
for (int i = 0; i < dMdY0.getRowDimension(); ++i) {
int jOrb = orbitsStartColumns[p];
for (int j = 0; j < dMdY0.getColumnDimension(); ++j) {
final ParameterDriver driver = selectedOrbitalDrivers.getDrivers().get(j);
jacobian.setEntry(index + i, jOrb++,
weight[i] * dMdY0.getEntry(i, j) / sigma[i] * driver.getScale());
}
......
......@@ -69,6 +69,11 @@ public abstract class AbstractKalmanModel implements KalmanEstimation, NonLinear
/** Estimated propagation drivers. */
private final ParameterDriversList allEstimatedPropagationParameters;
/** Per-builder estimated orbita parameters drivers.
* @since 11.1
*/
private final ParameterDriversList[] estimatedOrbitalParameters;
/** Per-builder estimated propagation drivers. */
private final ParameterDriversList[] estimatedPropagationParameters;
......@@ -186,7 +191,9 @@ public abstract class AbstractKalmanModel implements KalmanEstimation, NonLinear
orbitsEndColumns = new int[builders.size()];
int columns = 0;
allEstimatedOrbitalParameters = new ParameterDriversList();
estimatedOrbitalParameters = new ParameterDriversList[builders.size()];
for (int k = 0; k < builders.size(); ++k) {
estimatedOrbitalParameters[k] = new ParameterDriversList();
orbitsStartColumns[k] = columns;
final String suffix = propagatorBuilders.size() > 1 ? "[" + k + "]" : null;
for (final ParameterDriver driver : builders.get(k).getOrbitalParametersDrivers().getDrivers()) {
......@@ -200,6 +207,7 @@ public abstract class AbstractKalmanModel implements KalmanEstimation, NonLinear
}
if (driver.isSelected()) {
allEstimatedOrbitalParameters.add(driver);
estimatedOrbitalParameters[k].add(driver);
orbitalParameterColumns.put(driver.getName(), columns++);
}
}
......@@ -698,17 +706,14 @@ public abstract class AbstractKalmanModel implements KalmanEstimation, NonLinear
harvesters[k].setReferenceState(predictedSpacecraftStates[k]);
// Derivatives of the state vector with respect to initial state vector
final RealMatrix dYdY0 = harvesters[k].getStateTransitionMatrix(predictedSpacecraftStates[k]);
// Fill upper left corner (dY/dY0)
final List<ParameterDriversList.DelegatingDriver> drivers =
builders.get(k).getOrbitalParametersDrivers().getDrivers();
for (int i = 0; i < dYdY0.getRowDimension(); ++i) {
if (drivers.get(i).isSelected()) {
for (int j = 0; j < dYdY0.getColumnDimension(); ++j) {
if (drivers.get(j).isSelected()) {
stm.setEntry(indK[i], indK[j], dYdY0.getEntry(i, j));
}
final int nbOrbParams = estimatedOrbitalParameters[k].getNbParams();
if (nbOrbParams > 0) {
final RealMatrix dYdY0 = harvesters[k].getStateTransitionMatrix(predictedSpacecraftStates[k]);
// Fill upper left corner (dY/dY0)
for (int i = 0; i < dYdY0.getRowDimension(); ++i) {
for (int j = 0; j < nbOrbParams; ++j) {
stm.setEntry(indK[i], indK[j], dYdY0.getEntry(i, j));
}
}
}
......
Supports Markdown
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