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

Add GradientEmitter to support OMG-MEGA and OG-MAP-Elites #348

Merged
merged 55 commits into from
Sep 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
0e85f88
swap out mp for dask
yutaizhou Aug 21, 2023
da408da
add to history.md
yutaizhou Aug 21, 2023
873c834
Replace multiprocessing text
btjanaka Aug 21, 2023
28e5aca
add dask distributed to pip install list
yutaizhou Aug 21, 2023
22bbceb
install swig on separate line
yutaizhou Aug 21, 2023
34f58bb
edit history.md to include swig, and clean up imports in tutorial
yutaizhou Aug 21, 2023
817f246
take out dask call to LocalCluster
yutaizhou Aug 21, 2023
04e919e
Update HISTORY.md
btjanaka Aug 21, 2023
aead9da
Remove LocalCluster
btjanaka Aug 21, 2023
15f5a70
Note import
btjanaka Aug 21, 2023
dc15b4a
Revert image
btjanaka Aug 21, 2023
2a48e73
Update lunar_lander.ipynb
btjanaka Aug 21, 2023
5f3797b
grokked the pyribs dqd interface. starting to add functions for OMG-MEGA
yutaizhou Aug 22, 2023
21ef8e0
added omg-mega to test and import, first pass at {ask/tell}_dqd()
yutaizhou Aug 23, 2023
9a733c5
passed sphere archive coverage test. need to debug QD score being sup…
yutaizhou Aug 23, 2023
091c317
OG-MAP-Elites added
yutaizhou Aug 23, 2023
989cdcd
Merge branch 'omg-mega/emitter' of github.com:yutaizhou/pyribs into o…
yutaizhou Aug 23, 2023
7a5594c
more properties to make it more 0.5 like
yutaizhou Aug 24, 2023
73fdffc
make gradient_emitter accept initial solutions (xor x0)
yutaizhou Aug 24, 2023
c758bb5
vectorized isolinedd added!
yutaizhou Aug 24, 2023
c2de49d
gradient emitter test!
yutaizhou Aug 25, 2023
5280e9f
documentation for gradient_emitter
yutaizhou Aug 25, 2023
ed93866
forgot history.md
yutaizhou Aug 25, 2023
574c018
Merge branch 'master' into omg-mega/emitter
yutaizhou Aug 25, 2023
6fd5344
Merge remote-tracking branch 'remotes/upstream/master' into omg-mega/…
yutaizhou Sep 9, 2023
cc9fc68
updated HISTORY to reflect GradientEmitter
yutaizhou Sep 9, 2023
8786462
use np clip instead of max and min for noise clipping
yutaizhou Sep 9, 2023
2209f41
updated docstring for the various sigmas
yutaizhou Sep 9, 2023
c750067
updated docstring for iterations and ask_dqd() not returning just one…
yutaizhou Sep 9, 2023
fff7ff1
updated docstring for tell_dqd, particularly on jacobian batch shape
yutaizhou Sep 9, 2023
ea5b3cd
GradientOperator -> GradientOperatorEmitter
yutaizhou Sep 9, 2023
428286a
asarray validate for jacobian_batch. and don't use np.multiply
yutaizhou Sep 9, 2023
2d3c97e
extended docstring added
yutaizhou Sep 9, 2023
a866f1e
Merge branch 'master' into omg-mega/emitter
btjanaka Sep 10, 2023
d40d881
history
btjanaka Sep 10, 2023
9c1b575
Update call to validate_batch_args
btjanaka Sep 10, 2023
7609425
Make isort line length be 80 to match yapf
btjanaka Sep 10, 2023
dcb7a31
Remove yapf disable
btjanaka Sep 10, 2023
70c91a1
Fix pylint error in sphere.py
btjanaka Sep 10, 2023
1632a03
Add period
btjanaka Sep 10, 2023
b19d1cb
Add GradientOperatorEmitter to list in emitter docs
btjanaka Sep 10, 2023
f325be5
Comment on batch size
btjanaka Sep 10, 2023
608132a
Docstring edits
btjanaka Sep 10, 2023
32f8ef7
fix link to tell_dqd
btjanaka Sep 10, 2023
68f36f7
no default values for sigma0 and sigma_g. also take out shape checkin…
yutaizhou Sep 14, 2023
51ea8c5
sigma0 to sigma, changed pytest fname to reflect new classname for gr…
yutaizhou Sep 14, 2023
5fb221c
take out linebreak
yutaizhou Sep 15, 2023
ffc81c9
updated docstring for gradientOperator
yutaizhou Sep 21, 2023
51d4339
Merge branch 'omg-mega/emitter' of github.com:yutaizhou/pyribs into o…
btjanaka Sep 21, 2023
7ce06aa
Add see also to gradient arborescence emitter
btjanaka Sep 21, 2023
37b7ed5
Update leading docstring
btjanaka Sep 21, 2023
13b008f
Update top line
btjanaka Sep 21, 2023
1313a2f
Merge branch 'master' into omg-mega/emitter
btjanaka Sep 21, 2023
dedeb9d
Move history to new version
btjanaka Sep 21, 2023
0a125d7
isolinedd docstring
yutaizhou Sep 21, 2023
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
8 changes: 8 additions & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# History

## (Forthcoming)

### Changelog

#### API

- Add GradientOperatorEmitter to support OMG-MEGA and OG-MAP-Elites ({pr}`348`)

## 0.6.0

### Changelog
Expand Down
70 changes: 67 additions & 3 deletions examples/sphere.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@
- `cma_me_mixed`: GridArchive with EvolutionStrategyEmitter, where half (7) of
the emitter are using TwoStageRandomDirectionRanker and half (8) are
TwoStageImprovementRanker.
- `og_map_elites`: GridArchive with GradientOperatorEmitter, does not use
measure gradients.
- `omg_mega`: GridArchive with GradientOperatorEmitter, uses measure gradients.
- `cma_mega`: GridArchive with GradientArborescenceEmitter.
- `cma_mega_adam`: GridArchive with GradientArborescenceEmitter using Adam
Optimizer.
Expand Down Expand Up @@ -83,7 +86,8 @@

from ribs.archives import CVTArchive, GridArchive
from ribs.emitters import (EvolutionStrategyEmitter, GaussianEmitter,
GradientArborescenceEmitter, IsoLineEmitter)
GradientArborescenceEmitter, GradientOperatorEmitter,
IsoLineEmitter)
from ribs.schedulers import BanditScheduler, Scheduler
from ribs.visualize import cvt_archive_heatmap, grid_archive_heatmap

Expand Down Expand Up @@ -417,6 +421,66 @@
"kwargs": {}
}
},
"og_map_elites": {
"dim": 1_000,
"iters": 10_000,
"archive_dims": (100, 100),
"use_result_archive": False,
"is_dqd": True,
# Divide by 2 since half of the 36 solutions are used in ask_dqd(), and
# the other half are used in ask().
"batch_size": 36 // 2,
yutaizhou marked this conversation as resolved.
Show resolved Hide resolved
"archive": {
"class": GridArchive,
"kwargs": {
"threshold_min": -np.inf
}
},
"emitters": [{
"class": GradientOperatorEmitter,
"kwargs": {
"sigma": 0.5,
"sigma_g": 0.5,
"measure_gradients": False,
"normalize_grad": False,
},
"num_emitters": 1
}],
"scheduler": {
"class": Scheduler,
"kwargs": {}
}
},
"omg_mega": {
"dim": 1_000,
"iters": 10_000,
"archive_dims": (100, 100),
"use_result_archive": False,
"is_dqd": True,
# Divide by 2 since half of the 36 solutions are used in ask_dqd(), and
# the other half are used in ask().
"batch_size": 36 // 2,
btjanaka marked this conversation as resolved.
Show resolved Hide resolved
"archive": {
"class": GridArchive,
"kwargs": {
"threshold_min": -np.inf
}
},
"emitters": [{
"class": GradientOperatorEmitter,
"kwargs": {
"sigma": 0.0,
"sigma_g": 10.0,
"measure_gradients": True,
"normalize_grad": True,
},
"num_emitters": 1
}],
"scheduler": {
"class": Scheduler,
"kwargs": {}
}
},
"cma_mega": {
"dim": 1_000,
"iters": 10_000,
Expand Down Expand Up @@ -790,8 +854,8 @@ def sphere_main(algorithm,

# Plot metrics.
print(f"Algorithm Time (Excludes Logging and Setup): {non_logging_time}s")
for metric in metrics:
plt.plot(metrics[metric]["x"], metrics[metric]["y"])
for metric, values in metrics.items():
plt.plot(values["x"], values["y"])
plt.title(metric)
plt.xlabel("Iteration")
plt.savefig(
Expand Down
7 changes: 5 additions & 2 deletions ribs/emitters/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@
:toctree:

ribs.emitters.EvolutionStrategyEmitter
ribs.emitters.GradientArborescenceEmitter
ribs.emitters.GaussianEmitter
ribs.emitters.GradientArborescenceEmitter
ribs.emitters.GradientOperatorEmitter
ribs.emitters.IsoLineEmitter
ribs.emitters.EmitterBase
"""
Expand All @@ -26,12 +27,14 @@
from ribs.emitters._gaussian_emitter import GaussianEmitter
from ribs.emitters._gradient_arborescence_emitter import \
GradientArborescenceEmitter
from ribs.emitters._gradient_operator_emitter import GradientOperatorEmitter
from ribs.emitters._iso_line_emitter import IsoLineEmitter

__all__ = [
"EvolutionStrategyEmitter",
"GradientArborescenceEmitter",
"GaussianEmitter",
"GradientArborescenceEmitter",
"GradientOperatorEmitter",
"IsoLineEmitter",
"EmitterBase",
]
5 changes: 5 additions & 0 deletions ribs/emitters/_gradient_arborescence_emitter.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ class GradientArborescenceEmitter(EmitterBase):
calling :meth:`ask` and :meth:`tell` to communicate the gradient
information to the emitter.

See Also:

Our DQD tutorial goes into detail on how to use this emitter:
:doc:`/tutorials/tom_cruise_dqd`

Args:
archive (ribs.archives.ArchiveBase): An archive to use when creating and
inserting solutions. For instance, this can be
Expand Down
Loading