def simpletsp(seed: tp.Optional[int] = None) -> tp.Iterator[Experiment]: """Simple TSP problems. Please note that the methods we use could be applied or complex variants, whereas specialized methods can not always do it; therefore this comparisons from a black-box point of view makes sense even if white-box methods are not included though they could do this more efficiently.""" funcs = [STSP(10), STSP(100), STSP(1000), STSP(10000)] seedg = create_seed_generator(seed) algos = [ "NaiveTBPSA", "SQP", "Powell", "LargeScrHammersleySearch", "ScrHammersleySearch", "PSO", "OnePlusOne", "NGO", "Shiva", "DiagonalCMA", "CMA", "TwoPointsDE", "QrDE", "LhsDE", "Zero", "StupidRandom", "RandomSearch", "HaltonSearch", "RandomScaleRandomSearch", "MiniDE" ] for budget in [25, 50, 100, 200, 400, 800, 1600, 3200, 6400, 12800, 25600]: for num_workers in [1]: # , 10, 100]: if num_workers < budget: for algo in algos: for fu in funcs: xp = Experiment(fu, algo, budget, num_workers=num_workers, seed=next(seedg)) if not xp.is_incoherent: yield xp
def realworld(seed: Optional[int] = None) -> Iterator[Experiment]: """Realworld optimization. This experiment contains: - a subset of MLDA (excluding the perceptron: 10 functions rescaled or not. - ARCoating https://arxiv.org/abs/1904.02907: 1 function. - The 007 game: 1 function, noisy. - PowerSystem: a power system simulation problem. - STSP: a simple TSP problem. MLDA stuff, except the Perceptron. """ funcs: List[Union[ExperimentFunction, rl.agents.TorchAgentFunction]] = [ _mlda.Clustering.from_mlda(name, num, rescale) for name, num in [("Ruspini", 5), ("German towns", 10)] for rescale in [True, False] ] funcs += [ _mlda.SammonMapping.from_mlda("Virus", rescale=False), _mlda.SammonMapping.from_mlda("Virus", rescale=True), _mlda.SammonMapping.from_mlda("Employees"), ] funcs += [_mlda.Landscape(transform) for transform in [None, "square", "gaussian"]] # Adding ARCoating. funcs += [ARCoating()] funcs += [PowerSystem(), PowerSystem(13)] funcs += [STSP(), STSP(500)] funcs += [game.Game("war")] funcs += [game.Game("batawaf")] funcs += [game.Game("flip")] funcs += [game.Game("guesswho")] funcs += [game.Game("bigguesswho")] # 007 with 100 repetitions, both mono and multi architectures. base_env = rl.envs.DoubleOSeven(verbose=False) random_agent = rl.agents.Agent007(base_env) modules = {'mono': rl.agents.Perceptron, 'multi': rl.agents.DenseNet} agents = {a: rl.agents.TorchAgent.from_module_maker(base_env, m, deterministic=False) for a, m in modules.items()} env = base_env.with_agent(player_0=random_agent).as_single_agent() runner = rl.EnvironmentRunner(env.copy(), num_repetitions=100, max_step=50) for archi in ["mono", "multi"]: func = rl.agents.TorchAgentFunction(agents[archi], runner, reward_postprocessing=lambda x: 1 - x) funcs += [func] seedg = create_seed_generator(seed) algos = ["NaiveTBPSA", "LargeScrHammersleySearch", "ScrHammersleySearch", "PSO", "OnePlusOne", "NGO", "Shiva", "DiagonalCMA", "CMA", "TwoPointsDE", "QrDE", "LhsDE", "Zero", "StupidRandom", "RandomSearch", "HaltonSearch", "RandomScaleRandomSearch", "MiniDE"] for budget in [25, 50, 100, 200, 400, 800, 1600, 3200, 6400, 12800]: for num_workers in [1, 10, 100]: if num_workers < budget: for algo in algos: for fu in funcs: xp = Experiment(fu, algo, budget, num_workers=num_workers, seed=next(seedg)) if not xp.is_incoherent: yield xp