Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CMA variants by Risto #1391

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions nevergrad/optimization/experimentalvariants.py
Original file line number Diff line number Diff line change
Expand Up @@ -354,3 +354,43 @@
# High-Speed variants
HSDE = DifferentialEvolution(high_speed=True).set_name("HSDE", register=True)
LhsHSDE = DifferentialEvolution(initialization="LHS", high_speed=True).set_name("LhsHSDE", register=True)

# CMA variants built by Risto.
# The four configurations obtained on yasmallbbob (CMA1 is supposed to be the best).
# 49 --solver=CMA-ES --scale=0.4151 --popsize_factor=9 --elitist=False --diagonal=False --fcmaes=True --random_init=False
# 35 --solver=CMA-ES --scale=0.3177 --popsize_factor=7 --elitist=False --diagonal=False --fcmaes=True --random_init=False
# 10 --solver=CMA-ES --scale=6.1404 --popsize_factor=8 --elitist=True --diagonal=False --fcmaes=False --random_init=False
# 60 --solver=CMA-ES --scale=0.4267 --popsize_factor=9 --elitist=False --diagonal=False --fcmaes=True --random_init=False
CMA1 = ParametrizedCMA(scale=0.4151, popsize_factor=9, elitist=False, diagonal=False, fcmaes=True).set_name(
"CMA1", register=True
)
CMA2 = ParametrizedCMA(scale=0.3177, popsize_factor=7, elitist=False, diagonal=False, fcmaes=True).set_name(
"CMA2", register=True
)
CMA3 = ParametrizedCMA(scale=6.1404, popsize_factor=8, elitist=True, diagonal=False, fcmaes=False).set_name(
"CMA3", register=True
)
CMA4 = ParametrizedCMA(scale=0.4267, popsize_factor=9, elitist=False, diagonal=False, fcmaes=True).set_name(
"CMA4", register=True
)
# The four configurations obtained on yabbob.
# 51 --solver=CMA-ES --scale=0.3739 --popsize_factor=3 --elitist=False --diagonal=False --fcmaes=False
# --random_init=False
# 45 --solver=CMA-ES --scale=0.3607 --popsize_factor=3 --elitist=False --diagonal=False --fcmaes=False
##--random_init=False
# 44 --solver=CMA-ES --scale=0.4699 --popsize_factor=3 --elitist=False --diagonal=False --fcmaes=False
# --random_init=False
# 27 --solver=CMA-ES --scale=0.6221 --popsize_factor=4 --elitist=False --diagonal=False --fcmaes=False
# --random_init=False
CMA5 = ParametrizedCMA(scale=0.3739, popsize_factor=3, elitist=False, diagonal=False, fcmaes=False).set_name(
"CMA5", register=True
)
CMA6 = ParametrizedCMA(scale=0.3607, popsize_factor=3, elitist=False, diagonal=False, fcmaes=False).set_name(
"CMA6", register=True
)
CMA7 = ParametrizedCMA(scale=0.4699, popsize_factor=3, elitist=False, diagonal=False, fcmaes=False).set_name(
"CMA7", register=True
)
CMA8 = ParametrizedCMA(scale=0.6221, popsize_factor=4, elitist=False, diagonal=False, fcmaes=False).set_name(
"CMA8", register=True
)
11 changes: 9 additions & 2 deletions nevergrad/optimization/optimizerlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -419,8 +419,11 @@ def __init__(
super().__init__(parametrization, budget=budget, num_workers=num_workers)
self._config = ParametrizedCMA() if config is None else config
pop = self._config.popsize
self._popsize = max(num_workers, 4 + int(3 * np.log(self.dimension))) if pop is None else pop
# internal attributes
self._popsize = (
max(num_workers, 4 + int(self._config.popsize_factor * np.log(self.dimension)))
if pop is None
else pop
) # internal attributes
self._to_be_asked: tp.Deque[np.ndarray] = deque()
self._to_be_told: tp.List[p.Parameter] = []
self._num_spawners = self._popsize // 2 # experimental, for visualization
Expand Down Expand Up @@ -532,6 +535,8 @@ class ParametrizedCMA(base.ConfiguredOptimizer):
popsize: Optional[int] = None
population size, should be n * self.num_workers for int n >= 1.
default is max(self.num_workers, 4 + int(3 * np.log(self.dimension)))
popsize_factor: float = 3.
factor in the formula for computing the population size
diagonal: bool
use the diagonal version of CMA (advised in big dimension)
high_speed: bool
Expand All @@ -554,6 +559,7 @@ def __init__(
scale: float = 1.0,
elitist: bool = False,
popsize: tp.Optional[int] = None,
popsize_factor: float = 3.0,
diagonal: bool = False,
high_speed: bool = False,
fcmaes: bool = False,
Expand All @@ -567,6 +573,7 @@ def __init__(
self.scale = scale
self.elitist = elitist
self.popsize = popsize
self.popsize_factor = popsize_factor
self.diagonal = diagonal
self.fcmaes = fcmaes
self.high_speed = high_speed
Expand Down
8 changes: 8 additions & 0 deletions nevergrad/optimization/recorded_recommendations.csv
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,14 @@ AvgRandomSearch,1.7163318206,-1.0929434198,-0.5715059829,0.2691248199,,,,,,,,,,,
BPRotationInvariantDE,-0.5273201105,-0.156805946,-1.2551455501,3.327306828,2.3993996197,1.2830831401,0.8566151549,-1.6450076557,,,,,,,,
CM,1.0082049151,-0.9099785499,-1.025147209,1.2046460074,,,,,,,,,,,,
CMA,1.012515477,-0.9138805701,-1.029555946,1.2098418178,,,,,,,,,,,,
CMA1,0.4202951745,-0.3793470828,-0.4273579891,0.5021865062,,,,,,,,,,,,
CMA2,0.321676167,-0.2903362279,-0.3270817469,0.384352332,,,,,,,,,,,,
CMA3,3.0816966941,0.8525817234,3.9346279048,3.2381549254,,,,,,,,,,,,
CMA4,0.432040354,-0.3899479649,-0.4393005395,0.5162201451,,,,,,,,,,,,
CMA5,0.3785795368,-0.3416999452,-0.3849509682,0.4523598557,,,,,,,,,,,,
CMA6,0.3652143325,-0.3296367217,-0.3713608297,0.4363899437,,,,,,,,,,,,
CMA7,0.4757810226,-0.4294324799,-0.483788339,0.5685046702,,,,,,,,,,,,
CMA8,0.6298858782,-0.5685251027,-0.640486754,0.7526425949,,,,,,,,,,,,
CMandAS2,1.012515477,-0.9138805701,-1.029555946,1.2098418178,,,,,,,,,,,,
CMandAS3,0.4729858315,-0.6814343973,0.2424455578,-1.7007994128,,,,,,,,,,,,
CauchyLHSSearch,-0.527971877,1.341890246,2.6790716005,3.5963545262,,,,,,,,,,,,
Expand Down