Plots the results of a run, including the best solution and detailed statistics about the algorithm's performance. Parameters ---------- result Result to be plotted. data Data instance underlying the result's solution. fig Optional Figure to draw
(
result: Result, data: ProblemData, fig: plt.Figure | None = None
)
| 8 | |
| 9 | |
| 10 | def plot_result( |
| 11 | result: Result, data: ProblemData, fig: plt.Figure | None = None |
| 12 | ): |
| 13 | """ |
| 14 | Plots the results of a run, including the best solution and detailed |
| 15 | statistics about the algorithm's performance. |
| 16 | |
| 17 | Parameters |
| 18 | ---------- |
| 19 | result |
| 20 | Result to be plotted. |
| 21 | data |
| 22 | Data instance underlying the result's solution. |
| 23 | fig |
| 24 | Optional Figure to draw on. One will be created if not provided. |
| 25 | """ |
| 26 | if not fig: |
| 27 | fig = plt.figure(figsize=(20, 12)) |
| 28 | |
| 29 | # Uses a GridSpec instance to lay-out all subplots nicely. There are |
| 30 | # two columns: left and right. Left has two rows, each containing a |
| 31 | # plot with statistics: the first plots each iteration's objective |
| 32 | # information, and the second plots iteration runtimes. The right column |
| 33 | # plots the solution on top of the instance data. |
| 34 | gs = fig.add_gridspec(2, 2, width_ratios=(2 / 5, 3 / 5)) |
| 35 | |
| 36 | ax_div = fig.add_subplot(gs[0, 0]) |
| 37 | plot_objectives(result, ax=ax_div) |
| 38 | plot_runtimes(result, ax=fig.add_subplot(gs[1, 0], sharex=ax_div)) |
| 39 | |
| 40 | plot_solution(result.best, data, ax=fig.add_subplot(gs[:, 1])) |
nothing calls this directly
no test coverage detected