in benchmarks/run_cmaes_benchmarks.py [0:0]
def run_hartmann6_benchmarks(D, rep, random_subspace=False):
if D == 100:
problem = hartmann6_100
elif D == 1000 and not random_subspace:
problem = hartmann6_1000
elif D == 1000 and random_subspace:
problem = hartmann6_random_subspace_1000
experiment, f = benchmark_minimize_callable(
problem=problem,
num_trials=200,
method_name='cmaes',
replication_index=rep,
)
try:
cma.fmin(
objective_function=f,
x0=[0.5] * D,
sigma0=0.25,
options={'bounds': [[0] * D, [1] * D], 'maxfevals': 200},
)
except ValueError:
pass # CMA-ES doesn't always terminate at exactly maxfevals
rs_str = 'random_subspace_' if random_subspace else ''
with open(f'results/hartmann6_{rs_str}{D}_cmaes_rep_{rep}.json', "w") as fout:
json.dump(object_to_json(experiment), fout)