Plots a route schedule. This function plots multiple time statistics as a function of distance travelled: * Solid: earliest possible trajectory / time, using time warp if the route is infeasible. * Shaded: slack up to latest possible trajectory / time, only if no time w
(
data: ProblemData,
route: Route,
load_dimension: int = 0,
legend: bool = True,
title: str | None = None,
ax: plt.Axes | None = None,
)
| 6 | |
| 7 | |
| 8 | def plot_route_schedule( |
| 9 | data: ProblemData, |
| 10 | route: Route, |
| 11 | load_dimension: int = 0, |
| 12 | legend: bool = True, |
| 13 | title: str | None = None, |
| 14 | ax: plt.Axes | None = None, |
| 15 | ): |
| 16 | """ |
| 17 | Plots a route schedule. This function plots multiple time statistics |
| 18 | as a function of distance travelled: |
| 19 | |
| 20 | * Solid: earliest possible trajectory / time, using time warp if the route |
| 21 | is infeasible. |
| 22 | * Shaded: slack up to latest possible trajectory / time, only if no time |
| 23 | warp on the route. |
| 24 | * Dash-dotted: driving and service time, excluding wait time and time warp. |
| 25 | * Dotted: pure driving time. |
| 26 | * Grey shaded background: remaining load in the vehicle for the provided |
| 27 | load dimension. |
| 28 | |
| 29 | Parameters |
| 30 | ---------- |
| 31 | data |
| 32 | Data instance for which to plot the route schedule. |
| 33 | route |
| 34 | Route (list of clients) whose schedule to plot. |
| 35 | load_dimension |
| 36 | Load dimension to plot. Defaults to the first dimension, if it exists. |
| 37 | legend |
| 38 | Whether or not to show the legends. Default True. |
| 39 | title |
| 40 | Title to add to the plot. |
| 41 | ax |
| 42 | Axes object to draw the plot on. One will be created if not provided. |
| 43 | """ |
| 44 | if not ax: |
| 45 | _, ax = plt.subplots() |
| 46 | |
| 47 | vehicle_type = data.vehicle_type(route.vehicle_type()) |
| 48 | distances = data.distance_matrix(vehicle_type.profile) |
| 49 | durations = data.duration_matrix(vehicle_type.profile) |
| 50 | |
| 51 | track_load = load_dimension < data.num_load_dimensions |
| 52 | |
| 53 | # Initialise tracking variables |
| 54 | drive_time = 0 |
| 55 | serv_time = 0 |
| 56 | dist = 0 |
| 57 | |
| 58 | load = 0 |
| 59 | if track_load: |
| 60 | load = route.delivery()[load_dimension] |
| 61 | |
| 62 | # Traces and objects used for plotting |
| 63 | trace_time = [] |
| 64 | trace_drive = [] |
| 65 | trace_drive_serv = [] |
nothing calls this directly
no test coverage detected