rtac.ac_functionalities.tournament

This module contains classes implementing problem instance solving tournaments by differently configured target algorithms according to the RTAC method utilized.

Functions

tournament_factory(scenario, ta_runner, ...)

Class factory to return the initialized TournamentManager class appropriate to the RTAC method scenario.ac.

Classes

AbstractTournament(scenario, ta_runner, ...)

Abstract class for tournaments.

Tournament(scenario, ta_runner, rtac_data, logs)

Tournament class with functions needed for ReACTR method tournaments.

Tournament_GB()

Class that contains gray-box tournament functions to be inserted into tournament classes if scenario.gray_box is True.

Tournamentpp(scenario, ta_runner, rtac_data, ...)

Tournament class with functions needed for ReACTR method tournaments.

class rtac.ac_functionalities.tournament.AbstractTournament(scenario: Namespace, ta_runner: BaseTARunner, rtac_data: RTACData | RTACDatapp, logs: RTACLogs)[source]

Bases: ABC

Abstract class for tournaments.

Parameters:
  • scenario (argparse.Namespace) – Namespace containing all settings for the RTAC.

  • ta_runner (BaseTARunner) – Target algorithm runner object.

  • rtac_data (RTACData | RTACDatapp) – Object containing data and objects necessary throughout the RTAC modules.

  • logs (RTACLogs) – Object containing loggers and logging functions.

close_tournament() None[source]

Initiates termination of all target algorithm runs.

Return type:

None

pid_alive(pid) None[source]

Checks if process is till alive using PID.

Parameters:

pid (int) – Unique identifier for process.

Return type:

None

abstract start_tournament(instance: str, contender_dict: dict[slice(<class 'str'>, <class 'rtac.ac_functionalities.rtac_data.Configuration'>, None)], tourn_nr: int) None[source]

Sets up tournament data and information and starts the tournament with scenario.number_cores configured target algorithms running in parallel, using settings according to the RTAC method.

Parameters:
  • instance (str) – Path to the problem instance to solve.

  • contender_dict (dict[str, Configuration]) – Dictionary containing configurations to run in the tournament, with configuration IDs as keys and Configuration objects as values.

  • tourn_nr (int) – Number of the tournament during this RTAC run.

Return type:

None

terminate_run(core: int, process: Popen) None[source]

Enforces termination of a target algorithm run.

Parameters:
  • core (int) – Index of the process in the list of processes.

  • process (subprocess.Popen) – Target algorithm run process to terminate.

Return type:

None

abstract watch_tournament() None[source]

Function to observe the tournament and enforce the timelimit scenario.timeout if reached according to the RTAC method used.

Return type:

None

class rtac.ac_functionalities.tournament.Tournament(scenario: Namespace, ta_runner: BaseTARunner, rtac_data: RTACData | RTACDatapp, logs: RTACLogs)[source]

Bases: AbstractTournament

Tournament class with functions needed for ReACTR method tournaments.

fill_tournament(cores_start: list[int]) None[source]

Fills up the remaining cores to be used in an early started tournament.

Parameters:

cores_start (list[int]) – List of cores which to start the contenders on.

Return type:

None

start_tournament(instance: str, contender_dict: dict[slice(<class 'str'>, <class 'rtac.ac_functionalities.rtac_data.Configuration'>, None)], tourn_nr: int, cores_start: list[int]) None[source]

Sets up tournament data and starts the tournament with scenario.number_cores configured target algorithms running in parallel according to the ReACTR method.

Parameters:
  • instance (str) – Path to the problem instance to solve.

  • contender_dict (dict[str, Configuration]) – Dictionary containing configurations to run in the tournament, with configuration IDs as keys and Configuration objects as values.

  • tourn_nr (int) – Number of the tournament during this RTAC run.

  • cores_start (list[int]) – List of cores which to start the contenders on.

Return type:

None

watch_tournament() None[source]

Function to observe the tournament and enforce the timelimit scenario.timeout if reached.

Return type:

None

class rtac.ac_functionalities.tournament.Tournament_GB[source]

Bases: object

Class that contains gray-box tournament functions to be inserted into tournament classes if scenario.gray_box is True.

watch_tournament_gray_box(early_tournament=False) None[source]

Function to observe the tournament and enforce the timelimit scenario.timeout if reached.

Parameters:

early_tournament (bool) – True if tournament is early starter, False if not.

Return type:

None

class rtac.ac_functionalities.tournament.Tournamentpp(scenario: Namespace, ta_runner: BaseTARunner, rtac_data: RTACData | RTACDatapp, logs: RTACLogs)[source]

Bases: Tournament

Tournament class with functions needed for ReACTR method tournaments.

rtac.ac_functionalities.tournament.tournament_factory(scenario: Namespace, ta_runner: BaseTARunner, rtac_data: RTACData | RTACDatapp, logs: RTACLogs) Tournament | Tournamentpp[source]

Class factory to return the initialized TournamentManager class appropriate to the RTAC method scenario.ac.

Parameters:
  • scenario (argparse.Namespace) – Namespace containing all settings for the RTAC.

  • ta_runner (BaseTARunner) – Target algorithm runner object.

  • rtac_data (RTACData | RTACDatapp) – Object containing data and objects necessary throughout the RTAC modules.

  • logs (RTACLogs) – Object containing loggers and logging functions.

Returns:

Initialized Tournament object matching the RTAC method of the scenario.

Return type:

Tournament or Tournamentpp