1   /* Copyright 2002-2021 CS GROUP
2    * Licensed to CS GROUP (CS) under one or more
3    * contributor license agreements.  See the NOTICE file distributed with
4    * this work for additional information regarding copyright ownership.
5    * CS licenses this file to You under the Apache License, Version 2.0
6    * (the "License"); you may not use this file except in compliance with
7    * the License.  You may obtain a copy of the License at
8    *
9    *   http://www.apache.org/licenses/LICENSE-2.0
10   *
11   * Unless required by applicable law or agreed to in writing, software
12   * distributed under the License is distributed on an "AS IS" BASIS,
13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14   * See the License for the specific language governing permissions and
15   * limitations under the License.
16   */
17  package org.orekit.estimation.leastsquares;
18  
19  import java.util.List;
20  
21  import org.orekit.estimation.measurements.ObservedMeasurement;
22  import org.orekit.orbits.Orbit;
23  import org.orekit.propagation.Propagator;
24  import org.orekit.propagation.SpacecraftState;
25  import org.orekit.propagation.conversion.OrbitDeterminationPropagatorBuilder;
26  import org.orekit.propagation.integration.AbstractJacobiansMapper;
27  import org.orekit.propagation.numerical.JacobiansMapper;
28  import org.orekit.propagation.numerical.NumericalPropagator;
29  import org.orekit.propagation.numerical.PartialDerivativesEquations;
30  import org.orekit.utils.ParameterDriversList;
31  
32  /** Bridge between {@link ObservedMeasurement measurements} and {@link
33   * org.hipparchus.optim.nonlinear.vector.leastsquares.LeastSquaresProblem
34   * least squares problems}.
35   * @author Luc Maisonobe
36   * @since 8.0
37   */
38  public class BatchLSModel extends AbstractBatchLSModel {
39  
40      /** Simple constructor.
41       * @param propagatorBuilders builders to use for propagation
42       * @param measurements measurements
43       * @param estimatedMeasurementsParameters estimated measurements parameters
44       * @param observer observer to be notified at model calls
45       */
46      public BatchLSModel(final OrbitDeterminationPropagatorBuilder[] propagatorBuilders,
47                          final List<ObservedMeasurement<?>> measurements,
48                          final ParameterDriversList estimatedMeasurementsParameters,
49                          final ModelObserver observer) {
50          // call super constructor
51          super(propagatorBuilders, measurements, estimatedMeasurementsParameters,
52                new JacobiansMapper[propagatorBuilders.length], observer);
53      }
54  
55      /** {@inheritDoc} */
56      @Override
57      protected JacobiansMapper configureDerivatives(final Propagator propagator) {
58  
59          final String equationName = BatchLSModel.class.getName() + "-derivatives";
60  
61          final PartialDerivativesEquations partials = new PartialDerivativesEquations(equationName, (NumericalPropagator) propagator);
62  
63          // add the derivatives to the initial state
64          final SpacecraftState rawState = propagator.getInitialState();
65          final SpacecraftState stateWithDerivatives = partials.setInitialJacobians(rawState);
66          propagator.resetInitialState(stateWithDerivatives);
67  
68          return partials.getMapper();
69  
70      }
71  
72      /** {@inheritDoc} */
73      @Override
74      protected Orbit configureOrbits(final AbstractJacobiansMapper mapper,
75                                      final Propagator propagator) {
76          // Directly return the propagator's initial state
77          return propagator.getInitialState().getOrbit();
78      }
79  
80  }