NLP working for 5 phases if there's a good initial guess
This commit is contained in:
@@ -92,7 +92,7 @@ function solve_mission( guess::Mission_Guess,
|
|||||||
"acceptable_constr_viol_tol" => 100tol,
|
"acceptable_constr_viol_tol" => 100tol,
|
||||||
"max_iter" => 10_000,
|
"max_iter" => 10_000,
|
||||||
"max_cpu_time" => 300.,
|
"max_cpu_time" => 300.,
|
||||||
"print_level" => 5)
|
"print_level" => 0)
|
||||||
options = Options(solver=IPOPT(ipopt_options), derivatives=ForwardFD())
|
options = Options(solver=IPOPT(ipopt_options), derivatives=ForwardFD())
|
||||||
|
|
||||||
x, _, info = minimize(optimizer!, x0, num_constraints, lower_x, upper_x, g_low, g_high, options)
|
x, _, info = minimize(optimizer!, x0, num_constraints, lower_x, upper_x, g_low, g_high, options)
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
@testset "Phase" begin
|
@testset "NLP Solver" begin
|
||||||
|
|
||||||
using PlotlyJS: savefig
|
using PlotlyJS: savefig
|
||||||
|
|
||||||
@@ -24,14 +24,13 @@
|
|||||||
p = plot(m, title="NLP Test Solution")
|
p = plot(m, title="NLP Test Solution")
|
||||||
savefig(p,"../plots/nlp_test_1_phase.html")
|
savefig(p,"../plots/nlp_test_1_phase.html")
|
||||||
|
|
||||||
# Now we can look at a more complicated trajectory
|
# Now we can look at a slightly more complicated trajectory
|
||||||
flybys = [Earth, Venus, Mars]
|
flybys = [Earth, Venus, Mars]
|
||||||
launch_window = [DateTime(2021,10,1), DateTime(2021,12,1)]
|
launch_window = [DateTime(2021,10,1), DateTime(2021,12,1)]
|
||||||
latest_arrival = DateTime(2023,1,1)
|
latest_arrival = DateTime(2023,1,1)
|
||||||
dates = [DateTime(2021,11,1), DateTime(2022,3,27), DateTime(2022,8,28)]
|
dates = [DateTime(2021,11,1), DateTime(2022,3,27), DateTime(2022,8,28)]
|
||||||
phases = Vector{Phase}()
|
phases = Vector{Phase}()
|
||||||
launch_v∞, _, tof1 = Thesis.lamberts(flybys[1], flybys[2], dates[1], dates[2])
|
launch_v∞, _, tof1 = Thesis.lamberts(flybys[1], flybys[2], dates[1], dates[2])
|
||||||
println(launch_v∞)
|
|
||||||
for i in 1:length(dates)-2
|
for i in 1:length(dates)-2
|
||||||
v∞_out1, v∞_in1, tof1 = Thesis.lamberts(flybys[i], flybys[i+1], dates[i], dates[i+1])
|
v∞_out1, v∞_in1, tof1 = Thesis.lamberts(flybys[i], flybys[i+1], dates[i], dates[i+1])
|
||||||
v∞_out2, v∞_in2, tof2 = Thesis.lamberts(flybys[i+1], flybys[i+2], dates[i+1], dates[i+2])
|
v∞_out2, v∞_in2, tof2 = Thesis.lamberts(flybys[i+1], flybys[i+2], dates[i+1], dates[i+2])
|
||||||
@@ -39,10 +38,33 @@
|
|||||||
end
|
end
|
||||||
v∞_out, v∞_in, tof = Thesis.lamberts(flybys[end-1], flybys[end], dates[end-1], dates[end])
|
v∞_out, v∞_in, tof = Thesis.lamberts(flybys[end-1], flybys[end], dates[end-1], dates[end])
|
||||||
push!(phases, Phase(flybys[end], v∞_in, v∞_in, tof, 0.01*ones(20,3)))
|
push!(phases, Phase(flybys[end], v∞_in, v∞_in, tof, 0.01*ones(20,3)))
|
||||||
# This isn't quite right. V∞ discrepancy is too big
|
|
||||||
guess = Mission_Guess(bepi, 12_000., dates[1], launch_v∞, phases)
|
guess = Mission_Guess(bepi, 12_000., dates[1], launch_v∞, phases)
|
||||||
m = solve_mission(guess, launch_window, latest_arrival, verbose=true)
|
m = solve_mission(guess, launch_window, latest_arrival, verbose=true)
|
||||||
p = plot(m, title="NLP Test Solution (2 Phases)")
|
p = plot(m, title="NLP Test Solution (2 Phases)")
|
||||||
savefig(p,"../plots/nlp_test_2_phase.html")
|
savefig(p,"../plots/nlp_test_2_phase.html")
|
||||||
|
|
||||||
|
# Here is the final, most complicated, trajectory to test
|
||||||
|
flybys = [Earth, Venus, Earth, Mars, Earth, Jupiter]
|
||||||
|
launch_window = [DateTime(2023,1,1), DateTime(2024,1,1)]
|
||||||
|
latest_arrival = DateTime(2031,1,1)
|
||||||
|
dates = [DateTime(2023,6,28),
|
||||||
|
DateTime(2023,10,30),
|
||||||
|
DateTime(2024,9,2),
|
||||||
|
DateTime(2025,2,10),
|
||||||
|
DateTime(2026,11,26),
|
||||||
|
DateTime(2029,10,16)]
|
||||||
|
phases = Vector{Phase}()
|
||||||
|
launch_v∞, _, tof1 = Thesis.lamberts(flybys[1], flybys[2], dates[1], dates[2])
|
||||||
|
for i in 1:length(dates)-2
|
||||||
|
v∞_out1, v∞_in1, tof1 = Thesis.lamberts(flybys[i], flybys[i+1], dates[i], dates[i+1])
|
||||||
|
v∞_out2, v∞_in2, tof2 = Thesis.lamberts(flybys[i+1], flybys[i+2], dates[i+1], dates[i+2])
|
||||||
|
push!(phases, Phase(flybys[i+1], v∞_in1, v∞_out2, tof1, 0.01*ones(20,3)))
|
||||||
|
end
|
||||||
|
v∞_out, v∞_in, tof = Thesis.lamberts(flybys[end-1], flybys[end], dates[end-1], dates[end])
|
||||||
|
push!(phases, Phase(flybys[end], v∞_in, v∞_in, tof, 0.01*ones(20,3)))
|
||||||
|
guess = Mission_Guess(bepi, 12_000., dates[1], launch_v∞, phases)
|
||||||
|
m = solve_mission(guess, launch_window, latest_arrival, verbose=true)
|
||||||
|
p = plot(m, title="NLP Test Solution (5 Phases)")
|
||||||
|
savefig(p,"../plots/nlp_test_5_phase.html")
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user