smac.runner.target_function_runner

Classes

TargetFunctionRunner(scenario, target_function)

Class to execute target functions which are python functions.

Interfaces

class smac.runner.target_function_runner.TargetFunctionRunner(scenario, target_function, required_arguments=[])[source]

Bases: AbstractSerialRunner

Class to execute target functions which are python functions. Evaluates functions for given configuration and resource limit.

The target function can either return a float (the loss), or a tuple with the first element being a float and the second being additional run information. In a multi-objective setting, the float value is replaced by a list of floats.

Parameters:
  • target_function (Callable) – The target function function.

  • scenario (Scenario) –

  • required_arguments (list[str]) – A list of required arguments, which are passed to the target function.

__call__(config, algorithm, algorithm_kwargs)[source]

Calls the algorithm, which is processed in the run method.

Return type:

float | list[float] | dict[str, float] | tuple[float, dict] | tuple[list[float], dict] | tuple[dict[str, float], dict]

property meta: dict[str, Any]

Returns the meta data of the created object.

Return type:

dict[str, Any]

run(config, instance=None, budget=None, seed=None)[source]

Calls the target function with pynisher if algorithm walltime limit or memory limit is set. Otherwise the function is called directly.

Parameters:
  • config (Configuration) – Configuration to be passed to the target function.

  • instance (str | None, defaults to None) – The Problem instance.

  • budget (float | None, defaults to None) – A positive, real-valued number representing an arbitrary limit to the target function handled by the target function internally.

  • seed (int, defaults to None) –

Return type:

tuple[StatusType, float | list[float], float, dict]

Returns:

  • status (StatusType) – Status of the trial.

  • cost (float | list[float]) – Resulting cost(s) of the trial.

  • runtime (float) – The time the target function function took to run.

  • additional_info (dict) – All further additional trial information.