diff --git a/repelling/cec.ipynb b/repelling/cec.ipynb index 83551e4..d24181c 100644 --- a/repelling/cec.ipynb +++ b/repelling/cec.ipynb @@ -58,7 +58,8 @@ "1116: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, \n", "1117: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, \n", "1118: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, \n", - "1119: 0, 1, 2, 3, 4, " + "1119: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, \n", + "1120: 0, " ] } ], diff --git a/repelling/collect_bbob.py b/repelling/collect_bbob.py new file mode 100644 index 0000000..c09618b --- /dev/null +++ b/repelling/collect_bbob.py @@ -0,0 +1,69 @@ +import argparse +import time +import sys + +import ioh +import numpy as np +import pandas as pd + +import modcma.c_maes as c_cmaes + + + +if __name__ == "__main__": + parser = argparse.ArgumentParser() + parser.add_argument("--fid", type=int, default=21) + parser.add_argument("--dim", type=int, default=2) + parser.add_argument("--n_instances", type=int, default=10) + parser.add_argument("--n_runs", type=int, default=100) + parser.add_argument("--elitist", action="store_true") + parser.add_argument("--repelling", action="store_true") + parser.add_argument("--logged", action="store_true") + parser.add_argument("--verbose", action="store_true") + parser.add_argument("--coverage", type=float, default=10.0) + parser.add_argument("--budget", type=int, default=10_000) + args = parser.parse_args() + + + + algorithm_name = "CMA-ES" + if args.repelling: + algorithm_name += f"-repelling-c{args.coverage}" + if args.elitist: + algorithm_name += "-elitist" + + if args.logged: + logger = ioh.logger.Analyzer( + root="data", algorithm_name=algorithm_name, folder_name=algorithm_name + ) + + modules = c_cmaes.parameters.Modules() + modules.restart_strategy = c_cmaes.options.RESTART + modules.center_placement = c_cmaes.options.UNIFORM + modules.bound_correction = c_cmaes.options.SATURATE + modules.repelling_restart = args.repelling + modules.elitist = args.elitist + + centers = [] + for instance in range(1, args.n_instances + 1): + problem = ioh.get_problem(args.fid, instance, args.dim) + if args.logged: + problem.attach_logger(logger) + + for run in range(args.n_runs): + c_cmaes.utils.set_seed(42 * run) + settings = c_cmaes.parameters.Settings( + args.dim, + modules, + sigma0=2.0, + budget=args.dim * args.budget, + target=problem.optimum.y + 1e-8, + ) + + parameters = c_cmaes.Parameters(settings) + parameters.repelling.coverage = args.coverage + cma = c_cmaes.ModularCMAES(parameters) + cma.run(problem) + centers.append((instance, run, cma.p.stats.centers)) + breakpoint() +