Skip to content

Commit 0eb81df

Browse files
authored
Merge pull request #160 from CyberAgentAILab/fix-bipop-cma
fix sigma setting
2 parents 3c471bc + 2a25966 commit 0eb81df

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

README.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,8 @@ if __name__ == "__main__":
327327
lower_bounds, upper_bounds = bounds[:, 0], bounds[:, 1]
328328

329329
mean = lower_bounds + (np.random.rand(2) * (upper_bounds - lower_bounds))
330-
sigma = 32.768 * 2 / 5 # 1/5 of the domain width
330+
sigma0 = 32.768 * 2 / 5 # 1/5 of the domain width
331+
sigma = sigma0
331332
optimizer = CMA(mean=mean, sigma=sigma, bounds=bounds, seed=0)
332333

333334
n_restarts = 0 # A small restart doesn't count in the n_restarts
@@ -363,11 +364,13 @@ if __name__ == "__main__":
363364
popsize = math.floor(
364365
popsize0 * popsize_multiplier ** (np.random.uniform() ** 2)
365366
)
367+
sigma = sigma0 * 10 ** (-2 * np.random.uniform())
366368
else:
367369
poptype = "large"
368370
n_restarts += 1
369371
popsize = popsize0 * (inc_popsize ** n_restarts)
370-
372+
sigma = sigma0
373+
371374
mean = lower_bounds + (np.random.rand(2) * (upper_bounds - lower_bounds))
372375
optimizer = CMA(
373376
mean=mean,

examples/bipop_cmaes.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ def main():
2020
lower_bounds, upper_bounds = bounds[:, 0], bounds[:, 1]
2121

2222
mean = lower_bounds + (rng.rand(2) * (upper_bounds - lower_bounds))
23-
sigma = 32.768 * 2 / 5 # 1/5 of the domain width
23+
sigma0 = 32.768 * 2 / 5 # 1/5 of the domain width
24+
sigma = sigma0
2425
optimizer = CMA(mean=mean, sigma=sigma, bounds=bounds, seed=0)
2526

2627
n_restarts = 0 # A small restart doesn't count in the n_restarts
@@ -57,10 +58,12 @@ def main():
5758
popsize = math.floor(
5859
popsize0 * popsize_multiplier ** (rng.uniform() ** 2)
5960
)
61+
sigma = sigma0 * 10 ** (-2 * rng.uniform())
6062
else:
6163
poptype = "large"
6264
n_restarts += 1
6365
popsize = popsize0 * (inc_popsize**n_restarts)
66+
sigma = sigma0
6467
mean = lower_bounds + (rng.rand(2) * (upper_bounds - lower_bounds))
6568
optimizer = CMA(
6669
mean=mean,

0 commit comments

Comments
 (0)