# Trajectory Optimization Example

This topic presents a complete code example using Segment Propagation Library to optimize a three maneuver sequence that both circularizes a geosynchronous transfer orbit (GTO) into a geostationary Earth orbit (GEO) and reduces its inclination from 57 degrees to 0 degrees.

Each of these maneuvers occurs at the apogee of the original GTO or the two intermediate orbits after the first two maneuvers. The third maneuver both completes the circularization and reduces the inclination to zero degrees. The optimizer varies the inclinations and perigees of the two intermediate orbits in order to minimize the required propellant usage for the three maneuver sequence. Each maneuver has a nested differential corrector that solves for the maneuver required to produce the intermediate orbits or final orbit from the previous satellite state.

Note

The functionality described in this topic requires a license for the Segment Propagation Library.

Building the Trajectory Optimizer

The setup for the trajectory optimizer is in the following code sample:

Java
```final String motionID = "Satellite";
final String fuelMassName = "Fuel_Mass";
final String dryMassName = "Dry_Mass";
double earthGravitationalParameter = WorldGeodeticSystem1984.GravitationalParameter;
EarthCentralBody earth = CentralBodiesFacet.getFromContext().getEarth();

// Initial state has periapsis 300 km above Earth's surface and apoapsis at approximately GEO radius.
final double initialRadiusPeriapsis = 6678000.0; // meters.
double initialRadiusApoapsis = Math.pow(earthGravitationalParameter * Math.pow(TimeConstants.SecondsPerDay / Constants.TwoPi, 2.0), 1.0 / 3.0); // meters.
Motion1<Cartesian> initialState = new ModifiedKeplerianElements(initialRadiusPeriapsis, 1.0 / initialSemimajorAxis, initialInclination, 0.0, 0.0, 0.0, earthGravitationalParameter)
.toCartesian();

// Specific impulse for impulsive maneuvers.
final double isp = 300.0; // seconds
double exhaustVelocity = isp * Constants.EarthSurfaceGravity;

// Fuel mass.
PropagationScalar fuelMass = new PropagationScalar(1000.0);
fuelMass.setIdentification(fuelMassName);
fuelMass.setScalarDerivative(new ScalarFixed(0.0));

// Dry mass.
PropagationScalar dryMass = new PropagationScalar(500.0);
dryMass.setIdentification(dryMassName);
dryMass.setScalarDerivative(new ScalarFixed(0.0));

// Create the integrator.
RungeKuttaVerner89Integrator integrator = new RungeKuttaVerner89Integrator();
integrator.setInitialStepSize(60.0);

// The propagation point and propagator.
PropagationNewtonianPoint propagationPoint = new PropagationNewtonianPoint(motionID, earth.getInertialFrame(), initialState.getValue(), initialState.getFirstDerivative());
TwoBodyGravity earthGravity = new TwoBodyGravity(propagationPoint.getIntegrationPoint(), earth, earthGravitationalParameter);

NumericalPropagatorDefinition numericalPropagator = new NumericalPropagatorDefinition();
numericalPropagator.setIntegrator(integrator);
numericalPropagator.setEpoch(epoch);

// Define initial state segment.
NumericalInitialStateSegment initialStateSegment = new NumericalInitialStateSegment();
initialStateSegment.setName("Initial_State_Segment");
initialStateSegment.setPropagatorDefinition(numericalPropagator);

// Define coasting segment that stops at first apogee.
NumericalPropagatorSegment coastToManeuver1 = new NumericalPropagatorSegment();
coastToManeuver1.setName("Coast_To_Maneuver1_Start");
coastToManeuver1.setPropagatorDefinition(numericalPropagator);

final double apogeeTrueAnomaly = Math.PI;
ScalarStoppingCondition apogee1StoppingCondition = new ScalarStoppingCondition();
apogee1StoppingCondition.setThreshold(ValueDefinition.<Double> toValueDefinition((double) apogeeTrueAnomaly));
apogee1StoppingCondition.setFunctionTolerance(Constants.Epsilon6);
apogee1StoppingCondition.setAngularSetting(CircularRange.ZERO_TO_TWO_PI);
apogee1StoppingCondition.setTypeOfStoppingCondition(StopType.THRESHOLD_INCREASING);

apogee1StoppingCondition
.setScalar(new ScalarModifiedKeplerianElement(earthGravitationalParameter, propagationPoint.getIntegrationPoint(), KeplerianElement.TRUE_ANOMALY, earth.getInertialFrame()));

// Define impulsive maneuver segment for first maneuver.
ImpulsiveManeuverSegment maneuverSegment1 = new ImpulsiveManeuverSegment();
ImpulsiveManeuverInformation maneuver1 = new ImpulsiveManeuverInformation(motionID, Cartesian.getZero(), fuelMassName, dryMassName, Scalar.toScalar(exhaustVelocity),
InvalidFuelStateBehavior.DO_AS_MUCH_AS_POSSIBLE);
maneuver1.setOrientation(new AxesVelocityOrbitNormal(maneuver1.getPropagationPoint(), earth));
maneuverSegment1.setManeuver(maneuver1);

// Set up variable for delta-v in the velocity direction.
DelegateBasedVariable<ImpulsiveManeuverSegmentConfiguration> deltaV1XVariable = maneuverSegment1.createVariable(100.0, 1.0,
SetVariableCallback.of((deltaVx, configuration) -> {
configuration.getManeuver().setX(configuration.getManeuver().getX() + deltaVx);// m/s.
}));

// Set up variable for delta-v in the normal direction.
DelegateBasedVariable<ImpulsiveManeuverSegmentConfiguration> deltaV1YVariable = maneuverSegment1.createVariable(100.0, 1.0,
SetVariableCallback.of((deltaVy, configuration) -> {
configuration.getManeuver().setY(configuration.getManeuver().getY() + deltaVy);// m/s.
}));

// Set up a variable for the post-maneuver radius of perigee.

// Set up a variable for the post-maneuver inclination.
maneuverSegment1);
postManeuver1InclinationVariable.getSettings().setVariableTolerance(Constants.Epsilon1);

// Set up a constraint for the post-maneuver radius of perigee.
DelegateBasedConstraint postManeuver1RadiusPerigeeEquality = new DelegateBasedConstraint(DelegateBasedConstraintCallback.of((results) -> {
Motion1<Cartesian> motion = results.getStateForNextSegment().<Cartesian> getMotion(motionID);
}), maneuverSegment1, Double.NaN, Constants.Epsilon3);

// Set up a constraint for the post-maneuver inclination.
DelegateBasedConstraint postManeuver1InclinationEquality = new DelegateBasedConstraint(DelegateBasedConstraintCallback.of((results) -> {
Motion1<Cartesian> motion = results.getStateForNextSegment().<Cartesian> getMotion(motionID);
return new ModifiedKeplerianElements(motion, WorldGeodeticSystem1984.GravitationalParameter).getInclination();
}), maneuverSegment1, Double.NaN, Constants.Epsilon3);
postManeuver1InclinationEquality.setDesiredValue(postManeuver1InclinationVariable.getValue());

// Define coasting segment that stops at second perigee.
NumericalPropagatorSegment coastToPerigee2 = new NumericalPropagatorSegment();
coastToPerigee2.setName("Coast_To_Perigee2");
coastToPerigee2.setPropagatorDefinition(numericalPropagator);

ScalarStoppingCondition perigee2StoppingCondition = new ScalarStoppingCondition();
perigee2StoppingCondition.setThreshold(ValueDefinition.<Double> toValueDefinition((double) 0.0));
perigee2StoppingCondition.setFunctionTolerance(Constants.Epsilon6);
perigee2StoppingCondition.setAngularSetting(CircularRange.NEGATIVE_PI_TO_PI);
perigee2StoppingCondition.setTypeOfStoppingCondition(StopType.THRESHOLD_INCREASING);
perigee2StoppingCondition
.setScalar(new ScalarModifiedKeplerianElement(earthGravitationalParameter, propagationPoint.getIntegrationPoint(), KeplerianElement.TRUE_ANOMALY, earth.getInertialFrame()));

// Define coasting segment that stops at second apogee.
NumericalPropagatorSegment coastToManeuver2 = new NumericalPropagatorSegment();
coastToManeuver2.setName("Coast_To_Maneuver2_Start");
coastToManeuver2.setPropagatorDefinition(numericalPropagator);

ScalarStoppingCondition apogee2StoppingCondition = new ScalarStoppingCondition();
apogee2StoppingCondition.setThreshold(ValueDefinition.<Double> toValueDefinition((double) apogeeTrueAnomaly));
apogee2StoppingCondition.setFunctionTolerance(Constants.Epsilon6);
apogee2StoppingCondition.setAngularSetting(CircularRange.ZERO_TO_TWO_PI);
apogee2StoppingCondition.setTypeOfStoppingCondition(StopType.THRESHOLD_INCREASING);
apogee2StoppingCondition
.setScalar(new ScalarModifiedKeplerianElement(earthGravitationalParameter, propagationPoint.getIntegrationPoint(), KeplerianElement.TRUE_ANOMALY, earth.getInertialFrame()));

// Define impulsive maneuver segment for second maneuver.
ImpulsiveManeuverSegment maneuverSegment2 = new ImpulsiveManeuverSegment();
ImpulsiveManeuverInformation maneuver2 = new ImpulsiveManeuverInformation(motionID, Cartesian.getZero(), fuelMassName, dryMassName, Scalar.toScalar(exhaustVelocity),
InvalidFuelStateBehavior.DO_AS_MUCH_AS_POSSIBLE);
maneuver2.setOrientation(new AxesVelocityOrbitNormal(maneuver2.getPropagationPoint(), earth));
maneuverSegment2.setManeuver(maneuver2);

// Set up variable for delta-v in the velocity direction.
DelegateBasedVariable<ImpulsiveManeuverSegmentConfiguration> deltaV2XVariable = maneuverSegment2.createVariable(100.0, 1.0,
SetVariableCallback.of((deltaVx, configuration) -> {
configuration.getManeuver().setX(configuration.getManeuver().getX() + deltaVx);// m/s.
}));

// Set up variable for delta-v in the normal direction.
DelegateBasedVariable<ImpulsiveManeuverSegmentConfiguration> deltaV2YVariable = maneuverSegment2.createVariable(100.0, 1.0,
SetVariableCallback.of((deltaVy, configuration) -> {
configuration.getManeuver().setY(configuration.getManeuver().getY() + deltaVy);// m/s.
}));

// Set up a variable for the post-maneuver radius of perigee.

// Set up a variable for the post-maneuver inclination.
maneuverSegment1);
postManeuver2InclinationVariable.getSettings().setVariableTolerance(Constants.Epsilon1);

// Set up a constraint for the post-maneuver radius of perigee.
DelegateBasedConstraint postManeuver2RadiusPerigeeEquality = new DelegateBasedConstraint(DelegateBasedConstraintCallback.of((results) -> {
Motion1<Cartesian> motion = results.getStateForNextSegment().<Cartesian> getMotion(motionID);
}), maneuverSegment2, Double.NaN, Constants.Epsilon6);

// Set up a constraint for the post-maneuver inclination.
DelegateBasedConstraint postManeuver2InclinationEquality = new DelegateBasedConstraint(DelegateBasedConstraintCallback.of((results) -> {
Motion1<Cartesian> motion = results.getStateForNextSegment().<Cartesian> getMotion(motionID);
return new ModifiedKeplerianElements(motion, WorldGeodeticSystem1984.GravitationalParameter).getInclination();
}), maneuverSegment2, Double.NaN, Constants.Epsilon6);
postManeuver2InclinationEquality.setDesiredValue(postManeuver2InclinationVariable.getValue());

// Define coasting segment that stops at second perigee.
NumericalPropagatorSegment coastToPerigee3 = new NumericalPropagatorSegment();
coastToPerigee3.setName("Coast_To_Perigee3");
coastToPerigee3.setPropagatorDefinition(numericalPropagator);

ScalarStoppingCondition perigee3StoppingCondition = new ScalarStoppingCondition();
perigee3StoppingCondition.setThreshold(ValueDefinition.<Double> toValueDefinition((double) 0.0));
perigee3StoppingCondition.setFunctionTolerance(Constants.Epsilon6);
perigee3StoppingCondition.setAngularSetting(CircularRange.NEGATIVE_PI_TO_PI);
perigee3StoppingCondition.setTypeOfStoppingCondition(StopType.THRESHOLD_INCREASING);
perigee3StoppingCondition
.setScalar(new ScalarModifiedKeplerianElement(earthGravitationalParameter, propagationPoint.getIntegrationPoint(), KeplerianElement.TRUE_ANOMALY, earth.getInertialFrame()));

// Define coasting segment that stops at second apogee.
NumericalPropagatorSegment coastToManeuver3 = new NumericalPropagatorSegment();
coastToManeuver3.setName("Coast_To_Maneuver3_Start");
coastToManeuver3.setPropagatorDefinition(numericalPropagator);

ScalarStoppingCondition apogee3StoppingCondition = new ScalarStoppingCondition();
apogee3StoppingCondition.setThreshold(ValueDefinition.<Double> toValueDefinition((double) apogeeTrueAnomaly));
apogee3StoppingCondition.setFunctionTolerance(Constants.Epsilon6);
apogee3StoppingCondition.setAngularSetting(CircularRange.ZERO_TO_TWO_PI);
apogee3StoppingCondition.setTypeOfStoppingCondition(StopType.THRESHOLD_INCREASING);
apogee3StoppingCondition
.setScalar(new ScalarModifiedKeplerianElement(earthGravitationalParameter, propagationPoint.getIntegrationPoint(), KeplerianElement.TRUE_ANOMALY, earth.getInertialFrame()));

// Define impulsive maneuver segment for third and final maneuver.
ImpulsiveManeuverSegment maneuverSegment3 = new ImpulsiveManeuverSegment();
ImpulsiveManeuverInformation maneuver3 = new ImpulsiveManeuverInformation(motionID, Cartesian.getZero(), fuelMassName, dryMassName, Scalar.toScalar(exhaustVelocity),
InvalidFuelStateBehavior.DO_AS_MUCH_AS_POSSIBLE);
maneuver3.setOrientation(new AxesVelocityOrbitNormal(maneuver3.getPropagationPoint(), earth));
maneuverSegment3.setManeuver(maneuver3);

// Set up variable for delta-v in the velocity direction.
DelegateBasedVariable<ImpulsiveManeuverSegmentConfiguration> deltaV3XVariable = maneuverSegment3.createVariable(100.0, 1.0,
SetVariableCallback.of((deltaVx, configuration) -> {
configuration.getManeuver().setX(configuration.getManeuver().getX() + deltaVx);// m/s.
}));

// Set up variable for delta-v in the normal direction.
DelegateBasedVariable<ImpulsiveManeuverSegmentConfiguration> deltaV3YVariable = maneuverSegment3.createVariable(100.0, 1.0,
SetVariableCallback.of((deltaVy, configuration) -> {
configuration.getManeuver().setY(configuration.getManeuver().getY() + deltaVy);// m/s.
}));

// Set up a constraint for the post-maneuver semi-major axis to be the GEO radius.
DelegateBasedConstraint postManeuver3SemimajorAxisEquality = new DelegateBasedConstraint(DelegateBasedConstraintCallback.of((results) -> {
Motion1<Cartesian> motion = results.getStateForNextSegment().<Cartesian> getMotion(motionID);
return 1.0 / new ModifiedKeplerianElements(motion, WorldGeodeticSystem1984.GravitationalParameter).getInverseSemimajorAxis();

// Set up a constraint for the post-maneuver inclination to be zero.
DelegateBasedConstraint postManeuver3InclinationEquality = new DelegateBasedConstraint(DelegateBasedConstraintCallback.of((results) -> {
Motion1<Cartesian> motion = results.getStateForNextSegment().<Cartesian> getMotion(motionID);
return new ModifiedKeplerianElements(motion, WorldGeodeticSystem1984.GravitationalParameter).getInclination();
}), maneuverSegment3, 0.0, Constants.Epsilon5);

// Define coasting segment that stops one day later.
NumericalPropagatorSegment finalGeostationaryOrbit = new NumericalPropagatorSegment();
finalGeostationaryOrbit.setName("Final Geostationary Orbit");
finalGeostationaryOrbit.setPropagatorDefinition(numericalPropagator);

DurationStoppingCondition oneDayStoppingCondition = new DurationStoppingCondition();
oneDayStoppingCondition.setThreshold(ValueDefinition.<Duration> toValueDefinition(Duration.fromDays(1.0)));
oneDayStoppingCondition.setFunctionTolerance(Constants.Epsilon4);

// Build targeted segment list optimizer and nested differential correctors.
TargetedSegmentList outerTargetedSegmentList = new TargetedSegmentList();

TargetedSegmentList maneuver1TargetedSegmentList = new TargetedSegmentList();

TargetedSegmentListDifferentialCorrector maneuver1DifferentialCorrector = new TargetedSegmentListDifferentialCorrector();

ScalarDifferenceOfSegmentCostFunction fuelUsageCostFunction1 = new ScalarDifferenceOfSegmentCostFunction(maneuver1TargetedSegmentList, CostFunctionGoal.MINIMIZE, Constants.Epsilon1,
ScalarConstraintDifference.INITIAL_MINUS_FINAL);
fuelUsageCostFunction1.setScalar(new ParameterizedOnStateScalar(fuelUsageCostFunction1.getParameter(), fuelMassName));

// Set up an inequality constraint that ensures that the radius of perigee increases with the maneuver.
DelegateBasedInequalityConstraint postManeuver1RadiusPerigeeLowerBound = new DelegateBasedInequalityConstraint(DelegateBasedInequalityConstraintCallback.of((results) -> {
Motion1<Cartesian> motion = results.getStateForNextSegment().<Cartesian> getMotion(motionID);

// Set up an inequality constraint that ensures that the inclination decreases with the maneuver.
DelegateBasedInequalityConstraint postManeuver1InclinationUpperBound = new DelegateBasedInequalityConstraint(DelegateBasedInequalityConstraintCallback.of((results) -> {
Motion1<Cartesian> motion = results.getStateForNextSegment().<Cartesian> getMotion(motionID);
return new ModifiedKeplerianElements(motion, WorldGeodeticSystem1984.GravitationalParameter).getInclination();
}), maneuver1TargetedSegmentList, InequalityBoundType.UPPER_BOUND, initialInclination, Constants.Epsilon3);

TargetedSegmentList maneuver2TargetedSegmentList = new TargetedSegmentList();

TargetedSegmentListDifferentialCorrector maneuver2DifferentialCorrector = new TargetedSegmentListDifferentialCorrector();

ScalarDifferenceOfSegmentCostFunction fuelUsageCostFunction2 = new ScalarDifferenceOfSegmentCostFunction(maneuver2TargetedSegmentList, CostFunctionGoal.MINIMIZE, Constants.Epsilon1,
ScalarConstraintDifference.INITIAL_MINUS_FINAL);
fuelUsageCostFunction2.setScalar(new ParameterizedOnStateScalar(fuelUsageCostFunction2.getParameter(), fuelMassName));

// Set up an inequality constraint that ensures that the radius of perigee increases with the maneuver.
DelegateBasedInequalityConstraint postManeuver2RadiusPerigeeLowerBound = new DelegateBasedInequalityConstraint(DelegateBasedInequalityConstraintCallback.of((results) -> {
Motion1<Cartesian> motion = results.getStateForNextSegment().<Cartesian> getMotion(motionID);
}), maneuver2TargetedSegmentList, InequalityBoundType.LOWER_BOUND, Double.NaN, Constants.Epsilon3);

// Set up an inequality constraint that ensures that the radius of perigee does not increase beyond GEO radius.
DelegateBasedInequalityConstraint postManeuver2RadiusPerigeeUpperBound = new DelegateBasedInequalityConstraint(DelegateBasedInequalityConstraintCallback.of((results) -> {
Motion1<Cartesian> motion = results.getStateForNextSegment().<Cartesian> getMotion(motionID);

// Set up an inequality constraint that ensures that the inclination decreases with the maneuver.
DelegateBasedInequalityConstraint postManeuver2InclinationUpperBound = new DelegateBasedInequalityConstraint(DelegateBasedInequalityConstraintCallback.of((results) -> {
Motion1<Cartesian> motion = results.getStateForNextSegment().<Cartesian> getMotion(motionID);
return new ModifiedKeplerianElements(motion, WorldGeodeticSystem1984.GravitationalParameter).getInclination();
}), maneuver2TargetedSegmentList, InequalityBoundType.UPPER_BOUND, Double.NaN, Constants.Epsilon3);

postManeuver2InclinationUpperBound.setBoundValue(postManeuver1InclinationVariable.getValue());

TargetedSegmentList maneuver3TargetedSegmentList = new TargetedSegmentList();

TargetedSegmentListDifferentialCorrector maneuver3DifferentialCorrector = new TargetedSegmentListDifferentialCorrector();

ScalarDifferenceOfSegmentCostFunction fuelUsageCostFunction3 = new ScalarDifferenceOfSegmentCostFunction(maneuver3TargetedSegmentList, CostFunctionGoal.MINIMIZE, Constants.Epsilon1,
ScalarConstraintDifference.INITIAL_MINUS_FINAL);
fuelUsageCostFunction3.setScalar(new ParameterizedOnStateScalar(fuelUsageCostFunction3.getParameter(), fuelMassName));

final ArrayList<SegmentPropagatorCostFunction> costFunctionCollection = new ArrayList<SegmentPropagatorCostFunction>();
CombinedCostFunction fuelUsageCombinedCostFunction = new CombinedCostFunction(CostFunctionGoal.MINIMIZE, Constants.Epsilon3, new NoScalingOnCostFunction(), 1.0, costFunctionCollection);

TargetedSegmentListParameterOptimizer outerOptimizer = new TargetedSegmentListParameterOptimizer();

outerOptimizer.setCostFunction(fuelUsageCombinedCostFunction);

internalOptimizer.setLineSearchSettings(new LineSearchSettings(Constants.Epsilon6, Constants.Epsilon6, ConvergenceCriteria.EITHER, 10));
outerOptimizer.setOptimizer(internalOptimizer);

// Set this value to TargetedSegmentListOperatorBehavior.RUN_ACTIVE_OPERATORS to run the optimizer until convergence.
outerTargetedSegmentList.setOperatorAction(TargetedSegmentListOperatorBehavior.RUN_ACTIVE_OPERATORS_ONCE);
```
Propagate one Iteration of Trajectory Optimizer

Since the code is set to run one iteration at a time, the following code will only run one iteration of the optimizer. Further, the outerTargetedSegmentList needs to have its getSegmentPropagator method run and its results set to m_segmentPropagator.

Java
```// Actually propagate.
TargetedSegmentListResults propagationResults = (TargetedSegmentListResults)m_segmentPropagator.propagate((SegmentListResults)null, m_segmentPropagator.getOriginalConfiguration(), backgroundCalculation);
```
Extract Results of Trajectory Optimizer

After an iteration of the optimizer is run, results can be extracted regardless of whether the optimizer converged or not.

Java
```// Extract information from propagation results.
// Outer optimizer results are extracted first.
TargetedSegmentListParameterOptimizerResults outerOptimizerOperatorResults = (TargetedSegmentListParameterOptimizerResults)propagationResults.getOperatorResults().get(0);
Boolean converged = outerOptimizerOperatorResults.getConverged();

MultivariableFunctionSolverResults<ParameterOptimizerIterationResults> outerOptimizerResults = outerOptimizerOperatorResults.getOptimizerResults();
ParameterOptimizerIterationResults outerFinalIterationResults = outerOptimizerResults.getFinalIteration();

OptimizerMultivariableFunctionResults outerFunctionResults = outerFinalIterationResults.getFunctionResult();
Double outerCostFunctionResults = outerFunctionResults.getCostFunctionValue();

double[] outerInequalityResults = outerFunctionResults.getInequalityConstraintValues();

// Extract results for nested maneuver 1 targeted segment list.
TargetedSegmentListDifferentialCorrectorResults maneuver1OperatorResults = (TargetedSegmentListDifferentialCorrectorResults)maneuver1TargetedSegmentResults.getOperatorResults().get(0);
//Boolean maneuver1Converged = maneuver1OperatorResults.getConverged();

MultivariableFunctionSolverResults<MultivariableFunctionSolverIterationResults> maneuver1FunctionSolverResults = maneuver1OperatorResults.getFunctionSolverResults();
MultivariableFunctionSolverIterationResults maneuver1FinalIterationResults = maneuver1FunctionSolverResults.getFinalIteration();
SolvableMultivariableFunctionResults maneuver1FunctionResult = maneuver1FinalIterationResults.getFunctionResult();
double[] deltaV1Results = maneuver1FunctionResult.getVariablesUsed();
double deltaV1Magnitude = Math.sqrt(deltaV1Results[0] * deltaV1Results[0] + deltaV1Results[1] * deltaV1Results[1]);

// Extract results for nested maneuver 2 targeted segment list.
TargetedSegmentListDifferentialCorrectorResults maneuver2OperatorResults = (TargetedSegmentListDifferentialCorrectorResults)maneuver2TargetedSegmentResults.getOperatorResults().get(0);
//Boolean maneuver2Converged = maneuver2OperatorResults.getConverged();

MultivariableFunctionSolverResults<MultivariableFunctionSolverIterationResults> maneuver2FunctionSolverResults = maneuver2OperatorResults.getFunctionSolverResults();
MultivariableFunctionSolverIterationResults maneuver2FinalIterationResults = maneuver2FunctionSolverResults.getFinalIteration();
SolvableMultivariableFunctionResults maneuver2FunctionResult = maneuver2FinalIterationResults.getFunctionResult();
double[] deltaV2Results = maneuver2FunctionResult.getVariablesUsed();
double deltaV2Magnitude = Math.sqrt(deltaV2Results[0] * deltaV2Results[0] + deltaV2Results[1] * deltaV2Results[1]);

// Extract results for nested maneuver 3 targeted segment list.
TargetedSegmentListDifferentialCorrectorResults maneuver3OperatorResults = (TargetedSegmentListDifferentialCorrectorResults)maneuver3TargetedSegmentResults.getOperatorResults().get(0);
//Boolean maneuver3Converged = maneuver3OperatorResults.getConverged();

MultivariableFunctionSolverResults<MultivariableFunctionSolverIterationResults> maneuver3FunctionSolverResults = maneuver3OperatorResults.getFunctionSolverResults();
MultivariableFunctionSolverIterationResults maneuver3FinalIterationResults = maneuver3FunctionSolverResults.getFinalIteration();
SolvableMultivariableFunctionResults maneuver3FunctionResult = maneuver3FinalIterationResults.getFunctionResult();
double[] deltaV3Results = maneuver3FunctionResult.getVariablesUsed();
double deltaV3Magnitude = Math.sqrt(deltaV3Results[0] * deltaV3Results[0] + deltaV3Results[1] * deltaV3Results[1]);

double totalDeltaV = deltaV1Magnitude + deltaV2Magnitude + deltaV3Magnitude;

// Extract ephemeris results for each propagate segment.
DateMotionCollection1<Cartesian> overallTrajectoryResults = propagationResults.getDateMotionCollectionOfOverallTrajectory(m_elementID);
List<DateMotionCollection1<Cartesian>> individualSegmentResults = new ArrayList<DateMotionCollection1<Cartesian>>();