MultipleShooter.java

  1. /* Copyright 2002-2022 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.utils;

  18. import java.util.List;
  19. import java.util.Map;
  20. import java.util.stream.Collectors;

  21. import org.orekit.propagation.SpacecraftState;
  22. import org.orekit.propagation.numerical.EpochDerivativesEquations;
  23. import org.orekit.propagation.numerical.NumericalPropagator;

  24. /**
  25.  * Multiple shooting method applicable for trajectories, in an ephemeris model.
  26.  * Not suited for closed orbits.
  27.  * @see "TRAJECTORY DESIGN AND ORBIT MAINTENANCE STRATEGIES IN MULTI-BODY DYNAMICAL REGIMES by Thomas A. Pavlak, Purdue University"
  28.  * @author William Desprats
  29.  * @since 10.2
  30.  */
  31. public class MultipleShooter extends AbstractMultipleShooting {

  32.     /** Name of the additional derivatives. */
  33.     private static final String DERIVATIVES = "derivatives";

  34.     /** Derivatives linked to the Propagators.
  35.      * @since 11.1
  36.      */
  37.     private final List<EpochDerivativesEquations> epochEquations;

  38.     /** Simple Constructor.
  39.      * <p> Standard constructor for multiple shooting which can be used with the CR3BP model.</p>
  40.      * @param initialGuessList initial patch points to be corrected.
  41.      * @param propagatorList list of propagators associated to each patch point.
  42.      * @param additionalEquations list of additional equations linked to propagatorList.
  43.      * @param arcDuration initial guess of the duration of each arc.
  44.      * @param tolerance convergence tolerance on the constraint vector
  45.      * @deprecated as of 11.1, replaced by {@link #MultipleShooter(List, List, List, double, double, int)}
  46.      */
  47.     @Deprecated
  48.     public MultipleShooter(final List<SpacecraftState> initialGuessList, final List<NumericalPropagator> propagatorList,
  49.                            final List<org.orekit.propagation.integration.AdditionalEquations> additionalEquations,
  50.                            final double arcDuration, final double tolerance) {
  51.         super(initialGuessList, propagatorList, additionalEquations, arcDuration, tolerance, DERIVATIVES);
  52.         epochEquations = additionalEquations.stream().map(ae -> (EpochDerivativesEquations) ae).collect(Collectors.toList());
  53.     }

  54.     /** Simple Constructor.
  55.      * <p> Standard constructor for multiple shooting which can be used with the CR3BP model.</p>
  56.      * @param initialGuessList initial patch points to be corrected.
  57.      * @param propagatorList list of propagators associated to each patch point.
  58.      * @param epochEquations list of additional derivatives providers linked to propagatorList.
  59.      * @param arcDuration initial guess of the duration of each arc.
  60.      * @param tolerance convergence tolerance on the constraint vector
  61.      * @param maxIter maximum number of iterations
  62.      */
  63.     public MultipleShooter(final List<SpacecraftState> initialGuessList, final List<NumericalPropagator> propagatorList,
  64.                            final List<EpochDerivativesEquations> epochEquations, final double arcDuration,
  65.                            final double tolerance, final int maxIter) {
  66.         super(initialGuessList, propagatorList, arcDuration, tolerance, maxIter, DERIVATIVES);
  67.         this.epochEquations = epochEquations;
  68.     }

  69.     /** {@inheritDoc} */
  70.     protected SpacecraftState getAugmentedInitialState(final int i) {
  71.         return epochEquations.get(i).setInitialJacobians(getPatchPoint(i));
  72.     }

  73.     /** {@inheritDoc} */
  74.     protected double[][] computeAdditionalJacobianMatrix(final List<SpacecraftState> propagatedSP) {
  75.         final Map<Integer, Double> mapConstraints = getConstraintsMap();

  76.         final int n = mapConstraints.size();
  77.         final int ncolumns = getNumberOfFreeVariables() - 1;

  78.         final double[][] M = new double[n][ncolumns];

  79.         int k = 0;
  80.         for (int index : mapConstraints.keySet()) {
  81.             M[k][index] = 1;
  82.             k++;
  83.         }
  84.         return M;
  85.     }

  86.     /** {@inheritDoc} */
  87.     protected double[] computeAdditionalConstraints(final List<SpacecraftState> propagatedSP) {
  88.         // The additional constraint vector has the following form :

  89.         //           [ y1i - y1d ]---- other constraints (component of
  90.         // Fadd(X) = [    ...    ]    | a patch point equals to a
  91.         //           [vz2i - vz2d]----  desired value)

  92.         // Number of additional constraints
  93.         final int      n             = getConstraintsMap().size();
  94.         final double[] fxAdditionnal = new double[n];

  95.         // Update additional constraints
  96.         updateAdditionalConstraints(0, fxAdditionnal);
  97.         return fxAdditionnal;
  98.     }

  99. }