Efficient Illumination
pyribs is the official implementation of Covariance Matrix Adaptation MAP-Elites (CMA-ME), a quality diversity optimization algorithm.
Flexible Components
Every quality diversity (QD) algorithm in pyribs consists of three components.
from ribs.archives import GridArchive
archive = GridArchive(
dims=[20, 20],
ranges=[(-1, 1), (-1, 1)],
)
An Archive saves the best representatives generated within behavior space.
from ribs.emitters import ImprovementEmitter
emitters = [
ImprovementEmitter(
archive,
x0=[0.0] * 10,
sigma0=0.1,
)
]
Emitters control how new candidate solutions are generated and affect if the algorithm prioritizes quality or diversity.
from ribs.optimizers import Optimizer
optimizer = Optimizer(archive, emitters)
An Optimizer joins the Archive and Emitters together and acts as a scheduling algorithm for emitters.
Intuitive Usage
pyribs components come together in an intuitive ask-tell interface inspired by pycma.
import numpy as np
for itr in range(1000):
solutions = optimizer.ask()
# Optimize the 10D negative Sphere function.
objectives = -np.sum(np.square(solutions), axis=1)
# BCs: first 2 coordinates of each 10D solution.
bcs = solutions[:, :2]
optimizer.tell(objectives, bcs)
Insightful Visualizations
The pyribs visualize module integrates with Matplotlib to plot a heatmap of the archive after each experiment.
import matplotlib.pyplot as plt
from ribs.visualize import grid_archive_heatmap
grid_archive_heatmap(archive)
plt.show()

Easy Installation
pyribs supports Python 3.6-3.9. The full version of pyribs adds the visualize module.
Distribution
Package
Command
pip install ribs
pip install ribs[all]
conda install -c conda-forge pyribs-base
conda install -c conda-forge pyribs
git clone https://github.com/icaros-usc/pyribs
cd pyribs
pip install .
git clone https://github.com/icaros-usc/pyribs
cd pyribs
pip install .[all]
Comprehensive Tutorials
Learn more about pyribs in the tutorials. All tutorials are also available on Google Colab.