src.logger¶
Module Contents¶
Classes¶
Functions¶
Introduction¶Converts an agent’s name to a simplified label for display or logging purposes. |
Data¶
API¶
- src.logger.markers[source]¶
[‘o’, ‘^’, ‘*’, ‘O’, ‘v’, ‘x’, ‘X’, ‘d’, ‘D’, ‘.’, ‘1’, ‘2’, ‘3’, ‘4’, ‘8’, ‘s’, ‘p’, ‘P’, ‘h’, ‘H’]
- src.logger.colors[source]¶
[‘b’, ‘g’, ‘orange’, ‘r’, ‘purple’, ‘brown’, ‘grey’, ‘limegreen’, ‘turquoise’, ‘olivedrab’, ‘royalbl…
- src.logger.to_label(agent_name: str) str[source]¶
Introduction¶
Converts an agent’s name to a simplified label for display or logging purposes.
Args:¶
agent_name (str): The name of the agent to be converted.
Returns:¶
str: The simplified label. If the agent name is ‘L2L_Agent’, returns ‘RNN-OI’. If the agent name ends with ‘_Agent’ or ‘_agent’, removes this suffix. Otherwise, returns the original name.
- class src.logger.Basic_Logger(config: argparse.Namespace)[source]¶
Initialization
- get_average_data(results: dict, norm: bool = False, data_wrapper: Callable = None)[source]¶
Introduction¶
Computes the average and standard deviation of each agent’s results across multiple problems, with optional normalization and data preprocessing.
Args:¶
results (dict): Nested dictionary containing results structured as
results[problem][agent] = values.They are the data to be process.norm (bool, optional): If True, applies min-max normalization to the values for each agent and problem. Defaults to False.
data_wrapper (Callable, optional): A function to preprocess each data item for each agent under each problem. Defaults to None.
Returns:¶
tuple: A tuple
(avg_data, std_data)where:avg_data(dict): Dictionary mapping each agent to their average value across all problems.std_data(dict): Dictionary mapping each agent to their standard deviation across all problems.
Raises:¶
KeyError: If the structure of
resultsdoes not match the expected format.ValueError: If normalization is requested but the data has zero range (max equals min).
- cal_scores1(D: dict, maxf: float)[source]¶
Introduction¶
Calculates a custom score for each agent based on the provided dictionary of values and a normalization factor, intended as a tool function for the CEC metric.
Args:¶
D (dict): A dictionary where each key represents an agent and the value is an array-like structure representing the results in all test problems.
maxf (float): A normalization factor used to scale the minimum values for each agent.
Returns:¶
np.ndarray: An array of computed scores for each agent.
Notes:¶
The function computes a score for each agent by first calculating a scaled sum of the minimum values in their associated array, then normalizing and scaling the result to produce the final score.
- get_random_baseline(results: dict, fes: Optional[Union[int, float]])[source]¶
Introduction¶
Calculates baseline statistics from Random Search results for normalization and comparison purposes in optimization experiments.
Args:¶
results (dict): The results data. Also a nested dictionary containing experimental results structured as
dict[metric][problem][algo][run].fes (Optional[Union[int, float]]): The maximum number of function evaluations used for normalization in the ‘fes’ baseline calculation.
Returns:¶
dict: A dictionary containing the following baseline statistics:
‘complexity_avg’: Mean log-complexity across problems.
‘complexity_std’: Standard deviation of log-complexity.
‘fes_avg’: Mean normalized log function evaluation score.
‘fes_std’: Mean standard deviation of normalized log function evaluation score.
‘cost_avg’: Mean log-inverse final cost.
‘cost_std’: Mean standard deviation of log-inverse final cost.
Notes:¶
Assumes that the input
resultsdictionary is structured with keys for ‘T1’, ‘T2’, ‘T0’, ‘fes’, and ‘cost’, each containing per-problem results for ‘Random_search’.Uses numpy for array operations and statistical calculations.
- gen_algorithm_complexity_table(results: dict, out_dir: str) None[source]¶
Introduction¶
Generates and saves an Excel table summarizing algorithm complexity metrics for different agents.
Args:¶
results (dict): The result data.Also a nested dictionary containing experimental results structured as
dict[metric][problem][algo][run].out_dir (str): The output directory where the Excel file will be saved.
Returns:¶
None
Details:¶
For each agent, the function computes the mean values of T1 and T2 across all problem names, calculates the ratio (T2-T1)/T0, and stores these metrics in a table. The resulting table is saved as ‘algorithm_complexity.xlsx’ in the specified output directory.
- gen_agent_performance_table(results: dict, out_dir: str) None[source]¶
Introduction¶
Generates and saves Excel tables summarizing the performance statistics of different agents on various problems. For each agent and problem, the function computes the Worst, Best, Median, Mean, and Standard Deviation (Std) of the final cost values across multiple runs, and stores these statistics in an Excel file.
Args:¶
results (dict): The result data.Also a nested dictionary containing experimental results structured as
dict[metric][problem][algo][run].out_dir (str): The directory path where the generated Excel files will be saved.
Returns:¶
None
Side Effects:¶
Writes one Excel file per agent to the specified output directory, each containing a table of performance statistics for all problems.
Raises:¶
KeyError: If the expected keys are missing in the
resultsdictionary.OSError: If there is an issue saving the Excel files to the specified directory.
- gen_overall_tab(results: dict, out_dir: str) None[source]¶
Introduction¶
Generates and stores an Excel table summarizing the overall results of optimization experiments, including objective values (costs), performance gap with CMAES, and consumed function evaluations (FEs) for each optimizer and problem.
Args:¶
results (dict): The result data.Also a nested dictionary containing experimental results structured as
dict[metric][problem][algo][run].out_dir (str): Directory path where the resulting Excel file (‘overall_table.xlsx’) will be saved.
Returns:¶
None
Raises:¶
KeyError: If expected keys are missing in the
resultsdictionary.AttributeError: If
self.config.test_runis not defined.ValueError: If the data shapes in
resultsdo not match expectations.
Notes:¶
The resulting Excel file contains a multi-indexed table with optimizers as rows and (problem, metric) pairs as columns.
Metrics include average and standard deviation of objective values, gap with CMAES, and function evaluations, all formatted for readability.
- aei_cost(cost_data: dict, baseline: dict, ignore: Optional[list] = None)[source]¶
Introduction¶
Calculates the Aggregated Evaluation Indicator (AEI) cost for different agents based on provided cost data and a baseline. Optionally ignores specified agents.
Args:¶
cost_data (dict): Part of the result data,the results[‘cost’]. Also a nested dictionary containing experimental results structured as
dict[problem][algorithm][run].baseline (dict): A dictionary containing baseline statistics, structured as ‘dict[metric]’.The metric includes ‘complexity_avg’, ‘complexity_std’, ‘fes_avg’, ‘fes_std’, ‘cost_avg’, and ‘cost_std’.
dict: A dictionary containing the following baseline statistics:
ignore (Optional[list]): A list of agent names to ignore during calculation. Defaults to None.
Returns:¶
results_cost (dict): A dictionary mapping each agent to their computed AEI cost values.
aei_mean (float): The mean AEI value across agents (excluding ignored ones).
aei_std (float): The standard deviation of AEI values across agents (excluding ignored ones).
- aei_fes(fes_data: dict, baseline: dict, maxFEs: Optional[Union[int, float]] = 20000, ignore: Optional[list] = None)[source]¶
Introduction¶
Computes the Aggregated Evaluation Indicator (AEI) for function evaluation steps (FEs) across multiple agents and problems, comparing them to a baseline. The method processes FEs data, applies logarithmic scaling, and calculates AEI statistics, optionally ignoring specified agents.
Args:¶
fes_data (dict):Part of the result data,the results[‘fes’].Also a nested dictionary containing experimental results structured as
dict[problem][algorithm][run].baseline (dict): A dictionary containing baseline statistics, structured as ‘dict[metric]’.The metric includes ‘complexity_avg’, ‘complexity_std’, ‘fes_avg’, ‘fes_std’, ‘cost_avg’, and ‘cost_std’.
maxFEs (Optional[Union[int, float]], default=20000): The maximum number of function evaluations allowed, used for normalization.
ignore (Optional[list], default=None): List of agent names to ignore during computation.
Returns:¶
results_fes (dict): Dictionary mapping each agent to their computed AEI values across problems.
aei_mean (float): Mean AEI value across all considered agents.
aei_std (float): Standard deviation of AEI values across all considered agents.
- aei_complexity(complexity_data: dict, baseline: dict, ignore: Optional[list] = None)[source]¶
Introduction¶
Calculates the AEI (Aggregated Evaluation Indicator) complexity for a set of agents based on provided complexity data and a baseline. The function computes a normalized complexity score for each agent, optionally ignoring specified agents, and returns the results along with the mean and standard deviation of the AEI.
Args:¶
complexity_data (dict):The result data,the results[‘fes’].Also a nested dictionary containing experimental results structured as
dict[problem][algorithm][run].ignore (Optional[list]): A list of agent keys to ignore during computation. Defaults to None.
Returns:¶
results_complex (dict): A dictionary mapping each agent to its computed complexity score.
aei_mean (float): The mean AEI value across all considered agents.
aei_std (float): The standard deviation of the AEI values.
Raises:¶
KeyError: If required keys are missing in
complexity_dataorbaseline.ValueError: If the input data shapes are inconsistent or invalid.
- cal_aei(results: dict, agents: dict, ignore: Optional[list] = None)[source]¶
Introduction¶
Calculates the mean and standard deviation of AEI (Aggregated Evaluation Indicator) values for a set of agents, with options to ignore certain agents and apply problem-specific scaling to the standard deviation.
Args:¶
results (dict): A dictionary mapping agent names to their corresponding AEI values (iterable or array-like), the value here is generated in aei_fes, aei_cost, or aei_complexity.
agents (dict): A dictionary of algorithm agent names.
ignore (Optional[list]): A list of agent names to be excluded from the calculation. Defaults to None.
Returns:¶
tuple: A tuple containing two dictionaries:
mean (dict): The mean AEI value for each agent.
std (dict): The standard deviation of AEI values for each agent, scaled according to the test problem.
Notes:¶
Agents named ‘Random_search’ are always ignored.
For test problems ‘protein’ or ‘protein-torch’, the standard deviation is multiplied by 5; otherwise, it is divided by 5.
- aei_metric(data: dict, maxFEs: Optional[Union[int, float]] = 20000, ignore: Optional[list] = None)[source]¶
Introduction¶
Calculates the AEI (Aggregated Evaluation Indicator) metric for a set of agents across multiple problems, based on cost, function evaluations, and complexity. The AEI metric is computed by combining normalized cost, function evaluation, and complexity metrics for each agent, excluding specified agents if required.
Args:¶
results (dict): The result data.Also a nested dictionary containing experimental results structured as
dict[metric][problem][algo][run].maxFEs (Optional[Union[int, float]], default=20000): The maximum number of function evaluations to consider for normalization.
ignore (Optional[list], default=None): A list of agent names to ignore in the AEI calculation.
Returns:¶
dict: A dictionary with two keys:
‘mean’: A dictionary mapping each agent to its mean AEI value.
‘std’: A dictionary mapping each agent to the standard deviation of its AEI value.
Notes:¶
The ‘Random_search’ agent and any agents listed in
ignoreare excluded from the results.For certain test problems (e.g., ‘protein’, ‘protein-torch’), the standard deviation is scaled differently.
- cec_metric(data: dict, ignore: Optional[list] = None)[source]¶
Introduction¶
Calculates the CEC metric for a set of optimization results, aggregating scores for different agents across multiple problems. The metric combines ranking and performance-based scores, optionally ignoring specified agents.
Args:¶
results (dict): The result data.Also a nested dictionary containing experimental results structured as
dict[metric][problem][algo][run].ignore (Optional[list]): A list of agent names to exclude from the metric calculation. Defaults to None.
Returns:¶
dict: A dictionary mapping agent labels to their computed CEC metric scores.
Notes:¶
The function expects the input
datato be structured with problems as keys, each containing agent results.Uses helper function
to_labelto standardize agent names andself.cal_scores1for part of the score calculation.
- draw_ECDF(data: dict, output_dir: str, Name: Optional[Union[str, list]] = None, pdf_fig: bool = True)[source]¶
Introduction¶
Plots Empirical Cumulative Distribution Functions (ECDF) for cost data of different agents across problems, and saves the figures to the specified output directory.
Args:¶
results (dict): The result data.Also a nested dictionary containing experimental results structured as
dict[metric][problem][algo][run].output_dir (str): The directory path where the ECDF plots will be saved.
Name (Optional[Union[str, list]], optional): The name(s) of the problem(s) to plot. If
None, plots for all problems. Defaults toNone.pdf_fig (bool, optional): If
True, saves figures as PDF; otherwise, saves as PNG. Defaults toTrue.
Returns:¶
None
Notes:¶
The method uses
self.color_arrangementto assign colors to agents and updates it if new agents are encountered.The method expects
to_label,colors,np, andpltto be available in the scope.
- draw_covergence_curve(agent: str, problem: str, metadata_dir: str, output_dir: str, pdf_fig: bool = True)[source]¶
Introduction¶
Plots the convergence curve of population diameter over optimization generations for a given agent and problem, using metadata from previous runs. The curve shows the mean and standard deviation of the population diameter across multiple test runs.
Args:¶
agent (str): The name of the agent whose convergence curve is to be plotted.
problem (str): The name of the optimization problem.
metadata_dir (str): Directory path where the metadata pickle file is stored.
output_dir (str): Directory path where the output plot will be saved.
pdf_fig (bool, optional): If True, saves the figure as a PDF; otherwise, saves as a PNG. Defaults to True.
Returns:¶
None
Raises:¶
FileNotFoundError: If the metadata file for the specified problem does not exist.
KeyError: If the specified agent is not found in the metadata.
Exception: For errors during file reading or plotting.
- draw_test_data(data: dict, data_type: str, output_dir: str, Name: Optional[Union[str, list]] = None, logged: bool = False, categorized: bool = False, pdf_fig: bool = True, data_wrapper: Callable = None) None[source]¶
Introduction¶
Plots and saves performance curves for test data of different agents on various problems, supporting both categorized and uncategorized visualizations, with options for logarithmic scaling and output format.
Args:¶
results (dict): Part of the result data,the result[data_type]. Also a nested dictionary containing experimental results structured as
dict[problem][algo][run].data_type (str): Label for the type of data being plotted (e.g., ‘cost’, ‘accuracy’).
output_dir (str): Directory path where the generated figures will be saved.
Name (Optional[Union[str, list]], optional): Specific problem name(s) to plot. If None, plots all problems. Defaults to None.
logged (bool, optional): If True, applies logarithmic scaling to the data before plotting. Defaults to False.
categorized (bool, optional): If True, separates plots into categories based on agent types (e.g., learnable vs. classic). Defaults to False.
pdf_fig (bool, optional): If True, saves figures as PDF; otherwise, saves as PNG. Defaults to True.
data_wrapper (Callable, optional): Optional function to preprocess or transform the data before plotting. Defaults to None.
Returns:¶
None
Notes:¶
The function uses matplotlib for plotting and saves figures to the specified output directory.
Color arrangements for agents are managed to ensure consistent coloring across plots.
When
categorizedis True, separate plots are generated for learnable and classic agent types.The function assumes the existence of
self.color_arrangement,self.arrange_index,self.config, and external variablescolorsandto_label.
- draw_named_average_test_costs(data: dict, output_dir: str, named_agents: dict, logged: bool = False, pdf_fig: bool = True) None[source]¶
Introduction¶
Plots and saves the average normalized test costs for multiple named agent groups across different problems. Each subplot corresponds to a group of agents, showing the mean and standard deviation of their normalized costs over function evaluations.
Args:¶
results (dict): Part of the result data.Also a nested dictionary containing experimental results structured as
dict[problem][algo][run].output_dir (str): Directory path where the resulting plot will be saved.
named_agents (dict): Dictionary mapping subplot titles to lists of agent names to be plotted in each subplot.
logged (bool, optional): If True, applies logarithmic scaling to the normalized costs. Defaults to False.
pdf_fig (bool, optional): If True, saves the figure as a PDF; otherwise, saves as PNG. Defaults to True.
Returns:¶
None
Notes:¶
The function normalizes costs by the initial value for each run.
Each agent’s mean and standard deviation curves are plotted with shaded error bands.
The function uses
self.color_arrangementandself.config.maxFEsfor color assignment and x-axis scaling, respectively.
- draw_concrete_performance_hist(data: dict, output_dir: str, Name: Optional[Union[str, list]] = None, pdf_fig: bool = True) None[source]¶
Introduction¶
Generates and saves bar plots representing the normalized performance (final cost divided by initial cost) of different agents on various problems. The plots are saved as either PDF or PNG files in the specified output directory.
Args:¶
results (dict): Part of the result data.Also a nested dictionary containing experimental results structured as
dict[problem][algo][run].output_dir (str): The directory path where the generated plots will be saved.
Name (Optional[Union[str, list]], optional): Specific problem name(s) to include in the plots. If None, all problems are included. Defaults to None.
pdf_fig (bool, optional): If True, saves plots as PDF files; otherwise, saves as PNG files. Defaults to True.
Returns:¶
None
Notes:¶
Each agent gets a separate bar plot.
The y-axis represents the mean normalized cost for each problem.
Plots are saved with filenames in the format ‘{agent}_concrete_performance_hist.{pdf|png}’.
- draw_boxplot(data: dict, output_dir: str, Name: Optional[Union[str, list]] = None, ignore: Optional[list] = None, pdf_fig: bool = True) None[source]¶
Introduction¶
Generates and saves boxplot visualizations of cost data for different agents and problems.
Args:¶
results (dict): The result data.Also a nested dictionary containing experimental results structured as
dict[metric][problem][algo][run].output_dir (str): The directory path where the generated boxplot figures will be saved.
Name (Optional[Union[str, list]], optional): Specific problem name(s) to plot. If
None, all problems in the data are plotted. Defaults toNone.ignore (Optional[list], optional): List of agent names to ignore when plotting. If
None, no agents are ignored. Defaults toNone.pdf_fig (bool, optional): If
True, saves figures as PDF files; otherwise, saves as PNG files. Defaults toTrue.
Returns:¶
None
Notes:¶
The function creates one boxplot per problem, with each agent represented on the x-axis.
The last column of each agent’s cost data is used for the boxplot.
Boxplots are saved to
output_dirwith filenames in the format{problem}_boxplot.{pdf|png}.
- draw_overall_boxplot(data: dict, output_dir: str, ignore: Optional[list] = None, pdf_fig: bool = True) None[source]¶
Introduction¶
Generates and saves a boxplot comparing the performance of different agents across multiple problems, using the final cost values from the provided data. The boxplot is normalized per problem and can be saved as either a PDF or PNG file.
Args:¶
results (dict): Part of the result data.Also a nested dictionary containing experimental results structured as
dict[problem][algo][run].output_dir (str): Directory path where the resulting boxplot image will be saved.
ignore (Optional[list], optional): List of agent names to exclude from the plot. Defaults to None.
pdf_fig (bool, optional): If True, saves the figure as a PDF; otherwise, saves as a PNG. Defaults to True.
Returns:¶
None
Notes:¶
The function normalizes the cost values for each problem before plotting.
The resulting boxplot displays agents on the x-axis and their normalized costs on the y-axis.
The plot includes mean and median markers, and outliers are not shown.
- draw_rank_hist(data: dict, random: dict, output_dir: str, ignore: Optional[list] = None, pdf_fig: bool = True) None[source]¶
Introduction¶
Plots a bar chart with error bars representing the AEI (Aggregated Evaluation Indicator) metric for different agents, and saves the figure to the specified output directory.
Args:¶
results (dict): The result data.Also a nested dictionary containing experimental results structured as
dict[metric][problem][algo][run].random (dict): Dictionary containing the random baseline data for comparison.
output_dir (str): Path to the directory where the output figure will be saved.
ignore (Optional[list], optional): List of agent names to ignore in the plot. Defaults to None.
pdf_fig (bool, optional): If True, saves the figure as a PDF; otherwise, saves as a PNG. Defaults to True.
Returns:¶
None: This method saves the plot to a file and does not return any value.
- draw_train_logger(data_type: str, steps: list, data: dict, agent_for_rollout: str, output_dir: str, ylabel: str = None, norm: bool = False, pdf_fig: bool = True, data_wrapper: Callable = None) None[source]¶
Introduction¶
Plots and saves the training curve for a given data type, applying smoothing and displaying mean and standard deviation shading. Supports normalization and custom data processing.
Args:¶
data_type (str): The type of data being plotted. e.g. cost
steps (list): List of step values (x-axis) corresponding to the data points.
results (dict): Part of the result data,the result[data_type]. Also a nested dictionary containing experimental results structured as
dict[problem][algo][run].output_dir (str): Directory path where the output figure will be saved.
ylabel (str, optional): Label for the y-axis. If None, uses
data_typeas the label. Defaults to None.norm (bool, optional): Whether to normalize the data before plotting. Defaults to False.
pdf_fig (bool, optional): Whether to save the figure as a PDF (if True) or PNG (if False). Defaults to True.
data_wrapper (Callable, optional): Optional function to preprocess or wrap the data before averaging. Defaults to None.
Returns:¶
None
Notes:¶
The function applies a smoothing operation to the plotted curve based on the configuration.
The mean and standard deviation are visualized, with the standard deviation shown as a shaded region.
The color arrangement for each agent is managed to ensure consistent coloring across plots.
- post_processing_test_statics(log_dir: str, include_random_baseline: bool = True, pdf_fig: bool = True) None[source]¶
Introduction¶
Post-processes test statistics by loading results, generating summary tables, and creating visualizations for algorithm performance evaluation.
Args:¶
log_dir (str): Directory path where test result files are stored and output files will be saved.
include_random_baseline (bool, optional): Whether to include a random baseline in the analysis. Defaults to True.
pdf_fig (bool, optional): Whether to save generated figures in PDF format. Defaults to True.
Returns:¶
None
Side Effects:¶
Reads test results from a pickle file in
log_dir.Creates directories for tables and figures if they do not exist.
Saves generated tables and figures to the corresponding directories.
Dumps additional metrics to a pickle file.
Raises:¶
FileNotFoundError: If the required test results file does not exist in
log_dir.Any exceptions raised by file I/O or pickle operations.
- post_processing_rollout_statics(log_dir: str, pdf_fig: bool = True) None[source]¶
Introduction¶
Processes rollout statistics after training, generates plots for return and cost, and saves them to the specified directory.
Args:¶
log_dir (str): The directory path where the rollout statistics file (‘rollout.pkl’) is located and where the output plots will be saved.
pdf_fig (bool, optional): Whether to save the generated plots as PDF files. Defaults to True.
Returns:¶
None
Raises:¶
FileNotFoundError: If the ‘rollout.pkl’ file does not exist in the specified directory.
KeyError: If expected keys (‘steps’, ‘return’, ‘cost’) are missing in the loaded results.
Exception: Propagates any exceptions raised during file I/O or plotting.
- class src.logger.MOO_Logger(config: argparse.Namespace)[source]¶
Bases:
src.logger.Basic_LoggerIntroduction¶
Custormized logger for Moo scenary.
Attributes¶
config (argparse.Namespace): Configuration namespace with parameters like maxFEs, indicators, agents.
color_arrangement (dict): Mapping of agents to colors for consistent plotting.
arrange_index (int): Index to track color assignment order.
indicators (list): List of performance indicators to log and plot.
Methods¶
init(config): Initializes logger with configuration.
is_pareto_efficient(points): Computes Pareto-efficient points from a set.
draw_pareto_fronts(data, output_dir, Name): Plots Pareto fronts for given problems.
draw_test_indicator(data, output_dir, indicator, Name, categorized, pdf_fig): Plots test indicator curves.
draw_named_average_test_indicator(data, output_dir, named_agents, indicator, pdf_fig): Plots average indicator curves for named agent groups.
draw_concrete_performance_hist(data, output_dir, indicator, Name, pdf_fig): Draws bar charts for final performance values.
draw_boxplot(data, output_dir, indicator, Name, ignore, pdf_fig): Generates boxplots for agent performances on each problem.
draw_overall_boxplot(data, output_dir, indicator, ignore, pdf_fig): Generates combined boxplot across all problems.
draw_train_logger(data_type, steps, data, agent_for_rollout, output_dir, ylabel, norm, pdf_fig, data_wrapper): Plots training metric curves with smoothing.
post_processing_test_statics(log_dir, include_random_baseline, pdf_fig): Processes test results and generates summary tables and figures.
post_processing_rollout_statics(log_dir, pdf_fig): Processes rollout statistics and generates plots.
Initialization
Introduction¶
Initializes the logger with the given configuration.
Args:¶
config (argparse.Namespace): Configuration namespace containing parameters like maxFEs, indicators, and agents.
Returns:¶
None
- is_pareto_efficient(points)[source]¶
Introduction¶
Determines the Pareto-efficient points from a given set of points. A point is considered Pareto-efficient if no other point is strictly better in all dimensions.
Args:¶
points (array-like): A 2D array or list of shape (n_points, n_dimensions) representing the set of points to evaluate.
Returns:¶
numpy.ndarray: An array containing the Pareto-efficient points.
Raises:¶
None
- draw_pareto_fronts(data: dict, output_dir: str, Name: Optional[Union[str, list]] = None)[source]¶
Introduction¶
Plots and saves the Pareto fronts for multiple algorithms on one or more optimization problems, supporting both 2D and 3D objective spaces. The function visualizes the final generation’s Pareto-efficient solutions for each algorithm and problem, and saves the resulting plots as PNG files.
Args:¶
data (dict): Nested dictionary containing optimization results structured as
dict[problem][algorithm][run].output_dir (str): Directory path where the generated Pareto front plots will be saved.
Name (Optional[Union[str, list]]): Specific problem name or list of problem names to plot. If
None, all problems indataare plotted.
Returns:¶
None
Notes:¶
The function expects each algorithm’s runs to be a list of generations, where each generation contains objective values.
The function uses
self.is_pareto_efficientto extract Pareto-efficient solutions.Plots are saved as PNG files named
{problem}_pareto_fronts.pngin the specified output directory.
- draw_test_indicator(data: dict, output_dir: str, indicator: str, Name: Optional[Union[str, list]] = None, categorized: bool = False, pdf_fig: bool = True) None[source]¶
Introduction¶
Plots and saves performance indicator curves for different agents based on the provided experimental data. Supports both categorized and non-categorized plotting, and can output figures in PDF or PNG format.
Args:¶
data (dict): Part of the result dictionary,mapping the indicator. Also a nested dictionary containing experimental results structured as
dict[problem][algorithm][run][generation][objective].output_dir (str): Directory path where the generated plots will be saved.
indicator (str): Name of the performance indicator to be plotted (e.g., accuracy, loss).
Name (Optional[Union[str, list]], optional): Specific problem name(s) to plot. If None, plots for all problems in
data. Defaults to None.categorized (bool, optional): If True, separates plots into learnable and classic agent categories. Defaults to False.
pdf_fig (bool, optional): If True, saves plots as PDF files; otherwise, saves as PNG files. Defaults to True.
Returns:¶
None
Notes:¶
The method uses
self.color_arrangementandself.arrange_indexto assign colors to agents.Requires
self.config.maxFEs,self.config.agent, andself.config.t_optimizerto be defined.Uses matplotlib for plotting and numpy for numerical operations.
The function saves plots to disk and does not display them interactively.
- draw_named_average_test_indicator(data: dict, output_dir: str, named_agents: dict, indicator: str, pdf_fig: bool = True) None[source]¶
Introduction¶
Plots the normalized average and standard deviation curves for a specified indicator across multiple agents and problems, grouping agents by provided names, and saves the resulting figure.
Args:¶
data (dict): Part of the result dictionary,mapping the indicator. Also a nested dictionary,structured as
dict[problem][algorithm][run][generation][objective],stores the test result data.output_dir (str): Directory path where the output figure will be saved.
named_agents (dict): Dictionary mapping group names (titles) to lists of agent names to be plotted together.
indicator (str): The key for the indicator to be plotted (e.g., ‘reward’, ‘cost’).
pdf_fig (bool, optional): If True, saves the figure as a PDF; otherwise, saves as a PNG. Defaults to True.
Returns:¶
None
Notes:¶
Normalizes indicator values for each problem across all agents to [0, 1] before plotting.
Plots mean and standard deviation curves for each agent, grouped by
named_agents.Uses internal color arrangement for agent curves.
Saves the figure as ‘all_problem_{indicator}_curve.{pdf|png}’ in the specified output directory.
- draw_concrete_performance_hist(data: dict, output_dir: str, indicator: Optional[str] = None, Name: Optional[Union[str, list]] = None, pdf_fig: bool = True) None[source]¶
Introduction¶
Generates and saves bar charts visualizing the concrete performance of different agents on various problems, based on the provided data. Each chart represents the mean performance of an agent across selected problems, with the option to filter by specific problem names and customize the output format.
Args:¶
data (dict) Part of the result dictionary,the results[indicator]. Also a nested dictionary,structured as
dict[problem][algorithm][run][generation][objective],stores the test result data.output_dir (str): The directory path where the generated figures will be saved.
indicator (Optional[str], default=None): The label for the y-axis, typically representing the performance metric being visualized.
Name (Optional[Union[str, list]], default=None): Specific problem name(s) to include in the visualization. If None, all problems are included.
pdf_fig (bool, default=True): If True, saves the figures as PDF files; otherwise, saves them as PNG files.
Returns:¶
None
Raises:¶
KeyError: If the specified problem or agent names are not found in the data dictionary.
IndexError: If the data arrays do not have the expected shape.
- draw_boxplot(data: dict, output_dir: str, indicator: str, Name: Optional[Union[str, list]] = None, ignore: Optional[list] = None, pdf_fig: bool = True) None[source]¶
Introduction¶
Generates and saves boxplot visualizations for the provided data, comparing the performance of different agents on specified problems.
Args:¶
data (dict):Part of the test result,that is, result[indicator].Also a nested dictionary,structured as
dict[problem][algorithm][run][generation][objective],stores the test result data.output_dir (str): The directory path where the generated boxplot figures will be saved.
indicator (str): The name of the indicator or metric to be displayed in the boxplot’s ylabel and filename.
Name (Optional[Union[str, list]], optional): Specific problem name(s) to plot. If None, plots all problems in
data. Defaults to None.ignore (Optional[list], optional): List of agent names to exclude from the plots. Defaults to None.
pdf_fig (bool, optional): If True, saves figures as PDF; otherwise, saves as PNG. Defaults to True.
Returns:¶
None
Notes:¶
Each boxplot compares the final column of results (assumed to be the last metric) for each agent on a given problem.
The function saves each plot to the specified output directory with a filename pattern:
{problem}_{indicator}_boxplot.{pdf/png}.
- draw_overall_boxplot(data: dict, output_dir: str, indicator: str, ignore: Optional[list] = None, pdf_fig: bool = True) None[source]¶
Introduction¶
Generates and saves a normalized boxplot comparing the performance of different agents across multiple problems for a specified indicator.
Args:¶
data (dict): Part of the test result,that is, result[indicator].Also a nested dictionary,structured as
dict[problem][algorithm][run][generation][objective],stores the test result data.output_dir (str): Directory path where the resulting boxplot image will be saved.
indicator (str): Name of the performance indicator to display on the plot’s y-axis and in the filename.
ignore (Optional[list], optional): List of agent names to exclude from the plot. Defaults to None.
pdf_fig (bool, optional): If True, saves the plot as a PDF; otherwise, saves as a PNG. Defaults to True.
Returns:¶
None
Notes:¶
The function normalizes the results for each problem before plotting.
The resulting boxplot visualizes the distribution of the final indicator values for each agent across all problems.
The plot is saved to the specified output directory with a filename indicating the indicator and file type.
- draw_train_logger(data_type: str, steps: list, data: dict, agent_for_rollout: str, output_dir: str, ylabel: str = None, norm: bool = False, pdf_fig: bool = True, data_wrapper: Callable = None) None[source]¶
Introduction¶
Plots and saves the training curve for a given data type, applying smoothing and displaying mean and standard deviation shading. Supports normalization and custom data processing.
Args:¶
data_type (str): The type of data being plotted. e.g. cost
steps (list): List of step values (x-axis) corresponding to the data points.
results (dict): Part of the result data,the result[data_type]. Also a nested dictionary containing experimental results structured as
dict[problem][algo][run].output_dir (str): Directory path where the output figure will be saved.
ylabel (str, optional): Label for the y-axis. If None, uses
data_typeas the label. Defaults to None.norm (bool, optional): Whether to normalize the data before plotting. Defaults to False.
pdf_fig (bool, optional): Whether to save the figure as a PDF (if True) or PNG (if False). Defaults to True.
data_wrapper (Callable, optional): Optional function to preprocess or wrap the data before averaging. Defaults to None.
Returns:¶
None
Notes:¶
The function applies a smoothing operation to the plotted curve based on the configuration.
The mean and standard deviation are visualized, with the standard deviation shown as a shaded region.
The color arrangement for each agent is managed to ensure consistent coloring across plots.
- post_processing_test_statics(log_dir: str, include_random_baseline: bool = False, pdf_fig: bool = True) None[source]¶
Introduction¶
Processes and visualizes test statistics from experiment logs, optionally including a random search baseline. Generates tables and figures summarizing algorithm performance.
Args:¶
log_dir (str): Directory path where the test results and output files are stored.
include_random_baseline (bool, optional): Whether to include results from a random search baseline. Defaults to False.
pdf_fig (bool, optional): Whether to save generated figures in PDF format. Defaults to True.
Returns:¶
None
Raises:¶
FileNotFoundError: If required result files (e.g., ‘test.pkl’) are not found in the specified directory.
Exception: For errors encountered during file reading, directory creation, or result processing.
- post_processing_rollout_statics(log_dir: str, pdf_fig: bool = True) None[source]¶
Introduction¶
Processes and visualizes the rollout statistics after training or evaluation.Loads the
rollout.pkllog file and generates plots for return and specified indicators.Args¶
log_dir (str): Directory path where the
rollout.pklfile is stored.pdf_fig (bool): Whether to save plots as PDF (True) or PNG (False). Default is True.
Returns¶
None
Notes¶
Saves all generated plots into a
pics/subdirectory inside the givenlog_dir.Uses
Basic_Logger.data_wrapper_cost_rolloutto wrap non-return indicators.
- class src.logger.MMO_Logger(config: argparse.Namespace)[source]¶
Bases:
src.logger.Basic_Logger#Introduction: The customized logger for multi-modal optimization(MMO) scenario.
Initialization
- data_wrapper_prsr_rollout(data)[source]¶
#Introduction: Wrapper function to extract pr/sr data for logging rollout results.
- data_wrapper_prsr_hist(data)[source]¶
#Introduction: Wrapper function to extract pr/sr historical information.
- data_wrapper_cost_rollout(data)[source]¶
#Introduction: Wrapper function to extract cost data for logging rollout results.
- gen_agent_performance_prsr_table(results: dict, data_type: str, out_dir: str) None[source]¶
Introduction¶
Generates and saves Excel tables summarizing the performance statistics (
Worst,Best,Median,Mean,Std) of different agents on various problems, based on the provided results.Args:¶
results (dict): Part of the result data,the result[data_type]. Also a nested dictionary,structured as
dict[problem][algorithm][run][generation][objective],stores the test result data.data_type (str): A string indicating the type of data being processed (used in the output filename).
out_dir (str): The directory path where the resulting Excel files will be saved.
Returns:¶
None
Notes:¶
For each agent, an Excel file is generated with a table of performance statistics for each problem.
The statistics are computed from the last pr/sr value of each run.
- gen_overall_tab(results: dict, out_dir: str) None[source]¶
Introduction¶
Generates and saves an Excel table summarizing the overall results of optimization experiments, including objective values (costs), precision (pr), and success rate (sr) for each optimizer and problem.
Args:¶
results (dict): The result data. Also a nested dictionary,structured as
dict[metric][problem][algo][run],stores the test result data.out_dir (str): The output directory path where the resulting Excel file (‘overall_table.xlsx’) will be saved.
Returns:¶
None: This method saves the results to an Excel file and does not return a value.
Raises:¶
KeyError: If the expected keys (‘cost’, ‘pr’, ‘sr’) or structure are missing in the
resultsdictionary.AttributeError: If
self.config.test_runis not defined in the class instance.ValueError: If the data shapes in
resultsdo not match the expected format for processing.
- draw_concrete_performance_prsr_hist(data: dict, data_type: str, output_dir: str, Name: Optional[Union[str, list]] = None, pdf_fig: bool = True) None[source]¶
Introduction¶
Generates and saves bar plots representing the normalized performance of different agents on various problems, based on the provided data. The function supports filtering by specific problem names and allows saving the figures in either PDF or PNG format.
Args:¶
data (dict):Part of the nested dictionary,the results[data_type].Also a nested dictionary,structured as
dict[problem][algorithm][run][generation][objective],stores the test result data.data_type (str): A string indicating the type of data being visualized (used for labeling the y-axis).
output_dir (str): Directory path where the generated figures will be saved.
Name (Optional[Union[str, list]], optional): Specific problem name or list of problem names to include in the plot. If None, all problems are included. Defaults to None.
pdf_fig (bool, optional): If True, saves figures as PDF; otherwise, saves as PNG. Defaults to True.
Returns:¶
None
Notes:¶
The function computes the mean of the last column of the performance data for each agent and problem.
Each agent’s performance is plotted as a separate bar chart, with values annotated on the bars.
The generated figures are saved to the specified output directory with filenames indicating the agent and data type.
- draw_boxplot_prsr(data: dict, data_type: str, output_dir: str, Name: Optional[Union[str, list]] = None, ignore: Optional[list] = None, pdf_fig: bool = True) None[source]¶
Introduction¶
Generates and saves boxplot visualizations for parsed result data of multiple agents on different problems. The function supports filtering by problem name, ignoring specific agents, and saving figures in PDF or PNG format.
Args:¶
data (dict): Part of the result data, the results[data_type].A nested dictionary where the first-level keys are problem names, and the second-level keys are agent names. The values are numpy arrays containing result data.
data_type (str): A string indicating the type of data being visualized (used in plot labels and filenames).
output_dir (str): The directory path where the generated boxplot figures will be saved.
Name (Optional[Union[str, list]], optional): A specific problem name or a list of problem names to plot. If None, all problems in
dataare plotted. Defaults to None.ignore (Optional[list], optional): A list of agent names to exclude from the plots. If None, no agents are ignored. Defaults to None.
pdf_fig (bool, optional): If True, saves figures as PDF files; otherwise, saves as PNG files. Defaults to True.
Returns:¶
None
Notes:¶
The function expects each value in
data[name][agent]to be a numpy array with at least four columns, as it accesses[:, -1, 3].Boxplots are saved with filenames formatted as
{problem_name}_{data_type}_boxplot.{pdf|png}in the specifiedoutput_dir.
- draw_overall_boxplot_prsr(data: dict, data_type: str, output_dir: str, ignore: Optional[list] = None, pdf_fig: bool = True) None[source]¶
Introduction¶
Generates and saves a boxplot comparing the performance of different agents across multiple problems using the provided data. The boxplot visualizes the distribution of the last metric (index 3) for each agent and problem, normalized per problem.
Args:¶
data (dict): Part of the result data, the results[data_type].Also a nested dictionary,structured as
dict[problem][algorithm][run][generation][objective],stores the test result data.data_type (str): A string indicating the type of data being visualized (used in plot labels and filenames).
output_dir (str): Directory path where the resulting boxplot figure will be saved.
ignore (Optional[list]): List of agent names to exclude from the plot. Defaults to None.
pdf_fig (bool): If True, saves the figure as a PDF; otherwise, saves as a PNG. Defaults to True.
Returns:¶
None
Notes:¶
The function normalizes the data for each problem before plotting.
The resulting boxplot shows the distribution for each agent, aggregated over all problems and runs.
The plot is saved as ‘overall_{data_type}_boxplot.{pdf|png}’ in the specified output directory.
- get_average_prsr_rank(results: dict)[source]¶
Introduction¶
Computes the average and standard deviation of the PRSR rank for each agent across multiple problems.
Args:¶
data (dict): Part of the result data, the results[data_type].Also a nested dictionary,structured as
dict[problem][algorithm][run][generation][objective],stores the test result data.
Returns:¶
tuple: A tuple containing two dictionaries:
avg_data (dict): Maps each agent to the mean PRSR rank averaged across all problems.
std_data (dict): Maps each agent to the mean standard deviation of PRSR rank across all problems.
Notes:¶
Assumes that all problems have the same set of agents and that the data structure for each agent is consistent across problems.
- draw_rank_hist_prsr(data: dict, data_type: str, output_dir: str, pdf_fig: bool = True) None[source]¶
Introduction¶
Generates and saves a bar plot with error bars representing the average PRSR (or similar metric) ranks for different agents, based on the provided data. The plot includes metric values, standard deviations, and agent labels, and is saved as either a PDF or PNG file.
Args:¶
data (dict): Part of the result data, the results[data_type].Also a nested dictionary,structured as
dict[problem][algorithm][run][generation][objective],stores the test result data.data_type (str): The type or name of the metric being visualized (e.g., ‘PRSR’).
output_dir (str): Directory path where the generated plot will be saved.
pdf_fig (bool, optional): If True, saves the figure as a PDF; otherwise, saves as a PNG. Defaults to True.
Returns:¶
None
Notes:¶
The method uses
self.get_average_prsr_rankto compute average metrics and standard deviations.The plot is customized with agent labels, error bars, and formatted text for clarity.
The output file is named using the
data_typeand saved in the specifiedoutput_dir.
- post_processing_test_statics(log_dir: str, pdf_fig: bool = True) None[source]¶
Introduction¶
Processes and visualizes test statistics from a results file, generating tables and plots for performance analysis.
Args:¶
log_dir (str): The directory path where the test results (
test.pkl) are stored and where output tables and figures will be saved.pdf_fig (bool, optional): Whether to save generated figures in PDF format. Defaults to True.
Returns:¶
None
Description:¶
This method loads test results from a pickle file, creates output directories if they do not exist, and generates a variety of tables and plots summarizing algorithm and agent performance. Outputs include overall statistics, algorithm complexity, agent performance tables, histograms, and boxplots for different metrics (cost, ‘pr’, ‘sr’). The method supports saving figures in PDF format if specified.
Raises:¶
FileNotFoundError: If the specified
test.pklfile does not exist inlog_dir.Any exceptions raised by the called table and plotting methods.
- class src.logger.MTO_Logger(config)[source]¶
Bases:
src.logger.Basic_LoggerIntroduction¶
The customized logger for multi-task optimization(MTO) scenario.
Initialization
- draw_avg_train_return(data: list, output_dir: str) None[source]¶
Introduction¶
Plots and saves the average training return over learning steps using the provided data.
Args:¶
data (list): A list of lists or arrays containing return values for each epoch and environment.
output_dir (str): The directory path where the output plot image will be saved.
Returns:¶
None
Notes:¶
The plot is saved as ‘avg_mto_return.png’ in the specified output directory.
- draw_avg_train_cost(data: list, output_dir: str) None[source]¶
Introduction¶
Plots and saves the average training cost over learning steps using the provided cost data.
Args:¶
data (list): A list representing cost data with shape [epochs, env_cnt, task_cnt].
output_dir (str): The directory path where the output plot image will be saved.
Returns:¶
None
Notes:¶
The function computes the mean cost across environments and tasks for each epoch, plots the result, and saves the figure as ‘avg_mto_cost.png’ in the specified output directory.
- draw_per_task_cost(data: list, output_dir: str) None[source]¶
Introduction¶
Plots and saves the cost (or value) curves for each task over epochs, given a dataset of per-task values.
Args:¶
data (list): A list or nested list containing per-task values for each epoch. Can be a 2D or 3D structure.
output_dir (str): The directory path where the output plot image will be saved.
Returns:¶
None
Notes:¶
If
datais 3D, it is averaged along the second axis before plotting.The function generates one subplot per task, showing the value progression over epochs.
The output image is saved as ‘mto_each_task_cost.png’ in the specified directory.
- save_mto_cost_to_csv(data: list, output_dir: str) None[source]¶
Introduction¶
Saves multi-task optimization (MTO) cost data to a CSV file, optionally averaging over a specific axis if the input data is 3-dimensional.
Args:¶
data (list): A list (or nested list) containing cost values for each task and epoch. Can be 2D or 3D (in which case it is averaged over axis 1).
output_dir (str): The directory path where the CSV file will be saved.
Returns:¶
None
Notes:¶
The output CSV file will be named ‘mto_each_task_cost.csv’ and will contain columns for each task and an ‘Epoch’ column.
- save_mto_reward_to_csv(data: list, output_dir: str) None[source]¶
Introduction¶
Saves the mean of multi-task optimization (MTO) reward data to a CSV file. The function processes the input data, computes the mean across the last axis if the data is 2-dimensional, and writes the results to a CSV file with epoch indices.
Args:¶
data (list): A list (or nested list) of reward values, where each element represents reward data for an epoch or task.
output_dir (str): The directory path where the output CSV file will be saved.
Returns:¶
None
Notes:¶
The output CSV file will be named ‘mto_return.csv’ and will contain two columns: ‘Epoch’ and ‘Value’.
If the input data is 2D, the mean is computed along the last axis before saving.
- draw_env_task_cost(data: list, output_dir: str) None[source]¶
Introduction¶
Plots and saves the performance metrics of multiple tasks across different environments over epochs.
Args:¶
data (list): A 3D list or array-like structure with shape (epochs, env_cnt, task_cnt), containing metric values.
output_dir (str): The directory path where the generated plot images will be saved.
Returns:¶
None
Notes:¶
For each task, a separate plot is generated showing the metric values for all environments across epochs.
Plots are saved as PNG files in the specified output directory, with filenames indicating the corresponding task.
If the input data has fewer than 3 dimensions, the function returns without plotting.
- draw_test_cost(data: dict, output_dir: str)[source]¶
Introduction¶
Plots and saves the performance metrics of different algorithms and problems.
Args:¶
data (dict): A dict contains a 3D list or an array-like structure for each algorithm and problem with shape (test_epoch, log_point, task), containing metric values.
output_dir (str): The directory path where the generated plot images will be saved.
Returns:¶
None
Notes:¶
For each algorithm and problem, a separate plot is generated showing the metric values.
Plots are saved as PNG files in the specified output directory, with filenames indicating the corresponding task.
- post_processing_test_statics(log_dir: str) None[source]¶
Introduction¶
Post-processes test statistics by loading results, generating summary tables, and creating visualizations for algorithm performance evaluation.
Args:¶
log_dir (str): The directory path where the plot images generated from test datas will be saved.
Returns:¶
None
- static data_wrapper_mto_cost_rollout(data)[source]¶
Introduction¶
Reshape the MTO rollout datas from 3D to 2D.
Args:¶
data (list): A 3D list or array-like structure containing rollout datas to be reshaped.
Returns:¶
numpy.ndarray: A 2D reshaped rollout datas.
- draw_train_logger(data_type: str, steps: list, data: dict, agent_for_rollout: str, output_dir: str, ylabel: str = None, norm: bool = False, pdf_fig: bool = True, data_wrapper: Callable = None) None[source]¶
Introduction¶
Plots and saves the training curve for a given data type, applying smoothing and displaying mean and standard deviation shading. Supports normalization and custom data processing.
Args:¶
data_type (str): The type of data being plotted. e.g. cost
steps (list): List of step values (x-axis) corresponding to the data points.
agent_for_rollout (str): A string represents the agent during the rollout process.
data (dict): Part of the result data,the result[data_type]. Also a nested dictionary containing experimental datas structured as
dict[problem][algo][run].output_dir (str): Directory path where the output figure will be saved.
ylabel (str, optional): Label for the y-axis. If None, uses
data_typeas the label. Defaults to None.norm (bool, optional): Whether to normalize the data before plotting. Defaults to False.
pdf_fig (bool, optional): Whether to save the figure as a PDF (if True) or PNG (if False). Defaults to True.
data_wrapper (Callable, optional): Optional function to preprocess or wrap the data before averaging. Defaults to None.
Returns:¶
None
Notes:¶
The function applies a smoothing operation to the plotted curve based on the configuration.
The mean and standard deviation are visualized, with the standard deviation shown as a shaded region.
The color arrangement for each agent is managed to ensure consistent coloring across plots.
- post_processing_rollout_statics(log_dir: str, pdf_fig: bool = True) None[source]¶
Introduction¶
Processes rollout statistics after the rollout process, generates plots for return and cost, and saves them to the specified directory.
Args:¶
log_dir (str): The directory path where the rollout statistics file (‘rollout.pkl’) is located and where the output plots will be saved.
pdf_fig (bool, optional): Whether to save the generated plots as PDF files. Defaults to True.
Returns:¶
None