Exemplo n.º 1
0
def bragg_structure(seed: tp.Optional[int] = None) -> tp.Iterator[Experiment]:
    seedg = create_seed_generator(seed)
    recombinable: tp.List[tp.Union[str, ConfiguredOptimizer]] = [
        ng.families.EvolutionStrategy(recombination_ratio=0.1, popsize=40).set_name("Pairwise-ES"),
        ng.families.DifferentialEvolution(crossover="parametrization").set_name("Param-DE")
    ]
    algos: tp.List[tp.Union[str, ConfiguredOptimizer]] = ["TwoPointsDE", "DE", "CMA", "NaiveTBPSA", "DiagonalCMA"]
    algos += [ng.optimizers.ConfiguredPSO().set_name("PSO"), ng.optimizers.ParametrizedOnePlusOne().set_name("1+1")]
    func = Photonics("bragg", 80, bounding_method="clipping")
    func.parametrization.set_name("layer")
    #
    func_nostruct = Photonics("bragg", 80, bounding_method="clipping")
    func_nostruct.parametrization.set_name("2pt").set_recombination(ng.p.mutation.RavelCrossover())  # type: ignore
    #
    func_mix = Photonics("bragg", 80, bounding_method="clipping")
    param = func_mix.parametrization
    param.set_name("mix")
    param.set_recombination(ng.p.Choice([ng.p.mutation.Crossover(axis=1), ng.p.mutation.RavelCrossover()]))  # type: ignore
    muts = ["gaussian", "cauchy", ng.p.mutation.Jumping(axis=1, size=5), ng.p.mutation.Translation(axis=1)]
    muts += [ng.p.mutation.LocalGaussian(axes=1, size=10)]
    param.set_mutation(custom=ng.p.Choice(muts))  # type: ignore
    for budget in [1e3, 1e4, 1e5, 1e6]:
        xpseed = next(seedg)
        for algo in algos:
            yield Experiment(func, algo, int(budget), num_workers=1, seed=xpseed)
        for f in [func, func_nostruct, func_mix]:
            for algo in recombinable:
                yield Experiment(f, algo, int(budget), num_workers=1, seed=xpseed)
Exemplo n.º 2
0
def photonics(seed: tp.Optional[int] = None) -> tp.Iterator[Experiment]:
    seedg = create_seed_generator(seed)
    popsizes = [20, 40, 80]
    es = [
        ng.families.EvolutionStrategy(recombination_ratio=recomb,
                                      only_offsprings=only,
                                      popsize=pop,
                                      offsprings=pop * 5)
        for only in [True, False] for recomb in [0.1, .5] for pop in popsizes
    ]
    algos = [
        "TwoPointsDE", "DE", "RealSpacePSO", "PSO", "OnePlusOne",
        "ParametrizationDE", "NaiveTBPSA", "SplitOptimizer5", "Shiva", "NGO",
        "MultiCMA", "CMandAS2", "SplitOptimizer13"
    ] + es  # type: ignore
    for method in ["clipping", "tanh"]:  # , "arctan"]:
        for name in ["bragg", "chirped", "morpho"]:
            func = Photonics(name,
                             60 if name == "morpho" else 80,
                             bounding_method=method)
            for budget in [1e3, 1e4, 1e5, 1e6]:
                for algo in algos:
                    xp = Experiment(func,
                                    algo,
                                    int(budget),
                                    num_workers=1,
                                    seed=next(seedg))
                    if not xp.is_incoherent:
                        yield xp
Exemplo n.º 3
0
def photonics(seed: tp.Optional[int] = None) -> Iterator[Experiment]:
    seedg = create_seed_generator(seed)
    popsizes = [10, 40, 100]
    es = [ng.families.EvolutionStrategy(recombination_ratio=recomb, only_offsprings=False, popsize=pop)
          for recomb in [0.1, 1] for pop in popsizes]
    es += [ng.families.EvolutionStrategy(recombination_ratio=recomb, only_offsprings=only, popsize=pop,
                                         offsprings={10: 20, 40: 60, 100: 150}[pop])
           for only in [True, False] for recomb in [0.1, 1] for pop in popsizes]
    algos = ["TwoPointsDE", "DE", "PSO", "OnePlusOne", "ParametrizationDE", "NaiveTBPSA"] + es  # type: ignore
    for method in ["clipping", "tanh", "arctan"]:
        # , "chirped"]]:  # , "morpho"]]:
        for func in [Photonics(x, 60 if x == "morpho" else 80, bounding_method=method) for x in ["bragg"]]:
            for budget in [1e2, 1e3, 1e4, 1e5, 1e6]:
                for algo in algos:
                    xp = Experiment(func, algo, int(budget), num_workers=1, seed=next(seedg))
                    if not xp.is_incoherent:
                        yield xp