from pathlib import Path from dacbench.logger import Logger from dacbench.wrappers import PerformanceTrackingWrapper, ObservationWrapper from examples.example_utils import make_chainer_a3c from dacbench.benchmarks import CMAESBenchmark # Make logger object logger = Logger(experiment_name="CMAESBenchmark", output_path=Path("../plotting/data")) # Make CMA-ES environment # We use the configuration from the "Learning to Optimize Step-size Adaption in CMA-ES" Paper by Shala et al. bench = CMAESBenchmark() env = bench.get_benchmark() logger.set_env(env) # Wrap to track performance performance_logger = logger.add_module(PerformanceTrackingWrapper) env = PerformanceTrackingWrapper(env=env, logger=performance_logger) # Also wrap to make the dictionary observations into an easy to work with list env = ObservationWrapper(env) # Make chainer agent obs_size = env.observation_space.low.size action_size = env.action_space.low.size agent = make_chainer_a3c(obs_size, action_size) # Training num_episodes = 3 for i in range(num_episodes):
def test_benchmark_env(self): bench = CMAESBenchmark() env = bench.get_benchmark() self.assertTrue(issubclass(type(env), CMAESEnv))
def get_test_env(self) -> AbstractEnv: bench = CMAESBenchmark() env = bench.get_benchmark(seed=42) return env