smac.optimizer.ei_optimization module

class smac.optimizer.ei_optimization.AcquisitionFunctionMaximizer(acquisition_function: smac.optimizer.acquisition.AbstractAcquisitionFunction, config_space: ConfigSpace.configuration_space.ConfigurationSpace, rng: Union[bool, numpy.random.mtrand.RandomState] = None)[source]

Bases: object

Abstract class for acquisition maximization.

In order to use this class it has to be subclassed and the method _maximize must be implemented.

Parameters
_abc_impl = <_abc_data object>
abstract _maximize(runhistory: smac.runhistory.runhistory.RunHistory, stats: smac.stats.stats.Stats, num_points: int) → List[Tuple[float, ConfigSpace.configuration_space.Configuration]][source]

Implements acquisition function maximization.

In contrast to maximize, this method returns an iterable of tuples, consisting of the acquisition function value and the configuration. This allows to plug together different acquisition function maximizers.

Parameters
  • runhistory (RunHistory) – runhistory object

  • stats (Stats) – current stats object

  • num_points (int) – number of points to be sampled

Returns

An iterable consistng of tuple(acqusition_value, smac.configspace.Configuration).

Return type

iterable

_sort_configs_by_acq_value(configs: List[ConfigSpace.configuration_space.Configuration]) → List[Tuple[float, ConfigSpace.configuration_space.Configuration]][source]

Sort the given configurations by acquisition value

Parameters

configs (list(Configuration)) –

Returns

list – ordered by their acquisition function value

Return type

(acquisition value, Candidate solutions),

maximize(runhistory: smac.runhistory.runhistory.RunHistory, stats: smac.stats.stats.Stats, num_points: int, random_configuration_chooser: Optional[smac.optimizer.random_configuration_chooser.RandomConfigurationChooser] = None) → Iterator[ConfigSpace.configuration_space.Configuration][source]

Maximize acquisition function using _maximize.

Parameters
  • runhistory (RunHistory) – runhistory object

  • stats (Stats) – current stats object

  • num_points (int) – number of points to be sampled

  • random_configuration_chooser (RandomConfigurationChooser, optional) – part of the returned ChallengerList such that we can interleave random configurations by a scheme defined by the random_configuration_chooser; random_configuration_chooser.next_smbo_iteration() is called at the end of this function

Returns

An iterable consisting of smac.configspace.Configuration.

Return type

iterable

class smac.optimizer.ei_optimization.ChallengerList(challenger_callback: Callable, configuration_space: ConfigSpace.configuration_space.ConfigurationSpace, random_configuration_chooser: Optional[smac.optimizer.random_configuration_chooser.RandomConfigurationChooser] = <smac.optimizer.random_configuration_chooser.ChooserNoCoolDown object>)[source]

Bases: collections.abc.Iterator, typing.Generic

Helper class to interleave random configurations in a list of challengers.

Provides an iterator which returns a random configuration in each second iteration. Reduces time necessary to generate a list of new challengers as one does not need to sample several hundreds of random configurations in each iteration which are never looked at.

Parameters
_abc_impl = <_abc_data object>
class smac.optimizer.ei_optimization.DiffOpt(acquisition_function: smac.optimizer.acquisition.AbstractAcquisitionFunction, config_space: ConfigSpace.configuration_space.ConfigurationSpace, rng: Union[bool, numpy.random.mtrand.RandomState] = None)[source]

Bases: smac.optimizer.ei_optimization.AcquisitionFunctionMaximizer

Get candidate solutions via DifferentialEvolutionSolvers.

Parameters
_abc_impl = <_abc_data object>
_maximize(runhistory: smac.runhistory.runhistory.RunHistory, stats: smac.stats.stats.Stats, num_points: int, _sorted: bool = False) → List[Tuple[float, ConfigSpace.configuration_space.Configuration]][source]

DifferentialEvolutionSolver

Parameters
  • runhistory (RunHistory) – runhistory object

  • stats (Stats) – current stats object

  • num_points (int) – number of points to be sampled

  • _sorted (bool) – whether random configurations are sorted according to acquisition function

Returns

An iterable consistng of tuple(acqusition_value, smac.configspace.Configuration).

Return type

iterable

class smac.optimizer.ei_optimization.FixedSet(configurations: List[ConfigSpace.configuration_space.Configuration], acquisition_function: smac.optimizer.acquisition.AbstractAcquisitionFunction, config_space: ConfigSpace.configuration_space.ConfigurationSpace, rng: Union[bool, numpy.random.mtrand.RandomState] = None)[source]

Bases: smac.optimizer.ei_optimization.AcquisitionFunctionMaximizer

Maximize the acquisition function over a finite list of configurations.

Parameters
_abc_impl = <_abc_data object>
_maximize(runhistory: smac.runhistory.runhistory.RunHistory, stats: smac.stats.stats.Stats, num_points: int) → List[Tuple[float, ConfigSpace.configuration_space.Configuration]][source]

Implements acquisition function maximization.

In contrast to maximize, this method returns an iterable of tuples, consisting of the acquisition function value and the configuration. This allows to plug together different acquisition function maximizers.

Parameters
  • runhistory (RunHistory) – runhistory object

  • stats (Stats) – current stats object

  • num_points (int) – number of points to be sampled

Returns

An iterable consistng of tuple(acqusition_value, smac.configspace.Configuration).

Return type

iterable

class smac.optimizer.ei_optimization.LocalAndSortedRandomSearch(acquisition_function: smac.optimizer.acquisition.AbstractAcquisitionFunction, config_space: ConfigSpace.configuration_space.ConfigurationSpace, rng: Union[bool, numpy.random.mtrand.RandomState] = None, max_steps: Optional[int] = None, n_steps_plateau_walk: int = 10, n_sls_iterations: int = 10)[source]

Bases: smac.optimizer.ei_optimization.AcquisitionFunctionMaximizer

Implements SMAC’s default acquisition function optimization.

This optimizer performs local search from the previous best points according, to the acquisition function, uses the acquisition function to sort randomly sampled configurations. Random configurations are interleaved by the main SMAC code.

Parameters
  • acquisition_function (AbstractAcquisitionFunction) –

  • config_space (ConfigurationSpace) –

  • rng (np.random.RandomState or int, optional) –

  • max_steps (int) – [LocalSearch] Maximum number of steps that the local search will perform

  • n_steps_plateau_walk (int) – [LocalSearch] number of steps during a plateau walk before local search terminates

  • n_sls_iterations (int) – [Local Search] number of local search iterations

_abc_impl = <_abc_data object>
_maximize(runhistory: smac.runhistory.runhistory.RunHistory, stats: smac.stats.stats.Stats, num_points: int) → List[Tuple[float, ConfigSpace.configuration_space.Configuration]][source]

Implements acquisition function maximization.

In contrast to maximize, this method returns an iterable of tuples, consisting of the acquisition function value and the configuration. This allows to plug together different acquisition function maximizers.

Parameters
  • runhistory (RunHistory) – runhistory object

  • stats (Stats) – current stats object

  • num_points (int) – number of points to be sampled

Returns

An iterable consistng of tuple(acqusition_value, smac.configspace.Configuration).

Return type

iterable

class smac.optimizer.ei_optimization.LocalSearch(acquisition_function: smac.optimizer.acquisition.AbstractAcquisitionFunction, config_space: ConfigSpace.configuration_space.ConfigurationSpace, rng: Union[bool, numpy.random.mtrand.RandomState] = None, max_steps: Optional[int] = None, n_steps_plateau_walk: int = 10, vectorization_min_obtain: int = 2, vectorization_max_obtain: int = 64)[source]

Bases: smac.optimizer.ei_optimization.AcquisitionFunctionMaximizer

Implementation of SMAC’s local search.

Parameters
  • acquisition_function (AbstractAcquisitionFunction) –

  • config_space (ConfigurationSpace) –

  • rng (np.random.RandomState or int, optional) –

  • max_steps (int) – Maximum number of iterations that the local search will perform

  • n_steps_plateau_walk (int) – number of steps during a plateau walk before local search terminates

  • vectorization_min_obtain (int) – Minimal number of neighbors to obtain at once for each local search for vectorized calls. Can be tuned to reduce the overhead of SMAC

  • vectorization_max_obtain (int) – Maximal number of neighbors to obtain at once for each local search for vectorized calls. Can be tuned to reduce the overhead of SMAC

_abc_impl = <_abc_data object>
_get_initial_points(num_points: int, runhistory: smac.runhistory.runhistory.RunHistory, additional_start_points: Optional[List[Tuple[float, ConfigSpace.configuration_space.Configuration]]]) → List[ConfigSpace.configuration_space.Configuration][source]
_maximize(runhistory: smac.runhistory.runhistory.RunHistory, stats: smac.stats.stats.Stats, num_points: int, additional_start_points: Optional[List[Tuple[float, ConfigSpace.configuration_space.Configuration]]] = None) → List[Tuple[float, ConfigSpace.configuration_space.Configuration]][source]

Starts a local search from the given startpoint and quits if either the max number of steps is reached or no neighbor with an higher improvement was found.

Parameters
  • runhistory (RunHistory) – runhistory object

  • stats (Stats) – current stats object

  • num_points (int) – number of points to be sampled

  • additional_start_points (Optional[List[Tuple[float, Configuration]]]) – Additional start point

Returns

Return type

List

class smac.optimizer.ei_optimization.RandomSearch(acquisition_function: smac.optimizer.acquisition.AbstractAcquisitionFunction, config_space: ConfigSpace.configuration_space.ConfigurationSpace, rng: Union[bool, numpy.random.mtrand.RandomState] = None)[source]

Bases: smac.optimizer.ei_optimization.AcquisitionFunctionMaximizer

Get candidate solutions via random sampling of configurations.

Parameters
_abc_impl = <_abc_data object>
_maximize(runhistory: smac.runhistory.runhistory.RunHistory, stats: smac.stats.stats.Stats, num_points: int, _sorted: bool = False) → List[Tuple[float, ConfigSpace.configuration_space.Configuration]][source]

Randomly sampled configurations

Parameters
  • runhistory (RunHistory) – runhistory object

  • stats (Stats) – current stats object

  • num_points (int) – number of points to be sampled

  • _sorted (bool) – whether random configurations are sorted according to acquisition function

Returns

An iterable consistng of tuple(acqusition_value, smac.configspace.Configuration).

Return type

iterable