Skip to content

Commit

Permalink
fix sigma setting
Browse files Browse the repository at this point in the history
  • Loading branch information
nomuramasahir0 committed Dec 28, 2023
1 parent 057798d commit 2a25966
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,8 @@ if __name__ == "__main__":
lower_bounds, upper_bounds = bounds[:, 0], bounds[:, 1]

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

n_restarts = 0 # A small restart doesn't count in the n_restarts
Expand Down Expand Up @@ -363,11 +364,13 @@ if __name__ == "__main__":
popsize = math.floor(
popsize0 * popsize_multiplier ** (np.random.uniform() ** 2)
)
sigma = sigma0 * 10 ** (-2 * np.random.uniform())
else:
poptype = "large"
n_restarts += 1
popsize = popsize0 * (inc_popsize ** n_restarts)

sigma = sigma0

mean = lower_bounds + (np.random.rand(2) * (upper_bounds - lower_bounds))
optimizer = CMA(
mean=mean,
Expand Down
5 changes: 4 additions & 1 deletion examples/bipop_cmaes.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ def main():
lower_bounds, upper_bounds = bounds[:, 0], bounds[:, 1]

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

n_restarts = 0 # A small restart doesn't count in the n_restarts
Expand Down Expand Up @@ -57,10 +58,12 @@ def main():
popsize = math.floor(
popsize0 * popsize_multiplier ** (rng.uniform() ** 2)
)
sigma = sigma0 * 10 ** (-2 * rng.uniform())
else:
poptype = "large"
n_restarts += 1
popsize = popsize0 * (inc_popsize**n_restarts)
sigma = sigma0
mean = lower_bounds + (rng.rand(2) * (upper_bounds - lower_bounds))
optimizer = CMA(
mean=mean,
Expand Down

0 comments on commit 2a25966

Please sign in to comment.