General Question Optimizing trajectories with NASA's General Mission Analysis Tool: how to understand the Vary parameters, and how to know what values to use for them?

pantanplan

New member
Joined
Feb 10, 2022
Messages
2
Reaction score
0
Points
1
Location
Kanar
I've been using GMAT to optimize trajectories, and so far for simple trajectories I've had success. The vary command in GMAT's optimization sequence has the following parameters that can be changed:
  • Initial value: The initial guess. I know the gradient descent optimization method that GMAT uses is very sensitive to initial conditions and so this must be feasible or reasonably close to the final optimal value.
  • Perturbation: The step size used to calculate the finite difference derivative.
  • Max step: The maximum allowed change in the control variable during a single iteration of the solver.
  • Additive scale factor: Number used to nondimensionalize the independent variable. This is done with the equation xn = m (xd + a), where xn is the non-dimensional parameter, xd is the dimensional parameter and this parameter is a.
  • Multiplicative scale factor: Same as above, but it's the variable d in the equation.
For the initial value, I can usually see when my chosen value is feasible by observing the solver window or a graphical display of the orbit in different iterations. The max step is the most intuitive of these parameters for me, and by trial and error, observation of the solver window and how sensitive my target variables are to changes in the control variables I can usually get it right and get convergence. It is still partially trial and error though and sometimes this method doesn't work.

The other parameters I can't find much info about online, I don't understand how they affect the optimization and what they should be to achieve convergence, and I have now reached a point where I have to because I'm working on a more complex, sensitive multiple shooting-optimized script.

So my question is: how to understand the optimization parameters of GMAT and what they should be in different situations? Is there a procedure or automatic method that takes into account the scale of the optimization problem and its sensitivity, and gives an estimation of what the optimization parameters should be?

And as a secondary question: what should they be when I want GMAT to consider a wide array of possible trajectories with different values of control variables, especially when those control variables are epochs or time intervals? E.g., if I want to go from Earth to Mars, is there a way to get GMAT to propagate the spacecraft from the starting to the final destination across a large range of departure and arrival epochs, and find the lowest-delta v one, without me providing any a priori information (kind of like a more customizable patched conics approximation)?
 

Ajaja

Active member
Joined
Apr 20, 2008
Messages
225
Reaction score
93
Points
28
My understanding is that if you vary two different parameters, for example delta-v between 2000 m/s and 3000 m/s and time between 10 s and 20 s using "Additive scale factor" and "Multiplicative scale factor" you can manually normalize both variables for the solver to vary them internally, for example, between -1..1 both.
Personally, I use only "Multiplicative scale factor" to make variables roughly the same order.
 

Ajaja

Active member
Joined
Apr 20, 2008
Messages
225
Reaction score
93
Points
28
And as a secondary question: what should they be when I want GMAT to consider a wide array of possible trajectories with different values of control variables, especially when those control variables are epochs or time intervals? E.g., if I want to go from Earth to Mars, is there a way to get GMAT to propagate the spacecraft from the starting to the final destination across a large range of departure and arrival epochs, and find the lowest-delta v one, without me providing any a priori information (kind of like a more customizable patched conics approximation)?
BTW, You can combine patched conics approximation with more precise GMAT propagator.
For example, part of some my old script:
Code:
Optimize 'Optimize dV' Yukon {SolveMode = Solve, ExitMode = SaveAndContinue, ShowProgressWindow = true};
   Vary 'Vary' Yukon(dT = 5000.003207506064, {Perturbation = 0.001, MaxStep = 9.999999e300, AdditiveScaleFactor = 0.0, MultiplicativeScaleFactor = 1.0});
  
   Propagate 'Propagate Sat2' EarthPropagator(sat2) {sat2.ElapsedSecs = dT};
  
   BeginScript 'Lambert Solver'
      GMAT state1(1) = sat1.EarthMJ2000Eq.X;
      GMAT state1(2) = sat1.EarthMJ2000Eq.Y;
      GMAT state1(3) = sat1.EarthMJ2000Eq.Z;
      GMAT state2(1) = sat2.EarthMJ2000Eq.X;
      GMAT state2(2) = sat2.EarthMJ2000Eq.Y;
      GMAT state2(3) = sat2.EarthMJ2000Eq.Z;
      GMAT [vel1, vel2] = Python.PyKEP.lambert_v1(state1, state2, dT, mu);
     
      GMAT IB.Element1 = vel1(1)-sat1.EarthMJ2000Eq.VX;
      GMAT IB.Element2 = vel1(2)-sat1.EarthMJ2000Eq.VY;
      GMAT IB.Element3 = vel1(3)-sat1.EarthMJ2000Eq.VZ;
     
      GMAT dV1 = IB.Element1^2+IB.Element2^2+IB.Element3^2;
      GMAT dV2 = (vel2(1)-sat2.EarthMJ2000Eq.VX)^2+(vel2(2)-sat2.EarthMJ2000Eq.VY)^2+(vel2(3)-sat2.EarthMJ2000Eq.VZ)^2;
      GMAT dV = sqrt(dV1)+sqrt(dV2);
   EndScript;
  
   Maneuver 'Maneuver 1' IB(sat1);
   NonlinearConstraint 'NonlinearConstraint' Yukon(sat1.Earth.RadPer>=6480);
  
   Minimize 'Minimize dV' Yukon(dV);
EndOptimize;  % For optimizer Yukon


lambert_v1 is a user function (in /userfunctions/python/PyKEP.py):
Python:
import math
import pykep as pkp

def lambert_v1(r1, r2, t, mu):
   l = pkp.lambert_problem(r1,r2, t, mu)
   v1 = [0.0,0.0,0.0]
   v1[0] = l.get_v1()[0][0]
   v1[1] = l.get_v1()[0][1]
   v1[2] = l.get_v1()[0][2]

   v2 = [0.0,0.0,0.0]
   v2[0] = l.get_v2()[0][0]
   v2[1] = l.get_v2()[0][1]
   v2[2] = l.get_v2()[0][2]

   return v1, v2
 
Top