smac.facade.experimental.psmac_facade module

class smac.facade.experimental.psmac_facade.PSMAC(scenario: Type[smac.scenario.scenario.Scenario], rng: Optional[Union[int, numpy.random.mtrand.RandomState]] = None, run_id: int = 1, tae: Type[smac.tae.base.BaseRunner] = <class 'smac.tae.execute_ta_run_old.ExecuteTARunOld'>, tae_kwargs: Optional[dict] = None, shared_model: bool = True, validate: bool = True, n_optimizers: int = 2, val_set: Optional[List[str]] = None, n_incs: int = 1, **kwargs)[source]

Bases: object

Facade to use PSMAC

logger
stats

loggs information about used resources

Type

Stats

solver

handles the actual algorithm calls

Type

SMBO

rh

List with information about previous runs

Type

RunHistory

portfolio

List of all incumbents

Type

list

Constructor

Parameters
  • scenario (Scenario) – Scenario object

  • n_optimizers (int) – Number of optimizers to run in parallel per round

  • rng (int/np.random.RandomState) – The randomState/seed to pass to each smac run

  • run_id (int) – run_id for this hydra run

  • tae (BaseRunner) – Target Algorithm Runner (supports old and aclib format as well as AbstractTAFunc)

  • tae_kwargs (Optional[dict]) – arguments passed to constructor of ‘~tae’

  • shared_model (bool) – Flag to indicate whether information is shared between SMAC runs or not

  • validate (bool / None) – Flag to indicate whether to validate the found configurations or to use the SMAC estimates None => neither and return the full portfolio

  • n_incs (int) – Number of incumbents to return (n_incs <= 0 ==> all found configurations)

  • val_set (typing.List[str]) – List of instance-ids to validate on

_get_mean_costs(incs: List[ConfigSpace.configuration_space.Configuration], new_rh: smac.runhistory.runhistory.RunHistory)[source]

Compute mean cost per instance

Parameters
  • incs (typing.List[Configuration]) – incumbents determined by all parallel SMAC runs

  • new_rh (RunHistory) – runhistory to determine mean performance

Returns

  • List[float] means

  • Dict(Config -> Dict(inst_id(str) -> float))

get_best_incumbents_ids(incs: List[ConfigSpace.configuration_space.Configuration])[source]

Determines the IDs and costs of the best configurations

Parameters

incs (typing.List[Configuration]) – incumbents determined by all parallel SMAC runs

Returns

  • Dict(Config -> Dict(inst_id (str) -> cost (float))) (if real validation runs are performed)

  • List(ints) (indices of best configurations if validation runs are performed)

  • Dict(Config -> Dict(inst_id (str) -> cost (float))) (if performance is estimated)

  • List(ints) (indices of best configurations if performance is estimated)

optimize()[source]

Optimizes the algorithm provided in scenario (given in constructor)

Returns

  • incumbent(s) (Configuration / List[Configuration] / ndarray[Configuration]) – Incumbent / Portfolio of incumbents

  • pid(s) (int / ndarray[ints]) – Process ID(s) from which the configuration stems

validate_incs(incs: numpy.ndarray)[source]

Validation

smac.facade.experimental.psmac_facade.optimize(scenario: Type[smac.scenario.scenario.Scenario], tae: Type[smac.tae.base.BaseRunner], tae_kwargs: Dict, rng: Union[numpy.random.mtrand.RandomState, int], output_dir: str, **kwargs) → ConfigSpace.configuration_space.Configuration[source]

Unbound method to be called in a subprocess

Parameters
  • scenario (Scenario) – smac.Scenario to initialize SMAC

  • tae (BaseRunner) – Target Algorithm Runner (supports old and aclib format)

  • tae_runner_kwargs (Optional[dict]) – arguments passed to constructor of ‘~tae’

  • rng (int/np.random.RandomState) – The randomState/seed to pass to each smac run

  • output_dir (str) – The directory in which each smac run should write it’s results

Returns

incumbent – The incumbent configuration of this run

Return type

Configuration