smac.facade.psmac_facade

Functions

optimize(scenario, tae_runner, ...[, ...])

Unbound method to be called in a subprocess

Classes

PSMAC(scenario[, rng, run_id, tae_runner, ...])

Facade to use pSMAC 1

class smac.facade.psmac_facade.PSMAC(scenario, rng=None, run_id=1, tae_runner=<class 'smac.tae.execute_ta_run_old.ExecuteTARunOld'>, tae_runner_kwargs=None, shared_model=True, facade_class=None, validate=True, n_workers=2, val_set=None, **kwargs)[source]

Bases: object

Facade to use pSMAC 1

With pSMAC you can either run n distinct SMAC optimizations in parallel (shared_model=False) or you can parallelize the target algorithm evaluations (shared_model=True). In the latter case all SMAC workers share one file directory and communicate via the logfiles. You can specify the number of SMAC workers/optimizers with the argument n_workers.

You can pass all other kwargs for the SMAC4AC facade. In addition, you can access the facade’s attributes normally (e.g. smac.stats), however each time a new SMAC object is built, reading the information from the file system.

1(1,2)

Ramage, S. E. A. (2015). Advances in meta-algorithmic software libraries for distributed automated algorithm configuration (T). University of British Columbia. Retrieved from https://open.library.ubc.ca/collections/ubctheses/24/items/1.0167184.

Parameters
  • scenario (Scenario) – Scenario object. Note that the budget/number of evaluations (runcount-limit) is used for each worker. So if you specify 40 evaluations and 3 workers, 120 configurations will be evaluated in total.

  • n_workers (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_runner (BaseRunner) – Target Algorithm Runner (supports old and aclib format as well as AbstractTAFunc)

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

  • 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

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

  • **kwargs – Keyword arguments for the SMAC4AC facade

# TODO update attributes
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

get_best_incumbent(incs)[source]

Determine ID and cost of best configuration (incumbent).

Parameters

incs (List[Configuration]) – List of incumbents from the workers.

Returns

Best incumbent from all workers.

Return type

Configuration

get_runhistory()[source]

Get merged runhistory from pSMAC workers

Return type

Optional[RunHistory]

get_trajectory()[source]

Get trajectory from merged runhistory

Return type

Optional[List[Dict[str, Any]]]

optimize()[source]

Optimizes the algorithm provided in scenario (given in constructor)

Returns

incumbent – Best configuration across all workers.

Return type

Configuration

validate_incs(incs)[source]

Validation of the incumbents.

write_run()[source]

Write all SMAC files to pSMAC dir

Return type

None

smac.facade.psmac_facade.optimize(scenario, tae_runner, tae_runner_kwargs, rng, output_dir, facade_class=None, **kwargs)[source]

Unbound method to be called in a subprocess

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

  • tae_runner (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 its results

Returns

incumbent – The incumbent configuration of this run

Return type

Configuration