Update for ky
This commit is contained in:
42
julia/test/mbh.jl
Normal file
42
julia/test/mbh.jl
Normal file
@@ -0,0 +1,42 @@
|
||||
@testset "Monotonic Basin Hopping" begin
|
||||
|
||||
using PlotlyJS: savefig
|
||||
|
||||
println("Testing Monotonic Basin Hopper")
|
||||
|
||||
"""
|
||||
The cost function for the mission
|
||||
"""
|
||||
function easy_cost(m::Mission, C3::Float64, v∞::Float64)
|
||||
norm_mass = (m.start_mass - prop(m)[7]) / m.start_mass
|
||||
norm_C3 = ( m.launch_v∞ ⋅ m.launch_v∞ ) / C3
|
||||
norm_v∞ = norm(m.phases[end].v∞_in) / v∞
|
||||
return norm_mass + norm_C3 + norm_v∞
|
||||
end
|
||||
|
||||
# Mission Parameters that won't change (they're very lenient)
|
||||
sc, fuel = bepi, 2_000.
|
||||
max_c3, max_v∞ = 100., 20.
|
||||
launch_window = DateTime(2022,1,1), DateTime(2024,12,25)
|
||||
latest_arrival = DateTime(2034,12,25)
|
||||
|
||||
# Convenience function for these tests
|
||||
Thesis.mbh(fbs) = mbh(fbs, sc, sc.dry_mass + fuel, launch_window, max_c3, max_v∞, latest_arrival,
|
||||
easy_cost, search_patience=500, drill_patience=20, verbose=true, test=true)
|
||||
function log(m::Mission, archive::Vector{Mission})
|
||||
p = plot(m, title="MBH Test Solution")
|
||||
savefig(p,"../plots/mbh_test_$(length(m.phases))_phase.html")
|
||||
store(m, "missions/mbh_$(length(m.phases))_phase_best")
|
||||
store(archive, "missions/mbh_$(length(m.phases))_phase_archive")
|
||||
end
|
||||
|
||||
# Start simple and get more complex
|
||||
tests = [Earth, Jupiter], [Earth, Mars, Jupiter], [Earth, Mars, Mars, Jupiter]
|
||||
|
||||
for planets in tests
|
||||
best, archive = mbh(planets)
|
||||
@test typeof(best) == Mission
|
||||
log(best, archive)
|
||||
end
|
||||
|
||||
end
|
||||
Reference in New Issue
Block a user