PenalizedCartesianFuelCost.java

  1. /* Copyright 2022-2025 Romain Serra
  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.control.indirect.adjoint.cost;

  18. import org.hipparchus.geometry.euclidean.threed.Vector3D;
  19. import org.orekit.errors.OrekitException;
  20. import org.orekit.errors.OrekitMessages;

  21. /**
  22.  * Abstract class for fuel cost with a penalty term proportional to a weight parameter epsilon.
  23.  * This is typically used in a continuation method, starting from epsilon equal to 1
  24.  * and going towards 0 where the fuel cost is recovered. The point is to enhance convergence.
  25.  * The control vector is the normalized (by the upper bound on magnitude) thrust force in propagation frame.
  26.  * See the following reference:
  27.  * BERTRAND, Régis et EPENOY, Richard. New smoothing techniques for solving bang–bang optimal control problems—numerical results and statistical interpretation.
  28.  * Optimal Control Applications and Methods, 2002, vol. 23, no 4, p. 171-197.
  29.  *
  30.  * @author Romain Serra
  31.  * @since 13.0
  32.  * @see CartesianFuelCost
  33.  */
  34. public abstract class PenalizedCartesianFuelCost extends AbstractCartesianCost {

  35.     /** Maximum value of thrust force Euclidean norm. */
  36.     private final double maximumThrustMagnitude;

  37.     /** Penalty weight. */
  38.     private final double epsilon;

  39.     /**
  40.      * Constructor.
  41.      *
  42.      * @param name               adjoint name
  43.      * @param massFlowRateFactor mass flow rate factor
  44.      * @param maximumThrustMagnitude maximum thrust magnitude
  45.      * @param epsilon penalty weight
  46.      */
  47.     protected PenalizedCartesianFuelCost(final String name, final double massFlowRateFactor,
  48.                                          final double maximumThrustMagnitude, final double epsilon) {
  49.         super(name, massFlowRateFactor);
  50.         if (epsilon < 0 || epsilon > 1) {
  51.             throw new OrekitException(OrekitMessages.INVALID_PARAMETER_RANGE, "epsilon", epsilon, 0, 1);
  52.         }
  53.         this.maximumThrustMagnitude = maximumThrustMagnitude;
  54.         this.epsilon = epsilon;
  55.     }

  56.     /** Getter for the penalty weight epsilon.
  57.      * @return epsilon
  58.      */
  59.     public double getEpsilon() {
  60.         return epsilon;
  61.     }

  62.     /** Getter for maximum thrust magnitude.
  63.      * @return maximum thrust
  64.      */
  65.     public double getMaximumThrustMagnitude() {
  66.         return maximumThrustMagnitude;
  67.     }

  68.     /**
  69.      * Evaluate the penalty term (without the weight), assumed to be a function of the control norm.
  70.      * @param controlNorm Euclidean norm of control vector
  71.      * @return penalty function
  72.      */
  73.     public abstract double evaluatePenaltyFunction(double controlNorm);

  74.     /**
  75.      * Computes the direction of thrust.
  76.      * @param adjointVariables adjoint vector
  77.      * @return thrust direction
  78.      */
  79.     protected Vector3D getThrustDirection(final double[] adjointVariables) {
  80.         return new Vector3D(adjointVariables[3], adjointVariables[4], adjointVariables[5]).normalize();
  81.     }

  82.     /** {@inheritDoc} */
  83.     @Override
  84.     public double getHamiltonianContribution(final double[] adjointVariables, final double mass) {
  85.         final Vector3D thrustForce = getThrustAccelerationVector(adjointVariables, mass).scalarMultiply(mass);
  86.         final double controlNorm = thrustForce.getNorm() / getMaximumThrustMagnitude();
  87.         return -(controlNorm + getEpsilon() * evaluatePenaltyFunction(controlNorm)) * getMaximumThrustMagnitude();
  88.     }

  89. }