smac.utils.io.output_writer module

class smac.utils.io.output_writer.OutputWriter[source]

Bases: object

Writing scenario to file.

_parse_argument(scenario: Scenario, key: str, value: Any) Any[source]

Some values of the scenario-file need to be changed upon writing, such as the ‘ta’ (target algorithm), due to it’s callback. Also, the configspace, features, train_inst- and test-inst-lists are saved to output_dir, if they exist.

Sideeffects - copies files pcs_fn, train_inst_fn, test_inst_fn and feature_fn to output if possible, creates the files from attributes otherwise

Parameters
  • scenario (Scenario) – Scenario-file to be written

  • key (string) – Name of the attribute in scenario-file

  • value (Any) – Corresponding attribute

Returns

new value – The altered value, to be written to file

Return type

string

save_configspace(cs: ConfigSpace.configuration_space.ConfigurationSpace, fn: str, output_format: str) None[source]

Writing ConfigSpace to file.

Parameters
  • cs (ConfigurationSpace) – Config-space to be written

  • fn (str) – Output-file-path

  • output_format (str) – Output format of the configuration space file. Currently, json and pcs_new are supported.

write_inst_features_file(n_features: int, feat_dict: Dict[str, Iterable[float]], fn: str) None[source]

Writes features to file.

Parameters
  • n_features (int) – Number of features

  • feat_dict (dict) – Features to be written

  • fn (string) – File name of instance feature file

write_inst_file(insts: List[str], fn: str) None[source]

Writes instance-list to file.

Parameters
  • insts (list<string>) – Instance list to be written

  • fn (string) – Output path

write_scenario_file(scenario: Scenario) None[source]

Write scenario to a file (format is compatible with input_reader). Will overwrite if file exists. If you have arguments that need special parsing when saving, specify so in the _parse_argument-function. Creates output-dir if necessesary.

Parameters

scenario (Scenario) – Scenario to be written to file

Returns

status – False indicates that writing process failed

Return type

False or None