smac.utils.io.traj_logging module

class smac.utils.io.traj_logging.TrajEntry(train_perf, incumbent_id, incumbent, ta_runs, ta_time_used, wallclock_time, budget)

Bases: tuple

Create new instance of TrajEntry(train_perf, incumbent_id, incumbent, ta_runs, ta_time_used, wallclock_time, budget)

_asdict()

Return a new OrderedDict which maps field names to their values.

_field_defaults = {}
_fields = ('train_perf', 'incumbent_id', 'incumbent', 'ta_runs', 'ta_time_used', 'wallclock_time', 'budget')
_fields_defaults = {}
classmethod _make(iterable)

Make a new TrajEntry object from a sequence or iterable

_replace(**kwds)

Return a new TrajEntry object replacing specified fields with new values

property budget

Alias for field number 6

property incumbent

Alias for field number 2

property incumbent_id

Alias for field number 1

property ta_runs

Alias for field number 3

property ta_time_used

Alias for field number 4

property train_perf

Alias for field number 0

property wallclock_time

Alias for field number 5

class smac.utils.io.traj_logging.TrajLogger(output_dir: Optional[str], stats: smac.stats.stats.Stats)[source]

Bases: object

Writes trajectory logs files and creates output directory if not exists already

stats
logger
output_dir
aclib_traj_fn
old_traj_fn
trajectory

Constructor

Parameters
  • output_dir (str) – directory for logging (or None to disable logging)

  • stats (Stats()) – Stats object

_add_in_aclib_format(train_perf: float, incumbent_id: int, incumbent: ConfigSpace.configuration_space.Configuration, ta_time_used: float, wallclock_time: float) → None[source]

Adds entries to AClib2-like trajectory file

Parameters
  • train_perf (float) – Estimated performance on training (sub)set

  • incumbent_id (int) – Id of incumbent

  • incumbent (Configuration()) – Current incumbent configuration

  • ta_time_used (float) – CPU time used by the target algorithm

  • wallclock_time (float) – Wallclock time used so far

_add_in_alljson_format(train_perf: float, incumbent_id: int, incumbent: ConfigSpace.configuration_space.Configuration, budget: float, ta_time_used: float, wallclock_time: float) → None[source]

Adds entries to AClib2-like (but with configs as json) trajectory file

Parameters
  • train_perf (float) – Estimated performance on training (sub)set

  • incumbent_id (int) – Id of incumbent

  • incumbent (Configuration()) – Current incumbent configuration

  • budget (float) – budget (cutoff) used in intensifier to limit TA (default: 0)

  • ta_time_used (float) – CPU time used by the target algorithm

  • wallclock_time (float) – Wallclock time used so far

_add_in_old_format(train_perf: float, incumbent_id: int, incumbent: ConfigSpace.configuration_space.Configuration, ta_time_used: float, wallclock_time: float) → None[source]

Adds entries to old SMAC2-like trajectory file

Parameters
  • train_perf (float) – Estimated performance on training (sub)set

  • incumbent_id (int) – Id of incumbent

  • incumbent (Configuration()) – Current incumbent configuration

  • ta_time_used (float) – CPU time used by the target algorithm

  • wallclock_time (float) – Wallclock time used so far

static _convert_dict_to_config(config_list: List[str], cs: ConfigSpace.configuration_space.ConfigurationSpace) → ConfigSpace.configuration_space.Configuration[source]

Since we save a configurations in a dictionary str->str we have to try to figure out the type (int, float, str) of each parameter value

Parameters
  • config_list (typing.List[str]) – Configuration as a list of “str=’str’”

  • cs (ConfigurationSpace) – Configuration Space to translate dict object into Confiuration object

add_entry(train_perf: float, incumbent_id: int, incumbent: ConfigSpace.configuration_space.Configuration, budget: float = 0) → None[source]

Adds entries to trajectory files (several formats) with using the same timestamps for each entry

Parameters
  • train_perf (float) – estimated performance on training (sub)set

  • incumbent_id (int) – id of incumbent

  • incumbent (Configuration()) – current incumbent configuration

  • budget (float) – budget used in intensifier to limit TA (default: 0)

static read_traj_aclib_format(fn: str, cs: ConfigSpace.configuration_space.ConfigurationSpace) → List[Dict[str, Union[float, int, ConfigSpace.configuration_space.Configuration]]][source]

Reads trajectory from file

Parameters
  • fn (str) – Filename with saved runhistory in self._add_in_aclib_format format

  • cs (ConfigurationSpace) – Configuration Space to translate dict object into Confiuration object

Returns

trajectory – Each entry in the list is a dictionary of the form { “cpu_time”: float, “wallclock_time”: float, “evaluations”: int “cost”: float, “incumbent”: Configuration }

Return type

list

static read_traj_alljson_format(fn: str, cs: ConfigSpace.configuration_space.ConfigurationSpace) → List[Dict[str, Union[float, int, ConfigSpace.configuration_space.Configuration]]][source]

Reads trajectory from file

Parameters
  • fn (str) – Filename with saved runhistory in self._add_in_alljson_format format

  • cs (ConfigurationSpace) – Configuration Space to translate dict object into Confiuration object

Returns

trajectory – Each entry in the list is a dictionary of the form { “cpu_time”: float, “wallclock_time”: float, “evaluations”: int “cost”: float, “budget”: budget, “incumbent”: Configuration }

Return type

list