Rocket Trajectory Optimization in Julia

Find the fuel-minimum path from launchpad to orbit — mathematically.

Undergraduate Orbital Mechanics 4–6 weeks
Last reviewed: March 2026

Overview

Trajectory optimization is the discipline of finding the control inputs — typically engine thrust direction and magnitude — that drive a vehicle from an initial state to a desired final state while minimising a cost such as fuel consumption or time. For launch vehicles, even a small improvement in propellant efficiency translates to tens of kilograms of additional payload delivered to orbit, making trajectory optimization one of the highest-leverage engineering tasks in the business. Companies like SpaceX, Rocket Lab, and United Launch Alliance run trajectory optimisers on every flight to generate the guidance tables that are loaded onto the vehicle before launch.

Julia is ideally suited to this task: its JuMP algebraic modelling language allows you to write optimization problems in near-mathematical notation, while its automatic differentiation ecosystem computes the exact Jacobians and Hessians that nonlinear solvers like Ipopt need for efficient convergence. Direct collocation transcribes the continuous-time trajectory into a finite-dimensional NLP by representing state and control variables at a grid of collocation points and enforcing the dynamics as algebraic equality constraints at each point — an approach that is robust, parallelisable, and used in production trajectory software.

By completing this project you will have solved a non-trivial optimal control problem from mathematical formulation to numerical solution, visualised the fuel-optimal gravity-turn trajectory, and performed sensitivity analysis showing how constraints (maximum dynamic pressure, minimum altitude, thrust magnitude limits) change the solution. These skills underpin careers in launch vehicle GNC, space mission design, and operations research applied to aerospace systems.

What You'll Learn

  • Formulate a continuous-time optimal control problem for a single-stage rocket as a mathematical statement
  • Transcribe the OCP into a nonlinear program using direct collocation (Hermite–Simpson method)
  • Implement the NLP in JuMP with Ipopt and interpret solver output (constraint violations, KKT conditions)
  • Visualise optimal altitude, velocity, flight path angle, and thrust profiles and explain each phase physically
  • Perform parametric analysis: how does the optimal trajectory change with thrust-to-weight ratio and Isp?

Step-by-Step Guide

1

Review the equations of motion and optimal control theory

Derive the 2D point-mass rocket equations of motion in a spherical Earth frame: altitude rate, velocity rate, flight path angle rate, and mass rate (Tsiolkovsky). State the fuel-optimal control problem formally: minimise final mass loss subject to dynamics, boundary conditions (launch pad to target orbit altitude and velocity), and path constraints (maximum dynamic pressure q ≤ 50 kPa).

2

Set up Julia, JuMP, and Ipopt

Install Julia and add the packages JuMP, Ipopt, Plots, and DifferentialEquations. Verify Ipopt is correctly linked by solving a small nonlinear test problem. Write a helper function that evaluates the rocket dynamics given a state and control vector, which you will use both for simulation and to formulate the collocation constraints.

3

Formulate the direct collocation NLP in JuMP

Define a uniform grid of N=100 collocation nodes over the flight time T (treat T as a free optimisation variable). Declare state variables (h, v, γ, m) and control variables (thrust magnitude, thrust angle) at each node as JuMP decision variables. Add Hermite–Simpson defect equality constraints enforcing the dynamics, bound constraints on thrust and dynamic pressure, and boundary condition constraints at nodes 1 and N.

4

Provide an initial guess and solve

A good initial guess is critical for nonlinear solvers. Provide a simple gravity-turn reference trajectory (constant thrust, zero angle of attack) interpolated onto your grid. Solve with Ipopt and monitor the solver log for constraint violations and objective value. If Ipopt fails to converge, relax path constraints temporarily to find a feasible initial solution, then tighten them progressively.

5

Visualise and interpret the optimal trajectory

Plot altitude vs. time, velocity vs. time, flight path angle vs. time, and mass vs. time for the optimal solution. Plot the thrust angle profile and mark the gravity-turn, pitch-over, and orbit-insertion phases. Compute the total ΔV and compare against the theoretical Tsiolkovsky equation to verify the optimiser is not "cheating" by violating conservation laws.

6

Parametric sensitivity analysis

Re-solve the trajectory for three values of thrust-to-weight ratio (1.3, 1.6, 2.0) and two values of Isp (300 s, 380 s) — six total runs. Create a table and plots showing how payload mass fraction, peak dynamic pressure, and trajectory shape change across configurations. Write a one-page engineering discussion explaining which parameters are most beneficial to improve.

Go Further

  • Extend to a two-stage rocket and optimise the staging event (mass ratio and ignition time) as additional decision variables.
  • Add a landing phase for the first stage (Falcon 9-style boostback) and solve the combined ascent-plus-landing trajectory in a single NLP.
  • Implement a Model Predictive Control loop that re-solves the remaining trajectory in real time as wind disturbances are applied, simulating closed-loop guidance.