rtac.ac_functionalities.ta_runner
In this module classes to run the target algorithm and observe its output through the wrapper are implemented.
Functions
|
Records runtime output of the target algorithm if there was any new. |
|
Function for reading subprocess.PIPE output without blocking the application until there is output. |
|
Class factory to return the initialized target algorithm runner class appropriate to the RTAC method specified in scenario.ac. |
Classes
|
Abstract TARunner. |
|
Target algorithm runner for ReACTR implementation. |
|
Target algorithm runner for ReACTR++ implementation. |
- class rtac.ac_functionalities.ta_runner.AbstractTARunner(scenario: Namespace, logs: RTACLogs, core: int)[source]
Bases:
ABCAbstract TARunner.
- Parameters:
scenario (argparse.Namespace) – Namespace containing all settings for the RTAC.
logs (RTACLogs) – Object containing loggers and logging functions.
core (int) – Number of the parallel run started on a core.
- abstract check_output(ta_output: bytes) None[source]
Checks the output, if there was any, and declares the instance as solved by the contender if the corresponding marker is present.
- Parameters:
ta_output (bytes) – Output from subprocess.PIPE.
- Return type:
None
- abstract check_result() None[source]
If this contender solved the problem instance the rtac data is populated by the resulting information according to the RTAC method scenario.ac.
- Return type:
None
- abstract kill_run() None[source]
Terminates this process/ target algorithm run, as well as the other contenders. Several layers of termination are included to ensure termination on different platforms.
- Return type:
None
- abstract run(instance: str, config: Configuration, rtac_data: RTACData | RTACDatapp) None[source]
Manages the target algorithm runner functions depending on the state of the run, according to the RTAC method specified in scenario.ac.
- Parameters:
instance (str) – Path to the problem instance to solve.
config (Configuration) – Configuration of parameter values to run the problem instance with.
rtac_data (RTACData | RTACDatapp) – Object containing data and objects necessary throughout the RTAC modules.
- Return type:
None
- abstract start_run(instance: str, config: Configuration, rtac_data: RTACData | RTACDatapp) None[source]
Starts the target algorithm run and populates data necessary for coronation of tournament members.
- Parameters:
instance (str) – Path to the problem instance to solve.
config (Configuration) – Representation of the configuration.
rtac_data (RTACData | RTACDatapp) – Object containing data and objects necessary throughout the RTAC modules.
- Return type:
None
- abstract translate_config(config: Configuration) Any[source]
Convert dictionary representation of the configuration to the format needed by the wrapper to pass to the target algorithm.
- Parameters:
config (Configuration) – Configuration of parameter values to run the problem instance with.
- Returns:
New representation of the configuration suitable for the target algorithm.
- Return type:
Any
- class rtac.ac_functionalities.ta_runner.BaseTARunner(scenario: Namespace, logs: RTACLogs, core: int)[source]
Bases:
AbstractTARunnerTarget algorithm runner for ReACTR implementation.
- Parameters:
scenario (argparse.Namespace) – Namespace containing all settings for the RTAC.
logs (RTACLogs) – Object containing loggers and logging functions.
core (int) – Identifier for the parallel run on a specific core.
- check_output(ta_output: bytes) None[source]
Checks the output, if there was any, and declares the instance as solved by the contender if the corresponding marker is present.
- Parameters:
ta_output (bytes) – Output from subprocess.PIPE.
- Return type:
None
- check_result() None[source]
If this contender solved the problem instance the rtac data is populated by the resulting information.
- Return type:
None
- kill_run() None[source]
Terminates this process/ target algorithm run, as well as the other contenders. Several layers of termination are included to ensure termination on different platforms.
- Return type:
None
- run(instance: str, config: Configuration, rtac_data: RTACData | RTACDatapp, sync_event: Event) None[source]
Manages the target algorithm runner functions depending on the state of the run.
- Parameters:
instance (str) – Path to the problem instance to solve.
config (Configuration) – Configuration of parameter values to run the problem instance with.
rtac_data (RTACData | RTACDatapp) – Object containing data and objects necessary throughout the RTAC modules.
- Return type:
None
- start_run(instance: str, config: Any, rtac_data: RTACData | RTACDatapp) None[source]
Starts the target algorithm run and populates data necessary for coronation of tournament members.
- Parameters:
instance (str) – Path to the problem instance to solve.
config (Any) – Representation of the configuration.
rtac_data (RTACData | RTACDatapp) – Object containing data and objects necessary throughout the RTAC modules.
- Return type:
None
- translate_config(config: Configuration) Any[source]
Convert dictionary representation of the configuration to the format needed by the wrapper to pass to the target algorithm.
- Parameters:
config (Configuration) – Configuration of parameter values to run the problem instance with.
- Returns:
New representation of the configuration.
- Return type:
Any
- class rtac.ac_functionalities.ta_runner.TARunnerpp(scenario: Namespace, logs: RTACLogs, core: int)[source]
Bases:
BaseTARunnerTarget algorithm runner for ReACTR++ implementation.
- Parameters:
scenario (argparse.Namespace) – Namespace containing all settings for the RTAC.
logs (RTACLogs) – Object containing loggers and logging functions.
core (int) – Identifier for the parallel run on a specific core.
- check_output(ta_output: bytes) None[source]
Checks the output, if there was any, and either declares the instance as solved by the contender (if the corresponding marker is present) or outputs intermediate target algorithm output.
- Parameters:
ta_output (bytes) – Output from subprocess.PIPE.
- Return type:
None
- rtac.ac_functionalities.ta_runner.gb_record(self, ta_output: bytes) None[source]
Records runtime output of the target algorithm if there was any new.
- Parameters:
ta_output (bytes) – Output from subprocess.PIPE.
- Return type:
None
- rtac.ac_functionalities.ta_runner.non_block_read(ta_output: bytes, logs: RTACLogs | None = None) str[source]
Function for reading subprocess.PIPE output without blocking the application until there is output. It checks for output and exits immediately if none is available.
- Parameters:
ta_output (bytes) – subprocess.PIPE output to be read.
logs (RTACLogs) – Object containing loggers and logging functions. Defaults to None.
- Returns:
Either the output as a string or an empty string if no output was available.
- Return type:
str
- rtac.ac_functionalities.ta_runner.ta_runner_factory(scenario: Namespace, logs: RTACLogs, core: int) BaseTARunner | TARunnerpp[source]
Class factory to return the initialized target algorithm runner class appropriate to the RTAC method specified in scenario.ac.
- Parameters:
scenario (argparse.Namespace) – Namespace containing all settings for the RTAC.
logs (RTACLogs) – Object containing loggers and logging functions.
core (int) – Number of the parallel run started on a core.
- Returns:
Initialized target algorithm runner object matching the RTAC method of the scenario.
- Return type: