smac.tae.execute_func module

class smac.tae.execute_func.AbstractTAFunc(ta: Callable, stats: smac.stats.stats.Stats, run_obj: str = 'quality', memory_limit: Optional[int] = None, par_factor: int = 1, cost_for_crash: float = 2147483647.0, abort_on_first_run_crash: bool = False, use_pynisher: bool = True)[source]

Bases: smac.tae.serial_runner.SerialRunner

Baseclass to execute target algorithms which are python functions.

Note:* Do not use directly

memory_limit
use_pynisher
_abc_impl = <_abc_data object>
_call_ta(obj: Callable, config: ConfigSpace.configuration_space.Configuration, obj_kwargs: Dict[str, Optional[Union[int, str, float]]]) → Union[float, Tuple[float, Dict]][source]
run(config: ConfigSpace.configuration_space.Configuration, instance: Optional[str] = None, cutoff: Optional[float] = None, seed: int = 12345, budget: Optional[float] = None, instance_specific: str = '0') → Tuple[smac.tae.StatusType, float, float, Dict][source]

Runs target algorithm <self._ta> with configuration <config> for at most <cutoff> seconds, allowing it to use at most <memory_limit> RAM.

Whether the target algorithm is called with the <instance> and <seed> depends on the subclass implementing the actual call to the target algorithm.

Parameters
  • config (Configuration, dictionary (or similar)) – Dictionary param -> value

  • instance (str, optional) – Problem instance

  • cutoff (float, optional) – Wallclock time limit of the target algorithm. If no value is provided no limit will be enforced. It is casted to integer internally.

  • seed (int) – Random seed

  • budget (float, optional) – A positive, real-valued number representing an arbitrary limit to the target algorithm Handled by the target algorithm internally

  • instance_specific (str) – Instance specific information (e.g., domain file or solution)

Returns

  • status (enum of StatusType (int)) – {SUCCESS, TIMEOUT, CRASHED, ABORT}

  • cost (float) – cost/regret/quality/runtime (float) (None, if not returned by TA)

  • runtime (float) – runtime (None if not returned by TA)

  • additional_info (dict) – all further additional run information

class smac.tae.execute_func.ExecuteTAFuncArray(ta: Callable, stats: smac.stats.stats.Stats, run_obj: str = 'quality', memory_limit: Optional[int] = None, par_factor: int = 1, cost_for_crash: float = 2147483647.0, abort_on_first_run_crash: bool = False, use_pynisher: bool = True)[source]

Bases: smac.tae.execute_func.AbstractTAFunc

Evaluate function for given configuration and resource limit.

Passes the configuration as an array-like to the target algorithm. The target algorithm needs to implement one of the following signatures:

  • target_algorithm(config: np.ndarray) -> Union[float, Tuple[float, Any]]

  • target_algorithm(config: np.ndarray, seed: int) -> Union[float, Tuple[float, Any]]

  • target_algorithm(config: np.ndarray, seed: int, instance: str) -> Union[float, Tuple[float, Any]]

The target algorithm can either return a float (the loss), or a tuple with the first element being a float and the second being additional run information.

ExecuteTAFuncDict will use inspection to figure out the correct call to the target algorithm.

Parameters
  • ta (callable) – Function (target algorithm) to be optimized.

  • stats (smac.stats.stats.Stats, optional) – Stats object to collect statistics about runtime etc.

  • run_obj (str, optional) – Run objective (runtime or quality)

  • memory_limit (int, optional) – Memory limit (in MB) that will be applied to the target algorithm.

  • par_factor (int, optional) – Penalized average runtime factor. Only used when run_obj=’runtime’

_abc_impl = <_abc_data object>
_call_ta(obj: Callable, config: ConfigSpace.configuration_space.Configuration, obj_kwargs: Dict[str, Optional[Union[int, str, float]]]) → Union[float, Tuple[float, Dict]][source]
class smac.tae.execute_func.ExecuteTAFuncDict(ta: Callable, stats: smac.stats.stats.Stats, run_obj: str = 'quality', memory_limit: Optional[int] = None, par_factor: int = 1, cost_for_crash: float = 2147483647.0, abort_on_first_run_crash: bool = False, use_pynisher: bool = True)[source]

Bases: smac.tae.execute_func.AbstractTAFunc

Evaluate function for given configuration and resource limit.

Passes the configuration as a dictionary to the target algorithm. The target algorithm needs to implement one of the following signatures:

  • target_algorithm(config: Configuration) -> Union[float, Tuple[float, Any]]

  • target_algorithm(config: Configuration, seed: int) -> Union[float, Tuple[float, Any]]

  • target_algorithm(config: Configuration, seed: int, instance: str) -> Union[float, Tuple[float, Any]]

The target algorithm can either return a float (the loss), or a tuple with the first element being a float and the second being additional run information.

ExecuteTAFuncDict will use inspection to figure out the correct call to the target algorithm.

Parameters
  • ta (callable) – Function (target algorithm) to be optimized.

  • stats (smac.stats.stats.Stats, optional) – Stats object to collect statistics about runtime etc.

  • run_obj (str, optional) – Run objective (runtime or quality)

  • memory_limit (int, optional) – Memory limit (in MB) that will be applied to the target algorithm.

  • par_factor (int, optional) – Penalized average runtime factor. Only used when run_obj=’runtime’

  • use_pynisher (bool, optional) – use pynisher to limit resources;

_abc_impl = <_abc_data object>
_call_ta(obj: Callable, config: ConfigSpace.configuration_space.Configuration, obj_kwargs: Dict[str, Optional[Union[int, str, float]]]) → Union[float, Tuple[float, Dict]][source]