The tasks directory provides default scoring_function's to import easily to perform experiments without the boilerplate code so that the main script is kept simple and is not bloated. It provides a set of fixed tasks that is not meant to be modified. If you are developing and require the flexibility of modifying the task and the details that come along with it, we recommend copying and writing your own custom scoring_function in your main script instead of importing from tasks.
The tasks directory also serves as a way to maintain a QD benchmark task suite that can be easily accessed. We implement several benchmark task across a range of domains. The tasks here are classical tasks from QD literature as well as more recent benchmarks tasks proposed at the QD Benchmarks Workshop at GECCO 2022.
| Task | Parameter Dimensions | Parameter Bounds | Descriptor Dimensions | Descriptor Bounds | Description |
|---|---|---|---|---|---|
| Arm | n | 2 | |||
| Noisy Arm | n | 2 |
Notes:
- the parameter space is normalized between
$[0,1]$ which corresponds to$[0,2\pi]$ - the descriptor space (end-effector x-y position) is normalized between
$[0,1]$
import jax
from qdax.tasks.arm import arm_scoring_function
key = jax.random.key(0)
# Get scoring function
scoring_fn = arm_scoring_function
# Get Task Properties (parameter space, descriptor space, etc.)
min_param, max_param = 0., 1.
min_desc, max_desc = 0., 1.
# Get initial batch of parameters
num_param_dimensions = ...
init_batch_size = ...
key, _subkey = jax.random.split(key)
initial_params = jax.random.uniform(
_subkey,
shape=(init_batch_size, num_param_dimensions),
minval=min_param,
maxval=max_param,
)
# Get number of descriptor dimensions
desc_size = 2| Task | Parameter Dimensions | Parameter Bounds | Descriptor Dimensions | Descriptor Bounds | Description |
|---|---|---|---|---|---|
| Sphere | n | 2 | |||
| Rastrigin | n | 2 | |||
| Rastrigin-Projection | n | 2 |
import jax
from qdax.tasks.standard_functions import sphere_scoring_function
key = jax.random.key(0)
# Get scoring function
scoring_fn = sphere_scoring_function
# Get Task Properties (parameter space, descriptor space, etc.)
min_param, max_param = 0., 1.
min_desc, max_desc = 0., 1.
# Get initial batch of parameters
num_param_dimensions = ...
init_batch_size = ...
key, _subkey = jax.random.split(key)
initial_params = jax.random.uniform(
_subkey,
shape=(init_batch_size, num_param_dimensions),
minval=min_param,
maxval=max_param,
)
# Get number of descriptor dimensions
desc_size = 2"Hypervolume-based Benchmark Functions for Quality Diversity Algorithms" by Jean-Baptiste Mouret
| Task | Parameter Dimensions | Parameter Bounds | Descriptor Dimensions | Descriptor Bounds | Description |
|---|---|---|---|---|---|
| Square | n | n | |||
| Checkered | n | n | |||
| Empty Circle | n | n | |||
| Non-continuous Islands | n | n | |||
| Continuous Islands | n | n |
import jax
from qdax.tasks.hypervolume_functions import square_scoring_function
key = jax.random.key(0)
# Get scoring function
scoring_fn = square_scoring_function
# Get Task Properties (parameter space, descriptor space, etc.)
min_param, max_param = 0., 1.
min_desc, max_desc = 0., 1.
# Get initial batch of parameters
num_param_dimensions = ...
init_batch_size = ...
key, _subkey = jax.random.split(key)
initial_params = jax.random.uniform(
_subkey,
shape=(init_batch_size, num_param_dimensions),
minval=min_param,
maxval=max_param,
)
# Get number of descriptor dimensions
desc_size = num_param_dimensions"Towards QD-suite: developing a set of benchmarks for Quality-Diversity algorithms" by Achkan Salehi and Stephane Doncieux
| Task | Parameter Dimensions | Parameter Bounds | Descriptor Dimensions | Descriptor Bounds | Description |
|---|---|---|---|---|---|
| archimedean-spiral-v0 | 1 |
|
1 (geodesic descriptor) 2 (euclidean descriptor) |
|
|
| SSF-v0 | Unbounded | 1 |
|
||
| deceptive-evolvability-v0 |
|
Bounded area including the two gaussian peaks | 1 |
import math
from qdax.tasks.qd_suite import archimedean_spiral_v0_angle_euclidean_task
task = archimedean_spiral_v0_angle_euclidean_task
# Get scoring function
scoring_fn = task.scoring_function
# Get Task Properties (parameter space, descriptor space, etc.)
min_param, max_param = task.get_min_max_params()
min_desc, max_desc = task.get_bounded_min_max_descriptor() # To consider bounded Descriptor space
# If the task has a descriptor space that is not bounded, then the unbounded descriptor
# space can be obtained via the following:
# min_descriptor, max_descriptor = task.get_min_max_descriptor()
# Get initial batch of parameters
initial_params = task.get_initial_parameters(batch_size=...)
# Get number of descriptor dimensions
desc_size = task.get_descriptor_size()QDax provides organized utilities for working with Brax environments in the context of Quality Diversity. The Brax integrations are now structured in a versioned manner to support both Brax v1 and v2 APIs:
tasks.brax.v1: Contains code compatible with Brax v1 APItasks.brax.v2: Contains code compatible with Brax v2 API
| Task | Parameter Dimensions | Parameter Bounds | Descriptor Dimensions | Descriptor Bounds | Description |
|---|---|---|---|---|---|
| pointmaze | NN params | Unbounded | 2 | ||
| hopper_uni | NN params | Unbounded | 1 | ||
| walker2d_uni | NN params | Unbounded | 2 | ||
| halfcheetah_uni | NN params | Unbounded | 2 | ||
| ant_uni | NN params | Unbounded | 4 | ||
| humanoid_uni | NN params | Unbounded | 2 | ||
| ant_omni | NN params | Unbounded | 2 | ||
| humanoid_omni | NN params | Unbounded | 2 | ||
| anttrap | NN params | Unbounded | 2 | ||
| antmaze | NN params | Unbounded | 2 |
Notes:
- The parameter dimensions for default Brax-RL tasks depend on the size and architecture of the neural network used and can be customized and changed easily. If not set, a network size of two hidden layers of size 64 is used.
- The Brax environments are now properly versioned to support both Brax v1 and v2 APIs.
For Brax v1:
import jax
import qdax.tasks.brax.v1 as environments
from qdax.tasks.brax.v1.env_creators import create_default_brax_task_components
# Create environment, policy network and scoring function
env_name = "ant_omni"
key = jax.random.key(0)
env, policy_network, scoring_fn = create_default_brax_task_components(
env_name=env_name,
key=key,
episode_length=100
)For Brax v2:
import jax
import qdax.tasks.brax.v2 as environments
from qdax.tasks.brax.v2.env_creators import create_default_brax_task_components
# Create environment, policy network and scoring function
env_name = "ant_omni"
key = jax.random.key(0)
env, policy_network, scoring_fn = create_default_brax_task_components(
env_name=env_name,
key=key,
episode_length=100
)See Brax v1 and Brax v2 notebooks for more detailed examples.
QDax provide utils to interact easily with the suite of environments implemented in Jumanji.