Create Custom Benchmarks
Create Custom Benchmarks#
In addition to the default benchmark, it is possible to create custom benchmarks.
To create a custom benchmark, we instantiate a
ColosseumBenchmark
object, which requires
the parameters for the environments that will constitute the benchmark and
the settings that regulates the agent/MDP interactions, which are stored in
an ExperimentConfig
object.
We define a configuration that results in a small number of short agent/MDP interactions.
experiment_config = ExperimentConfig(
n_seeds=1,
n_steps=5_000,
max_interaction_time_s=30,
log_performance_indicators_every=1000,
)
MDP configurations
There are three ways to create environments configurations that can be used to create a custom benchmark.
Random sampling
Each \(\texttt{Colosseum}\) environment class implements a function to randomly sample parameters that are mainly used for the hyperparameters optimization procedure of the agents. Nonetheless, we can sample such configurations to create our custom benchmark.
# Get all the episodic MDP Colosseum classes
episodic_mdp_classes = get_colosseum_mdp_classes(episodic=True)
mdps_configs = dict()
for cl in episodic_mdp_classes:
# For each episodic MDP class, we sample a single configuration
mdps_configs[cl] = sample_mdp_gin_configs_file(cl, n=1, seed=seed)
# We define the benchmark object with the sampled MDP configs and the previously defined experiment config
benchmark = ColosseumBenchmark(
name="episodic_randomly_sampled", mdps_gin_configs=mdps_configs, experiment_config=experiment_config
)
Default benchmark instances
We can also borrow the MDP instances from the default benchmark, and maybe modify them.
# Instantiate the episodic ergodic benchmark and take its MDP configurations
mdps_configs = ColosseumDefaultBenchmark.EPISODIC_ERGODIC.get_benchmark().mdps_gin_configs
# Save the configurations in a new ColosseumBenchmark object with a custom name and the previously defined experiment config
benchmark = ColosseumBenchmark("borrowing_from_default", mdps_configs, experiment_config)
Configurations from MDP instances
Finally, we can obtain environment configurations directly from instances.
# Define a list of MDP instance
mdps = [
DeepSeaEpisodic(seed=4, size=10, p_rand=0.4),
FrozenLakeEpisodic(seed=4, size=5, p_frozen=0.8),
]
# from which we can obtain the configurations from
mdps_configs = get_mdps_configs_from_mdps(mdps)
benchmark = ColosseumBenchmark("custom_mdp_instances", mdps_configs, experiment_config)