using Thesis using Dates using SPICE using LinearAlgebra using PlotlyJS try furnsh("../../spice_files/naif0012.tls") furnsh("../../spice_files/de430.bsp") catch furnsh("spice_files/naif0012.tls") furnsh("spice_files/de430.bsp") end """ The cost function for the mission """ function easy_cost(m::Union{Mission, Mission_Guess}, 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∞ tof = 0.0 for phase in m.phases tof += phase.tof end tof = tof/(20Thesis.year) return 3norm_mass + norm_C3 end sc = Sc("mySat", 200., 3200., 0.00025, 1, 1.0) fuel = 3300. max_c3 = 200. max_v∞ = 500. ideal_launch = DateTime(2024,1,1) launch_window = ideal_launch - Day(365), ideal_launch + Day(365) latest_arrival = ideal_launch + Year(18) println("Max thrust at full bore: $(fuel/(mfr(sc)*Thesis.year)) years") println("Max mission length: $((latest_arrival - launch_window[1]).value/(1000Thesis.year)) years") # 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=200, drill_patience=50, verbose=true, ) function log(archive::Vector{Mission}, planets::Vector{Body}) abbrev = join([ planet.name[1] for planet in planets ]) println(length(archive)) for m in archive println(abbrev) store(m, "archive/$(abbrev)_$(easy_cost(m, 200., 200.))") end end log(_::Nothing, _::Vector{Mission}, _::Vector{Body}) = println("No Mission Found...") planets = [Earth, Saturn] latest_arrival = ideal_launch + Year(5) best, archive, missions = mbh(planets) log(missions, planets) p = scatter(;x=1:length(missions), y=easy_cost.(missions, 200., 200.), mode="markers") PlotlyJS.plot(p)