Skip to content

Commit

Permalink
data colleciton
Browse files Browse the repository at this point in the history
  • Loading branch information
jacobdenobel committed Apr 17, 2024
1 parent 7d0b107 commit faafe9a
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 1 deletion.
3 changes: 2 additions & 1 deletion repelling/cec.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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, "
]
}
],
Expand Down
69 changes: 69 additions & 0 deletions repelling/collect_bbob.py
Original file line number Diff line number Diff line change
@@ -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()

0 comments on commit faafe9a

Please sign in to comment.