in nevergrad/benchmark/experiments.py [0:0]
def yawidebbob(seed: tp.Optional[int] = None) -> tp.Iterator[Experiment]:
"""Yet Another Wide Black-Box Optimization Benchmark.
The goal is basically to have a very wide family of problems: continuous and discrete,
noisy and noise-free, mono- and multi-objective, constrained and not constrained, sequential
and parallel.
TODO(oteytaud): this requires a significant improvement, covering mixed problems and different types of constraints.
"""
seedg = create_seed_generator(seed)
total_xp_per_optim = 0
# Continuous case
# First, a few functions with constraints.
functions = [
ArtificialFunction(name, block_dimension=50, rotation=rotation, translation_factor=tf)
for name in ["cigar", "ellipsoid"]
for rotation in [True, False]
for tf in [0.1, 10.0]
]
for i, func in enumerate(functions):
func.parametrization.register_cheap_constraint(_Constraint("sum", as_bool=i % 2 == 0))
assert len(functions) == 8
# Then, let us build a constraint-free case. We include the noisy case.
names = ["hm", "rastrigin", "sphere", "doublelinearslope", "ellipsoid"]
# names += ["deceptiveillcond", "deceptivemultimodal", "deceptivepath"]
functions += [
ArtificialFunction(
name, block_dimension=d, rotation=rotation, noise_level=nl, split=split, translation_factor=tf
)
for name in names # period 5
for rotation in [True, False] # period 2
for nl in [0.0, 100.0] # period 2
for tf in [0.1, 10.0]
for num_blocks in [1, 8] # period 2
for d in [5, 70, 10000] # period 4
for split in [True, False] # period 2
][
::37
] # 37 is coprime with all periods above so we sample correctly the possibilities.
assert len(functions) == 21, f"{len(functions)} problems instead of 21. Yawidebbob should be standard."
# This problem is intended as a stable basis forever.
# The list of optimizers should contain only the basic for comparison and "baselines".
optims: tp.List[str] = ["NGOpt10"] + get_optimizers("baselines", seed=next(seedg)) # type: ignore
index = 0
for function in functions:
for budget in [50, 1500, 25000]:
for nw in [1, budget] + ([] if budget <= 300 else [300]):
index += 1
if index % 5 == 0:
total_xp_per_optim += 1
for optim in optims:
xp = Experiment(function, optim, num_workers=nw, budget=budget, seed=next(seedg))
if not xp.is_incoherent:
yield xp
# Discrete, unordered.
index = 0
for nv in [200, 2000]:
for arity in [2, 7, 37]:
instrum = ng.p.TransitionChoice(range(arity), repetitions=nv)
for name in ["onemax", "leadingones", "jump"]:
index += 1
if index % 4 != 0:
continue
dfunc = ExperimentFunction(
corefuncs.DiscreteFunction(name, arity), instrum.set_name("transition")
)
dfunc.add_descriptors(arity=arity)
for budget in [500, 5000]:
for nw in [1, 100]:
total_xp_per_optim += 1
for optim in optims:
yield Experiment(dfunc, optim, num_workers=nw, budget=budget, seed=next(seedg))
# The multiobjective case.
# TODO the upper bounds are really not well set for this experiment with cigar
mofuncs: tp.List[fbase.MultiExperiment] = []
for name1 in ["sphere", "ellipsoid"]:
for name2 in ["sphere", "hm"]:
for tf in [0.25, 4.0]:
mofuncs += [
fbase.MultiExperiment(
[
ArtificialFunction(name1, block_dimension=7),
ArtificialFunction(name2, block_dimension=7, translation_factor=tf),
],
upper_bounds=np.array((100.0, 100.0)),
)
]
mofuncs[-1].add_descriptors(num_objectives=2)
for name1 in ["sphere", "ellipsoid"]:
for name2 in ["sphere", "hm"]:
for name3 in ["sphere", "hm"]:
for tf in [0.25, 4.0]:
mofuncs += [
fbase.MultiExperiment(
[
ArtificialFunction(name1, block_dimension=7, translation_factor=1.0 / tf),
ArtificialFunction(name2, block_dimension=7, translation_factor=tf),
ArtificialFunction(name3, block_dimension=7),
],
upper_bounds=np.array((100.0, 100.0, 100.0)),
)
]
mofuncs[-1].add_descriptors(num_objectives=3)
index = 0
for mofunc in mofuncs[::3]:
for budget in [2000, 8000]:
for nw in [1, 100]:
index += 1
if index % 5 == 0:
total_xp_per_optim += 1
for optim in optims:
yield Experiment(mofunc, optim, budget=budget, num_workers=nw, seed=next(seedg))
assert total_xp_per_optim == 55, "We should have 55 xps per optimizer, not {total_xp_per_optim}."