Skip to content

Commit

Permalink
Allow overriding ES in sphere example
Browse files Browse the repository at this point in the history
  • Loading branch information
btjanaka committed Dec 9, 2023
1 parent ff84fd2 commit ca62008
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions examples/sphere.py
Original file line number Diff line number Diff line change
Expand Up @@ -757,6 +757,7 @@ def sphere_main(algorithm,
itrs=None,
archive_dims=None,
learning_rate=None,
es=None,
outdir="sphere_output",
log_freq=250,
seed=None):
Expand All @@ -768,6 +769,8 @@ def sphere_main(algorithm,
itrs (int): Iterations to run.
archive_dims (tuple): Dimensionality of the archive.
learning_rate (float): The archive learning rate.
es (str): If passed, this will set the ES for all
EvolutionStrategyEmitter instances.
outdir (str): Directory to save output.
log_freq (int): Number of iterations to wait before recording metrics
and saving heatmap.
Expand All @@ -791,6 +794,12 @@ def sphere_main(algorithm,
if learning_rate is not None:
config["archive"]["kwargs"]["learning_rate"] = learning_rate

# Set ES for all EvolutionStrategyEmitter.
if es is not None:
for e in config["emitters"]:
if e["class"] == EvolutionStrategyEmitter:
e["kwargs"]["es"] = es

name = f"{algorithm}_{config['dim']}"
outdir = Path(outdir)
if not outdir.is_dir():
Expand Down

0 comments on commit ca62008

Please sign in to comment.