-
Notifications
You must be signed in to change notification settings - Fork 48
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
Default Scoring Functions for Sphere, Rastrigin, Arm and Brax environments #73
Merged
Merged
Changes from 1 commit
Commits
Show all changes
56 commits
Select commit
Hold shift + click to select a range
a75970b
first commit - push a draft of the strcuture and arm and rastrigin tasks
limbryan fb5c5a2
complete arm and standard functions - rastrigin, sphere, rastrigin-proj
limbryan e314310
adding create_brax_scoring_function_fn to make scoring functions for …
Lookatator 0aa9d55
Merge branch 'feat/default_tasks' of github.com:adaptive-intelligent-…
Lookatator 418d2bc
add test for default standard functions
limbryan c28ec64
add test for default arm task and test make better docstring for arm
limbryan ab7edd0
add rastrigin proj test as well
limbryan 4f38cb4
fix weird styling issues to do with types for the tests script
limbryan ff4847c
adding function for init controllers, and a function for creating def…
Lookatator 34ac363
simpler metrics_fn + fix type of bd_extractor
Lookatator 15b931c
fix catch of return of init_population_controllers
Lookatator 2ce365e
add Docstrings
Lookatator a24ff3c
fix metadata notebook
Lookatator 7323ce7
fix import scoring function in notebook
Lookatator 3c83225
add init file into tasks directory, create an examples folder for scr…
limbryan 5d5ded3
update README to be a usable readme that uses the arm function instea…
limbryan d62baa6
upload new benchmark functions from QDbenchmark workshop with corresp…
limbryan c750ae1
add README for summary of tasks in the directory along wiht some desc…
limbryan c7f5f64
fix implementation hypervolume functions
Lookatator b1fb1f1
adding run_me() example function
Lookatator 3a04dc4
adding basis functions qd_suite benchmarking
Lookatator 632ff41
fix keymanagement in noisy arm and add option to add noise on params …
limbryan e44c7b8
Merge branch 'feat/default_tasks' of https://github.com/adaptive-inte…
limbryan 93fdadd
add draft of tasks summary README
338d7c2
refactoring benchmarking functions
Lookatator fa1acf0
fix key splitting in noisy arm task and references to hypervolume fun…
03a7702
improve plotting plot_multidimensional_map_elites_grid when using hig…
Lookatator b4a5a31
add default tasks qd_suite
Lookatator 53c206a
Merge branch 'feat/default_tasks' of github.com:adaptive-intelligent-…
Lookatator 460b5a8
completing description of QD Suite functions
Lookatator 22ffba8
move all qd_suite tasks
Lookatator 3639982
fix README latex
Lookatator 3e38f11
fix README latex
Lookatator c40b939
move default tasks to qd_suite __init__
Lookatator b865988
add example usage qd_suite tasks
Lookatator 6dab609
add example usage hypervolume functions
Lookatator 57d0d51
add examples for standard function
Lookatator 3c1419c
example BRAX usage
Lookatator 41831a5
add test for qd suite tasks
7371d35
Merge branch 'feat/default_tasks' of https://github.com/adaptive-inte…
5be8b0d
add test for qd suite tasks
f33ea17
remove type aliases
Lookatator 4b1f333
specify type of grid_shape
Lookatator 6e0baa7
Merge remote-tracking branch 'origin/develop' into feat/default_tasks
Lookatator 73d32ce
fix styling issue
Lookatator 75a456c
add Docstrings default scores
Lookatator c299e4f
Mention QDax tasks doc in the main README
Lookatator 1908362
stochastic arm -> noisy arm
Lookatator 169d1ac
add task specific test for arm
limbryan f5b88fb
Merge branch 'develop' into feat/default_tasks
Lookatator ed52ea6
Merge branch 'feat/default_tasks' of github.com:adaptive-intelligent-…
Lookatator 57e0caa
reformat tests/default_tasks_test/arm_test.py
Lookatator 1f08215
complete missing descriptor bounds
felixchalumeau fd98af0
QDSuiteTask inherits from abc.ABC instead of using ABCMeta
Lookatator 76cc8a5
Merge branch 'feat/default_tasks' of github.com:adaptive-intelligent-…
Lookatator 1de5311
create examples folder with notebooks and scripts
Lookatator File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
add test for default arm task and test make better docstring for arm
- Loading branch information
commit c28ec64f5c048f73d6d91f54bed0ddea8fcc5913
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
"""Test default rastrigin using MAP Elites""" | ||
|
||
import functools | ||
|
||
import jax | ||
import pytest | ||
|
||
from qdax.core.containers.mapelites_repertoire import compute_euclidean_centroids | ||
from qdax.core.emitters.mutation_operators import isoline_variation | ||
from qdax.core.emitters.standard_emitters import MixingEmitter | ||
from qdax.core.map_elites import MAPElites | ||
from qdax.tasks.arm import arm_scoring_function, noisy_arm_scoring_function | ||
from qdax.utils.metrics import default_qd_metrics | ||
|
||
scoring_functions = { | ||
"arm": arm_scoring_function, | ||
"noisy_arm": functools.partial( | ||
noisy_arm_scoring_function, fit_variance=0.1, desc_variance=0.1 | ||
), | ||
} | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"task_name, batch_size", | ||
[("arm", 1), ("noisy_arm", 10)], | ||
) | ||
def test_arm(task_name: str, batch_size: int) -> None: | ||
seed = 42 | ||
num_param_dimensions = 100 # num DoF arm | ||
init_batch_size = 100 | ||
batch_size = batch_size | ||
num_iterations = 5 | ||
grid_shape = (100, 100) | ||
min_param = 0.0 | ||
max_param = 1.0 | ||
min_bd = 0.0 | ||
max_bd = 1.0 | ||
|
||
# Init a random key | ||
random_key = jax.random.PRNGKey(seed) | ||
|
||
# Init population of controllers | ||
random_key, subkey = jax.random.split(random_key) | ||
init_variables = jax.random.uniform( | ||
subkey, | ||
shape=(init_batch_size, num_param_dimensions), | ||
minval=min_param, | ||
maxval=max_param, | ||
) | ||
|
||
# Prepare the scoring function | ||
scoring_fn = scoring_functions[task_name] | ||
|
||
# Define emitter | ||
variation_fn = functools.partial( | ||
isoline_variation, | ||
iso_sigma=0.05, | ||
line_sigma=0.1, | ||
minval=min_param, | ||
maxval=max_param, | ||
) | ||
mixing_emitter = MixingEmitter( | ||
mutation_fn=lambda x, y: (x, y), | ||
variation_fn=variation_fn, | ||
variation_percentage=1.0, | ||
batch_size=batch_size, | ||
) | ||
|
||
# Define a metrics function | ||
metrics_fn = functools.partial( | ||
default_qd_metrics, | ||
qd_offset=0.0, | ||
) | ||
|
||
# Instantiate MAP-Elites | ||
map_elites = MAPElites( | ||
scoring_function=scoring_fn, | ||
emitter=mixing_emitter, | ||
metrics_function=metrics_fn, | ||
) | ||
|
||
# Compute the centroids | ||
centroids = compute_euclidean_centroids( | ||
grid_shape=grid_shape, | ||
minval=min_bd, | ||
maxval=max_bd, | ||
) | ||
|
||
# Compute initial repertoire | ||
repertoire, emitter_state, random_key = map_elites.init( | ||
init_variables, centroids, random_key | ||
) | ||
|
||
# Run the algorithm | ||
(repertoire, emitter_state, random_key,), metrics = jax.lax.scan( | ||
map_elites.scan_update, | ||
(repertoire, emitter_state, random_key), | ||
(), | ||
length=num_iterations, | ||
) | ||
|
||
pytest.assume(repertoire is not None) | ||
|
||
|
||
if __name__ == "__main__": | ||
test_arm(task_name="arm", batch_size=128) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file looks more like testing MAP-Elites rather than arm task. Maybe we could think about just a few simple tests that check the implementation works as expected.