Exemple #1
0
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
Exemple #2
0
def powersystemssplit(
        seed: tp.Optional[int] = None) -> tp.Iterator[Experiment]:
    """Unit commitment problem, i.e. management of dams for hydroelectric planning.
    Bigger budget than the powersystems problem."""
    funcs: tp.List[ExperimentFunction] = []
    for dams in [3, 5, 9, 13]:
        for depth_width in [5]:
            funcs += [PowerSystem(dams, depth=depth_width, width=depth_width)]
    seedg = create_seed_generator(seed)
    algos = [
        "NGO", "Shiva", "DiagonalCMA", "CMA", "Zero", "RandomSearch", "DE",
        "PSO", "SplitOptimizer5", "SplitOptimizer9", "SplitOptimizer",
        "SplitOptimizer3", "SplitOptimizer13"
    ]
    for budget in [25600, 51200, 102400, 204800, 409600]:
        for num_workers in [1]:
            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
Exemple #3
0
def powersystems(seed: tp.Optional[int] = None) -> tp.Iterator[Experiment]:
    """Unit commitment problem, i.e. management of dams for hydroelectric planning."""
    funcs: tp.List[ExperimentFunction] = []
    for dams in [3, 5, 9, 13]:
        for depth_width in [5]:
            funcs += [PowerSystem(dams, depth=depth_width, width=depth_width)]
    seedg = create_seed_generator(seed)
    algos = [
        "NaiveTBPSA", "ScrHammersleySearch", "PSO", "OnePlusOne", "CMA",
        "TwoPointsDE", "QrDE", "LhsDE", "Zero", "StupidRandom", "RandomSearch",
        "HaltonSearch", "RandomScaleRandomSearch", "MiniDE", "SplitOptimizer5",
        "SplitOptimizer9", "SplitOptimizer", "NGO", "Shiva", "DiagonalCMA",
        "SplitOptimizer3", "SplitOptimizer13"
    ]
    for budget in [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