With the top.Cruise module, when the trajectory is called with certain h_min/h_max and objective='time' (or some combo of weight*time + fuel), the returned trajectory has a slowdown of 25% to 100% compared to past data. I'm running these on OpenAP 2.4 and top 1.1.
Link to test data
Code to replicate:
import pandas as pd
from openap import top
from openap import FuelFlow
from openap import aero
flight_triplets=(('7380c9_0','B789', 254000),
('4bb18a_0', 'B789', 254000),
('781345_0', 'A359', 280000),
('c01732_0', 'B772', 297000),
)
for triplet in flight_triplets:
# Load data
df = pd.read_csv('test_flights.csv', parse_dates=['time'])
history = df[df.flight_id == triplet[0]]
actype = triplet[1]
start = (history.lat.iloc[0], history.lon.iloc[0])
end = (history.lat.iloc[-1], history.lon.iloc[-1])
h_min_ft = history.geoaltitude.min()
h_max_ft = history.geoaltitude.max()
# First optimization with lowerbound and upperbound on altitude
optimizer_1 = top.Cruise(actype, start, end, 0.75, use_synonym=True)
optimizer_1.setup(nodes = len(history)-1)
flight = optimizer_1.trajectory(
objective='time',
h_min=(h_min_ft-500)*aero.ft, # Reduce the h_min a bit
h_max=h_max_ft*aero.ft)
print('First optimization round with h_min and h_max set using past data')
print(flight.head()[['ts', 'altitude', 'fuelflow']])
# Second optimization with default bounds
optimizer_2 = top.Cruise(actype, start, end, 0.75, use_synonym=True)
optimizer_2.setup(nodes = len(history)-1)
flight = optimizer_2.trajectory(
objective='time')
print('Second optimization round using default h_min h_max')
print(flight.head()[['ts', 'altitude', 'fuelflow']])
# Calculate fuelflow from past data
fuelflow = FuelFlow(ac=actype)
mass_current = triplet[2]*0.75
history = history.assign(d_ts=30) # Data was sampled every 30 seconds so this is known
fuelflow_every_step = []
fuel_every_step = []
for i, row in history.iterrows():
ff = fuelflow.enroute(
mass=mass_current,
tas=row.velocity,
alt=row.geoaltitude,
vs=row.vertrate,
)
fuel = ff * row.d_ts
fuelflow_every_step.append(ff)
fuel_every_step.append(ff * row.d_ts)
mass_current -= fuel
history = history.assign(fuel_flow=fuelflow_every_step, fuel=fuel_every_step)
print('Result from past data')
print(history.head()[['time', 'geoaltitude', 'fuel_flow']])
Sometimes, the optimized flight also has a worse time compared to the past flight (although only slightly, i.e. 5-20%).
It may be worth mentioning that, whenever this happens, even though the flying time of the optimized route is worse than the one from history, the fuel flow can still be slightly better.
With the top.Cruise module, when the trajectory is called with certain h_min/h_max and objective='time' (or some combo of weight*time + fuel), the returned trajectory has a slowdown of 25% to 100% compared to past data. I'm running these on OpenAP 2.4 and top 1.1.
Link to test data
Code to replicate:
Sometimes, the optimized flight also has a worse time compared to the past flight (although only slightly, i.e. 5-20%).
It may be worth mentioning that, whenever this happens, even though the flying time of the optimized route is worse than the one from history, the fuel flow can still be slightly better.