smac.runner.target_function_script_runner¶
Classes¶
|
Class to execute target functions from scripts. Uses Popen to execute the script in a |
Interfaces¶
- class smac.runner.target_function_script_runner.TargetFunctionScriptRunner(target_function, scenario, required_arguments=None)[source]¶
Bases:
AbstractSerialRunner
- Class to execute target functions from scripts. Uses Popen to execute the script in a
subprocess.
The following example shows how the script is called:
target_function --instance=test --instance_features=test --seed=0 --hyperparameter1=5323
The script must return an echo in the following form (white-spaces are removed):
cost=0.5; runtime=0.01; status=SUCCESS; additional_info=test
(single-objective)cost=0.5, 0.4; runtime=0.01; status=SUCCESS; additional_info=test
(multi-objective)The status must be a string and must be one of the
StatusType
values. However,runtime
,status
andadditional_info
are optional.Note
Everytime an instance is passed, also an instance feature in form of a comma-separated list (no spaces) of floats is passed. If no instance feature for the instance is given, an empty list is passed.
- Parameters:
target_function (Callable) – The target function.
scenario (Scenario)
required_arguments (list[str]) – A list of required arguments, which are passed to the target function.
- __call__(algorithm_kwargs)[source]¶
Calls the algorithm, which is processed in the
run
method.- Return type:
tuple
[str
,str
]
- property meta: dict[str, Any]¶
Returns the meta-data of the created object.
- run(config, instance=None, budget=None, seed=None)[source]¶
Calls the target function.
- 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 took to run.
additional_info (dict) – All further additional trial information.