You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- Define Hamiltonian H(x, p, u) = H0(x, p) + u * H1(x, p)
- Compute and display H along direct and indirect trajectories
- Show Hamiltonian variation (should be near zero for optimal solutions)
- Plot H(t) for both methods for visual comparison
The Hamiltonian should be constant along the optimal trajectory and equal to zero since the final time is free. Let us verify this for both the direct and indirect solutions.
511
+
512
+
```@example main-goddard
513
+
# Hamiltonian function
514
+
H(x, p, u) = H0(x, p) + u * H1(x, p)
515
+
516
+
# Direct solution
517
+
t_dir = time_grid(direct_sol)
518
+
x_dir = state(direct_sol)
519
+
u_dir = control(direct_sol)
520
+
p_dir = costate(direct_sol)
521
+
H_direct = [H(x_dir(ti), p_dir(ti), u_dir(ti)) for ti in t_dir]
522
+
523
+
# Indirect solution
524
+
t_ind = time_grid(indirect_sol)
525
+
x_ind = state(indirect_sol)
526
+
u_ind = control(indirect_sol)
527
+
p_ind = costate(indirect_sol)
528
+
H_indirect = [H(x_ind(ti), p_ind(ti), u_ind(ti)) for ti in t_ind]
[^1]: R.H. Goddard. A Method of Reaching Extreme Altitudes, volume 71(2) of Smithsonian Miscellaneous Collections. Smithsonian institution, City of Washington, 1919.
0 commit comments