Skip to content

Commit

Permalink
A/C Performance abstract class + graph improvement (#453)
Browse files Browse the repository at this point in the history
* updated graph + PS + OPENAP

* cleanup
  • Loading branch information
nestorcarmona authored Dec 20, 2024
1 parent a581668 commit 02f54a1
Show file tree
Hide file tree
Showing 62 changed files with 3,677 additions and 2,532 deletions.
150 changes: 78 additions & 72 deletions notebooks/15_flightplanning_tuto.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,20 @@
"source": [
"import datetime\n",
"\n",
"from skdecide.hub.domain.flight_planning.aircraft_performance.bean.aircraft_state import (\n",
" AircraftState,\n",
")\n",
"from skdecide.hub.domain.flight_planning.aircraft_performance.performance.performance_model_enum import (\n",
" PerformanceModelEnum,\n",
")\n",
"from skdecide.hub.domain.flight_planning.aircraft_performance.performance.phase_enum import (\n",
" PhaseEnum,\n",
")\n",
"from skdecide.hub.domain.flight_planning.aircraft_performance.performance.rating_enum import (\n",
" RatingEnum,\n",
")\n",
"from skdecide.hub.domain.flight_planning.domain import FlightPlanningDomain, WeatherDate\n",
"from skdecide.hub.domain.flight_planning.flightplanning_utils import plot_network\n",
"from skdecide.hub.solver.astar import Astar\n",
"\n",
"# reload\n",
Expand Down Expand Up @@ -149,6 +162,35 @@
"cost_function = \"fuel\""
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Definition of the aircraft initial state\n",
"Now, we define the aircraft state. This implies picking an aircraft performance model : `OPENAP` or `POLL_SCHUMANN`"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"acState = AircraftState(\n",
" model_type=\"A320\", # only for OPENAP and POLL_SCHUMANN\n",
" performance_model_type=PerformanceModelEnum.POLL_SCHUMANN, # PerformanceModelEnum.OPENAP\n",
" gw_kg=80_000,\n",
" zp_ft=10_000,\n",
" mach_cruise=0.7,\n",
" cas_climb_kts=250,\n",
" cas_descent_kts=220,\n",
" phase=PhaseEnum.CLIMB,\n",
" rating_level=RatingEnum.MCL,\n",
" cg=0.3,\n",
" gamma_air_deg=0,\n",
")"
]
},
{
"attachments": {},
"cell_type": "markdown",
Expand All @@ -166,29 +208,28 @@
"outputs": [],
"source": [
"domain_factory = lambda: FlightPlanningDomain(\n",
" origin,\n",
" destination,\n",
" aircraft,\n",
" weather_date=weather_date,\n",
" heuristic_name=heuristic,\n",
" perf_model_name=\"openap\", # a/c performance model\n",
" origin=origin,\n",
" destination=destination,\n",
" aircraft_state=acState,\n",
" objective=cost_function,\n",
" fuel_loop=False,\n",
" graph_width=\"normal\",\n",
" heuristic_name=heuristic,\n",
" weather_date=weather_date,\n",
" cruise_height_min=35_000,\n",
" cruise_height_max=42_000,\n",
" graph_width=\"medium\", # small, medium, large, xlarge\n",
" nb_vertical_points=5, # flight levels in cruise\n",
" nb_forward_points=5,\n",
" nb_lateral_points=7, # must be odd\n",
")\n",
"\n",
"domain = domain_factory()"
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
"## Solving and rendering out the flight planning domain\n",
"\n",
"We use here an A* solver as mentionned before. \n",
"We also use the custom rollout proposed to have some visualization during the flight planning generation."
"We can plot the graph:"
]
},
{
Expand All @@ -197,22 +238,18 @@
"metadata": {},
"outputs": [],
"source": [
"with Astar(\n",
" heuristic=lambda d, s: d.heuristic(s), domain_factory=domain_factory, parallel=False\n",
") as solver:\n",
" solver.solve()\n",
" domain.custom_rollout(solver=solver)"
"plot_network(domain)"
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
"## Changing aircraft performance model\n",
"\n",
"One of the new features of the flight planning domain is the addition of another aircraft performance model. Indeed, the default is OpenAP (`openap`) but we can now choose [Poll-Schumann](https://elib.dlr.de/135592/1/Poll_Schumann_estimation_method_fuel_burn_performance_aircraft_cruise_part_1_fundamentals_2020.pdf) (`PS`), which is more accurate.\n",
"## Solving and rendering out the flight planning domain\n",
"\n",
"Thus, we can run the solver on the domain with a Poll-Schumann A/C performance model:"
"We use here an A* solver as mentionned before. \n",
"We also use the custom rollout proposed to have some visualization during the flight planning generation."
]
},
{
Expand All @@ -221,34 +258,20 @@
"metadata": {},
"outputs": [],
"source": [
"domain_factory = lambda: FlightPlanningDomain(\n",
" origin,\n",
" destination,\n",
" aircraft,\n",
" weather_date=weather_date,\n",
" heuristic_name=heuristic,\n",
" perf_model_name=\"PS\", # a/c performance model\n",
" objective=cost_function,\n",
" fuel_loop=False,\n",
" graph_width=\"normal\",\n",
")\n",
"\n",
"domain = domain_factory()\n",
"\n",
"with Astar(\n",
" heuristic=lambda d, s: d.heuristic(s), domain_factory=domain_factory, parallel=False\n",
") as solver:\n",
" solver.solve()\n",
" domain.custom_rollout(solver=solver)"
"solver = Astar(\n",
" domain_factory=domain_factory,\n",
" heuristic=lambda d, s: d.heuristic(s),\n",
" parallel=False,\n",
")"
]
},
{
"cell_type": "markdown",
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"## Longer routes\n",
"\n",
"Finally, we will make a long haul flight: Cartagena (ICAO: SKCG) - Toulouse (ICAO: LFBO), with an A380. For computational purposes, we will also modify the heuristic function:"
"solver.solve()"
]
},
{
Expand All @@ -257,37 +280,20 @@
"metadata": {},
"outputs": [],
"source": [
"heuristic = \"lazy_fuel\"\n",
"\n",
"origin = \"SKCG\"\n",
"destination = \"LFBO\"\n",
"aircraft = \"A388\"\n",
"\n",
"domain_factory = lambda: FlightPlanningDomain(\n",
" origin,\n",
" destination,\n",
" aircraft,\n",
" weather_date=weather_date,\n",
" heuristic_name=heuristic,\n",
" perf_model_name=\"PS\", # a/c performance model\n",
" objective=cost_function,\n",
" fuel_loop=False,\n",
" graph_width=\"normal\",\n",
")\n",
"\n",
"domain = domain_factory()\n",
"\n",
"with Astar(\n",
" heuristic=lambda d, s: d.heuristic(s), domain_factory=domain_factory, parallel=False\n",
") as solver:\n",
" solver.solve()\n",
" domain.custom_rollout(solver=solver)"
"domain.custom_rollout(solver=solver, make_img=True)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"display_name": "test_dev_skdecide",
"language": "python",
"name": "python3"
},
Expand All @@ -301,7 +307,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.13"
"version": "3.9.19"
}
},
"nbformat": 4,
Expand Down
98 changes: 0 additions & 98 deletions skdecide/hub/domain/flight_planning/aircraft_performance/base.py

This file was deleted.

Loading

0 comments on commit 02f54a1

Please sign in to comment.