A bare-bones Python library for quality diversity optimization.

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 = [
x0=[0.0] * 10,

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 for the Sphere function

Easy Installation

pyribs supports Python 3.6-3.9. The full version of pyribs adds the visualize module.