results module

class results.Results(solutions: Optional[List[DataFrame]] = None, runtimes: Optional[List[float]] = None, objective_values: Optional[List[float]] = None, multiday: bool = False, day_index: Optional[List] = None)[source]

Bases: object

Class to handle optimization results, plot schedules and compute statistics.

  • solutions: list of dataframes containing the optimized schedules

  • runtimes: list containing the runtimes of each iteration

  • n_iter: number of simulation iterations.

  • plot: plots the given schedules

  • compute_statistics: compute average duration and frequency for each activity in the optimal schedules

  • plot_distribution:

  • get_solutions: returns list of optimized schedules

  • get_runtimes: returns list of runtimes for each iteration.

compute_statistics(activities: List = ['education', 'leisure', 'work', 'shopping'], days: Optional[List] = None, bootstrap: int = 100, verbose: bool = True, save: Union[bool, str] = 'out_stats.joblib') None[source]

Compute aggregate statistics for the optimized schedules.

  • activities: list of activities of interest for the computations.

  • days: list of days of interest for the computations (only defined in the multiday case)

  • bootstrap: number of bootstrap samples to generate, to compute the 95% confidence intervals.

  • verbose: if True, prints computed statistics.

  • save: if filename is provided, save statistics to file

List of computed statistics, either saved or printed

get_objective_values() List[source]

Returns list of objective_values for each iteration.

get_runtimes() List[source]

Returns list of runtimes for each iteration.

get_solutions() List[source]

Returns list of optimized schedules

plot(plot_every: int = 1, plot_iter: Optional[int] = None, colors: str = 'colorblind', title: Optional[str] = None, save_fig: Optional[str] = 'png') None[source]

Plots a given schedule.

  • plot_every: plotting frequency as a number of iterations

  • plot_iter: index of iteration to plot

  • colors: name of matplotlib/seaborn compatible palette, see options here: https://seaborn.pydata.org/tutorial/color_palettes.html

  • title: plot title as a string

  • save_fig: export format (png/pdf/svg) as string. if None, the figure is not saved.

Matplotlib figure, either printed or saved to an external file if save_fig is not None.

plot_distribution(exclude: Optional[List] = ['escort', 'business_trip', 'errands_services'], block_size: float = 0.08333333333333333, days: Optional[List] = None, figure_size: List = [7, 4], save_fig: Optional[str] = 'png') None[source]

Plots aggregate time of day distribution.

  • exclude: list of activities to exclude from the visualization

  • block_size: size of the discretization in hours. Default: 5/60 hours.

  • days: list of days of interest for the aggregation (only defined in the multiday case)

  • figure_size: size of figure

  • save_fig: xport format (png/pdf/svg) as string. if None, the figure is not saved.

Matplotlib figure, either printed or saved to an external file if save_fig is not None.

plot_multiday(multi_schedules: List, colors: str = 'colorblind')[source]

Plots schedules for the multiday case.

  • Matplotlib figure