rtac.ac_functionalities.result_processing
In this module results of the tournaments are processed and computations for the next tournament ar performed.
Functions
|
Class factory to return the initialized class with data structures appropriate to the RTAC method scenario.ac. |
Classes
|
Abstract class with functions to process tournament results. |
Helper object for setting trueskill ranks. |
|
|
Processes results of previous tournament. |
|
Process results of previous tournament. |
|
Process results of prvious tournament. |
- class rtac.ac_functionalities.result_processing.AbstractResultProcessing(scenario: Namespace, logs: RTACLogs)[source]
Bases:
ABCAbstract class with functions to process tournament results.
- Parameters:
scenario (argparse.Namespace) – Namespace containing all settings for the RTAC.
logs (RTACLogs) – Object containing loggers and logging functions.
- get_contender_dict() dict[slice(<class 'str'>, <class 'rtac.ac_functionalities.rtac_data.Configuration'>, None)][source]
Returns contender_dict.
- Returns:
Configuration selected to run in next tournament/on next problem instance. Dictionary with configuration id as key and Configuration object as value.
- Return type:
dict[str, Configuration]
- init_data() dict[slice(<class 'str'>, <class 'rtac.ac_functionalities.rtac_data.Configuration'>, None)][source]
Initialize tournament result processing data according to ReACTR implementation.
- Returns:
Randomly selected contenders.
- Return type:
dict[str, Configuration]
- abstract process_results(rtac_data: RTACData | RTACDatapp, instance: str | None = None, tourn_nr: int | None = None) None[source]
Perform tournament result processing necessary to replace contenders in pool and select contenders for next tournament/problem instance.
- Parameters:
rtac_data (RTACData | RTACDatapp) – Object containing data and objects necessary throughout the rtac modules.
instance (str) – ID of the problem instance. Defaults to None.
tourn_nr (int) – Tournament number. Defaults to None.
- Return type:
None
- process_tourn(rtac_data: RTACData | RTACDatapp, instance: str | None = None, tourn_nr: int | None = None) str | None[source]
Manage result processing.
- rtac_data: RTACData | RTACDatapp
Object containing data and objects necessary throughout the RTAC modules.
- instancestr
ID of the configuration to have won the previous tournament. Defaults to None.
- tourn_nr: int
Number of the tournament that is processed.
- Returns:
ID of the winner or None if problem instance could not be solved.
- Return type:
str or None
- result_summary_terminal(results: list[float], tourn_nr: int | None = None) None[source]
Print the sum of the winner results of all tournaments so far.
- Parameters:
results (list[float]) – List of results of previous tournament.
tourn_nr (int) – Number of previous tournament. Defaults to None.
- Return type:
None
- class rtac.ac_functionalities.result_processing.Contender[source]
Bases:
objectHelper object for setting trueskill ranks.
- class rtac.ac_functionalities.result_processing.ResultProcessing(scenario: Namespace, logs: RTACLogs)[source]
Bases:
AbstractResultProcessingProcesses results of previous tournament.
Note
Implementation based on the paper: “ReACTR: Realtime Algorithm Configuration through Tournament Rankings”
- Parameters:
scenario (argparse.Namespace) – Namespace containing all settings for the RTAC.
logs (RTACLogs) – Object containing loggers and logging functions.
- find_best(current_dict: list, number: int) list[source]
Find the configurations scored as best by trueskill.
- Parameters:
current_dict (list) – Dictionary with configuration ids as key and trueskill scores (mu, sigma) as value.
n_best (int) – Number of best configurations to draw.
- Returns:
List of best configurations.
- Return type:
list
- get_winner(times: list[float], res: list[float]) tuple[int, list[int]][source]
Get index of the winning configuration and ranks.
- Parameters:
times (list[float]) – List of time results of previous tournament.
res (list[float]) – List of objective results of previous tournament.
- Returns:
winner : int, Index of the winner.
ranks : list[int], Ranks of the contenders.
- Return type:
tuple
- manage_pool() None[source]
Replace contenders in pool according to Mu and Sigma (TrueSKill).
- Return type:
None
- process_results(rtac_data: RTACData | RTACDatapp, instance: str | None = None, tourn_nr: int | None = None) None[source]
Perform tournament result processing necessary to replace contenders in the pool and select contenders for the next tournament/problem instance according to the ReACTR implementation.
- Parameters:
rtac_data (RTACData | RTACDatapp) – Object containing data and objects necessary throughout the rtac modules.
instance (str) – ID of the configuration to have won the previous tournament. Defaults to None.
tourn_nr (int) – Number of the tournament that is processed.
- Return type:
None
- class rtac.ac_functionalities.result_processing.ResultProcessingCPPL(scenario: Namespace, logs: RTACLogs)[source]
Bases:
AbstractResultProcessingProcess results of previous tournament.
- Parameters:
scenario (argparse.Namespace) – Namespace containing all settings for the RTAC.
logs (RTACLogs) – Object containing loggers and logging functions.
- cppl_manage_pool(contender_dict: dict[str, rtac.ac_functionalities.rtac_data.Configuration], queue: Queue) None[source]
Replace contenders in pool if necessary. Runs in separate thread.
- Parameters:
contender_dict (dict[str, Configuration]) – List of contenders in the upcoming tournament. Loaded from logas or randomly selected.
queue (multiprocessing.Queue) – Queue to send data back to main thread.
- Return type:
None
- cppl_process_results(contender_dict: dict[str, rtac.ac_functionalities.rtac_data.Configuration], scenario: Namespace, rtac_data: RTACData | RTACDatapp, instance: str, pool: dict[str, rtac.ac_functionalities.rtac_data.Configuration], ob: bool, queue: Queue) None[source]
Perform tournament result processing necessary to replace contenders in the pool and select contenders for the next tournament/problem instance within a separate thread.
- Parameters:
contender_dict (dict[str, Configuration]) – List of contenders in the upcoming tournament. Loaded from logas or randomly selected.
scenario (argparse.Namespace) – Namespace containing all settings for the RTAC.
rtac_data (RTACData | RTACDatapp) – Object containing data and objects necessary throughout the rtac modules.
instance (str) – ID of the configuration to have won the previous tournament. Defaults to None.
pool (dict[str, Configuration]) – Initial pool of Configurations. Loaded from logas or randomly generated.
ob (bool) – True if scenario is objective value minimization, False if not.
queue (multiprocessing.Queue) – Queue to send data back to main thread.
- Return type:
None
- cppl_select_contenders(queue: Queue) None[source]
Select contenders for next tournament/problem instance.
- Parameters:
queue (multiprocessing.Queue) – Queue to send data back to main thread.
- Return type:
None
- init_cppl(scenario: Namespace, pool: dict[str, rtac.ac_functionalities.rtac_data.Configuration], random_config_gen: RandomConfigGen, contender_dict: dict[str, rtac.ac_functionalities.rtac_data.Configuration], queue: Queue) None[source]
Initialize cppl in isolated mode. The bandit functions are called and executed in a separate thread so no build up in background threads of libraries that numpy, scipy and sklearn depend on is possible.
- Parameters:
scenario (argparse.Namespace) – Namespace containing all settings for the RTAC.
pool (dict[str, Configuration]) – Initial pool of Configurations. Loaded from logas or randomly generated.
random_config_gen (RandomConfigGen) – Random configuration generator.
contender_dict (dict[str, Configuration]) – List of contenders in the upcoming tournament. Loaded from logas or randomly selected.
queue (multiprocessing.Queue) – Queue to send data back to main thread.
- Return type:
None
- process_results(rtac_data: RTACData | RTACDatapp, instance: str | None = None, tourn_nr: int | None = None) None[source]
Perform tournament result processing necessary to replace contenders in the pool and select contenders for the next tournament/problem instance.
- Parameters:
rtac_data (RTACData | RTACDatapp) – Object containing data and objects necessary throughout the rtac modules.
instance (str) – ID of the configuration to have won the previous tournament. Defaults to None.
tourn_nr (int) – Number of the tournament that is processed.
- Return type:
None
- process_tourn(rtac_data: RTACData | RTACDatapp, instance: str | None = None, tourn_nr: int | None = None) str[source]
Manage result processing.
- Parameters:
rtac_data (RTACData | RTACDatapp) – Object containing data and objects necessary throughout the rtac modules.
instance (str) – ID of the configuration to have won the previous tournament. Defaults to None.
tourn_nr (int) – Number of the tournament that is processed. Defaults to None.
- Returns:
ID of the configuration to have won the previous tournament.
- Return type:
str
- class rtac.ac_functionalities.result_processing.ResultProcessingpp(scenario: Namespace, logs: RTACLogs)[source]
Bases:
ResultProcessingProcess results of prvious tournament.
- duplicates(ranks: list[int], rank: float) list[int][source]
List the indices of the result in the results list.
- Parameters:
ranks (list[int]) – List of objective results of previous tournament.
rank (float) – A single result.
- Returns:
List of indices of this result in the results list.
- Return type:
list[int]
- get_winner(times: list[float], res: list[float]) tuple[int, list[int]][source]
Get index of the winning configuration including last known intermediate outputs to break ties. Additionally outputs complete ranking to compute more detailed assessment with trueskill.
- Parameters:
times (list[float]) – List of time results of previous tournament.
res (list[float]) – List of objective results of previous tournament.
- Returns:
winner : int, Index of the winner.
ranks : list[int], Ranks of the contenders..
- Return type:
tuple
- rtac.ac_functionalities.result_processing.processing_factory(scenario: Namespace, logs: RTACLogs) ResultProcessing | ResultProcessingpp | ResultProcessingCPPL[source]
Class factory to return the initialized class with data structures appropriate to the RTAC method scenario.ac.
- Parameters:
scenario (argparse.Namespace) – Namespace containing all settings for the RTAC.
logs (RTACLogs) – Object containing loggers and logging functions.
- Returns:
Initialized BaseTARunner object matching the RTAC method of the scenario.
- Return type:
ResultProcessing or ResultProcessingpp or ResultProcessingCPPL