dacbench

DACBench: a benchmark library for Dynamic Algorithm Configuration

Package Contents

Classes

AbstractEnv

Abstract template for environments

AbstractBenchmark

Abstract template for benchmark classes

class dacbench.AbstractEnv(config)

Bases: gym.Env

Abstract template for environments

step_(self)

Pre-step function for step count and cutoff

Returns

End of episode

Return type

bool

reset_(self, instance=None, instance_id=None, scheme=None)

Pre-reset function for progressing through the instance set Will either use round robin, random or no progression scheme

use_next_instance(self, instance=None, instance_id=None, scheme=None)

Changes instance according to chosen instance progession

Parameters
  • instance – Instance specification for potentional new instances

  • instance_id – ID of the instance to switch to

  • scheme – Update scheme for this progression step (either round robin, random or no progression)

abstract step(self, action)

Execute environment step

Parameters

action – Action to take

Returns

  • state – Environment state

  • reward – Environment reward

  • done (bool) – Run finished flag

  • info (dict) – Additional metainfo

abstract reset(self)

Reset environment

Returns

Environment state

Return type

state

get_inst_id(self)

Return instance ID

Returns

ID of current instance

Return type

int

get_instance_set(self)

Return instance set

Returns

List of instances

Return type

list

get_instance(self)

Return current instance

Returns

Currently used instance

Return type

type flexible

set_inst_id(self, inst_id)

Change current instance ID

Parameters

inst_id (int) – New instance index

set_instance_set(self, inst_set)

Change instance set

Parameters

inst_set (list) – New instance set

set_instance(self, instance)

Change currently used instance

Parameters

instance – New instance

seed_action_space(self, seed=None)

Seeds the action space. :param seed: if None self.initial_seed is be used :type seed: int, default None

seed(self, seed=None, seed_action_space=False)

Set rng seed

Parameters
  • seed – seed for rng

  • seed_action_space (bool, default False) – if to seed the action space as well

use_test_set(self)

Change to test instance set

use_training_set(self)

Change to training instance set

class dacbench.AbstractBenchmark(config_path=None, config: dacbench.abstract_benchmark.objdict = None)

Abstract template for benchmark classes

get_config(self)

Return current configuration

Returns

Current config

Return type

dict

serialize_config(self)

Save configuration to json

Parameters

path (str) – File to save config to

process_configspace(self, configuration_space)

This is largely the builting cs.json.write method, but doesn’t save the result directly If this is ever implemented in cs, we can replace this method

classmethod from_json(cls, json_config)
to_json(self)
save_config(self, path)
jsonify_wrappers(self)
dejson_wrappers(self, wrapper_list)
static __import_from(module: str, name: str)

Imports the class / function / … with name from module :param module: :param name:

Returns

Return type

the imported object

classmethod class_to_str(cls)
static __decorate_config_with_functions(conf: dict)

Replaced the stringified functions with the callable objects :param config:

static __stringify_functions(conf: dict) dict

Replaced all callables in the config with a triple (‘function’, module_name, function_name)

Parameters

config

Returns

Return type

modified dict

space_to_list(self, space)
list_to_space(self, space_list)
jsonify_dict_space(self, dict_space)
dictify_json(self, dict_list)
load_config(self, config: dacbench.abstract_benchmark.objdict)
read_config_file(self, path)

Read configuration from file

Parameters

path (str) – Path to config file

abstract get_environment(self)

Make benchmark environment

Returns

env – Benchmark environment

Return type

gym.Env

set_seed(self, seed)

Set environment seed

Parameters

seed (int) – New seed

set_action_space(self, kind, args)

Change action space

Parameters
  • kind (str) – Name of action space class

  • args (list) – List of arguments to pass to action space class

set_observation_space(self, kind, args, data_type)

Change observation_space

Parameters
  • kind (str) – Name of observation space class

  • args (list) – List of arguments to pass to observation space class

  • data_type (type) – Data type of observation space

register_wrapper(self, wrap_func)
__eq__(self, other)

Return self==value.