Scenario
smac.scenario
#
Scenario
dataclass
#
Scenario(
configspace: ConfigurationSpace,
name: str | None = None,
output_directory: Path = Path("smac3_output"),
deterministic: bool = False,
objectives: str | list[str] = "cost",
crash_cost: float | list[float] = inf,
termination_cost_threshold: float | list[float] = inf,
walltime_limit: float = inf,
cputime_limit: float = inf,
trial_walltime_limit: float | None = None,
trial_memory_limit: int | None = None,
n_trials: int = 100,
use_default_config: bool = False,
instances: list[str] | None = None,
instance_features: dict[str, list[float]] | None = None,
adaptive_capping: bool = False,
adaptive_capping_slackfactor: float | None = None,
runtime_cutoff: int | None = None,
min_budget: float | int | None = None,
max_budget: float | int | None = None,
seed: int = 0,
n_workers: int = 1,
)
The scenario manages environment variables and therefore gives context in which frame the optimization is performed.
| PARAMETER | DESCRIPTION |
|---|---|
configspace
|
The configuration space from which to sample the configurations.
TYPE:
|
name
|
The name of the run. If no name is passed, SMAC generates a hash from the meta data. Specify this argument to identify your run easily.
TYPE:
|
output_directory
|
The directory in which to save the output. The files are saved in
TYPE:
|
deterministic
|
If True, only one seed is passed to the target function, assuming deterministic (noise-free) behavior.
Otherwise, multiple seeds are passed (if
TYPE:
|
objectives
|
The objective(s) to optimize. This argument is required for multi-objective optimization.
TYPE:
|
crash_cost
|
Defines the cost for a failed trial. In case of multi-objective, each objective can be associated with a different cost.
TYPE:
|
termination_cost_threshold
|
Defines a cost threshold when the optimization should stop. In case of multi-objective, each objective must be associated with a cost. The optimization stops when all objectives crossed the threshold.
TYPE:
|
walltime_limit
|
The maximum time in seconds that SMAC is allowed to run.
TYPE:
|
cputime_limit
|
The maximum CPU time in seconds that SMAC is allowed to run.
TYPE:
|
trial_walltime_limit
|
The maximum time in seconds that a trial is allowed to run. If not specified, no constraints are enforced. Otherwise, the process will be spawned by pynisher.
TYPE:
|
trial_memory_limit
|
The maximum memory in MB that a trial is allowed to use. If not specified, no constraints are enforced. Otherwise, the process will be spawned by pynisher.
TYPE:
|
n_trials
|
The maximum number of trials (combination of configuration, seed, budget, and instance, depending on the task) to run.
TYPE:
|
use_default_config
|
If True, the configspace's default configuration is evaluated in the initial design. For historic benchmark reasons, this is False by default. Notice, that this will result in n_configs + 1 for the initial design. Respecting n_trials, this will result in one fewer evaluated configuration in the optimization.
TYPE:
|
instances
|
Names of the instances to use. If None, no instances are used. Instances could be dataset names, seeds, subsets, etc.
TYPE:
|
instance_features
|
Instances can be associated with features. For example, meta data of the dataset (mean, var, ...) can be incorporated which are then further used to expand the training data of the surrogate model.
TYPE:
|
adaptive_capping
|
Adaptive capping allows to preemptiveley cancel the evaluation of candidates as soon as their accumulative cost exceed the cost of the current incumbent. If a runtime_cutoff is set, SMAC will allocate budgets that are capped at the runtime_cutoff.
TYPE:
|
runtime_cutoff
|
A runtime cutoff can be set to limit the maximum runtime allowed for a single configuration to run solving instances.
TYPE:
|
min_budget
|
The minimum budget (epochs, subset size, number of instances, ...) that is used for the optimization. Use this argument if you use multi-fidelity or instance optimization.
TYPE:
|
max_budget
|
The maximum budget (epochs, subset size, number of instances, ...) that is used for the optimization. Use this argument if you use multi-fidelity or instance optimization.
TYPE:
|
seed
|
The seed is used to make results reproducible. If seed is -1, SMAC will generate a random seed.
TYPE:
|
n_workers
|
The number of workers to use for parallelization. If
TYPE:
|
meta
property
#
Returns the meta data of the SMAC run.
Note
Meta data are set when the facade is initialized.
__post_init__
#
Checks whether the config is valid.
Source code in smac/scenario.py
count_instance_features
#
count_instance_features() -> int
Counts the number of instance features.
Source code in smac/scenario.py
load
staticmethod
#
Loads a scenario and the configuration space from a file.
Source code in smac/scenario.py
make_serializable
staticmethod
#
Makes the scenario serializable.
Source code in smac/scenario.py
save
#
Saves internal variables and the configuration space to a file.