Files
thesis/julia/ingest_mbh.jl
2022-04-18 10:59:25 -06:00

53 lines
1.4 KiB
Julia

using Thesis
using SPICE
using LinearAlgebra
using Dates
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
function cost(m::Union{Mission, Mission_Guess})
norm_mass = (m.start_mass - prop(m)[7]) / m.start_mass
norm_C3 = ( m.launch_v∞ m.launch_v∞ ) / 200.
return 3norm_mass + norm_C3
end
files = Vector{String}()
contents = readdir("/home/connor/projects/thesis/archive", join=true)
for item in contents
if item[1:39] == "/home/connor/projects/thesis/archive/ES"
push!(files, item)
end
end
sort!(files, by=x->stat(x).ctime)
missions = Vector{Mission}()
for file in files push!(missions, ingest(file)) end
best_cost = Vector{Float64}()
global current_min = cost(missions[1])
for mission in missions
if cost(mission) < current_min global current_min = cost(mission) end
push!(best_cost, current_min)
end
p_dots = scatter(;y = cost.(missions), mode="markers")
p_best = scatter(;y = best_cost)
layout = Layout(;showlegend=false,
title=attr(
font_color="rgb(0,0,0)",
yanchor="top",
y=0.95,
text="Cost Functions Values of Single MBH run for Earth-Saturn Trajectory"
),
yaxis_title = "Cost Function Value",
)
display(PlotlyJS.plot([p_dots, p_best], layout))