diff --git a/nevergrad/optimization/experimentalvariants.py b/nevergrad/optimization/experimentalvariants.py index 19d6a8994..8e1d14a28 100644 --- a/nevergrad/optimization/experimentalvariants.py +++ b/nevergrad/optimization/experimentalvariants.py @@ -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 +) diff --git a/nevergrad/optimization/optimizerlib.py b/nevergrad/optimization/optimizerlib.py index 47f7f07b3..8b8143abb 100644 --- a/nevergrad/optimization/optimizerlib.py +++ b/nevergrad/optimization/optimizerlib.py @@ -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 @@ -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 @@ -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, @@ -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 diff --git a/nevergrad/optimization/recorded_recommendations.csv b/nevergrad/optimization/recorded_recommendations.csv index c55bbdcf5..01c074006 100644 --- a/nevergrad/optimization/recorded_recommendations.csv +++ b/nevergrad/optimization/recorded_recommendations.csv @@ -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,,,,,,,,,,,,