icaros-usc / pyribs

A bare-bones Python library for quality diversity optimization.
https://pyribs.org
MIT License
208 stars 32 forks source link

[BUG] Negative eigenvalues in the covariance matrix of CMA-ES #285

Closed vbhatt-cs closed 1 year ago

vbhatt-cs commented 1 year ago

Description

When running QD search with CMA-MAE, the minimum eigenvalue of the covariance matrix became negative and the maximum eigenvalue became extremely high (~1e16). The emitter should have restarted based on the condition number but didn't since the negative eigenvalue made the condition number negative. This led to the square root being NaN here and a causing an error downstream.

Steps to Reproduce

QD search was a part of a larger project, so I am not sure how to reproduce it outside that.

Fix

The CMA-ES code in the original CMA-MAE implementation takes the absolute value of the eigenvalues (https://github.com/icaros-usc/cma_mae/blob/28a2757dcfe34b24ee0fe60635954381987e3078/ribs/emitters/opt/_cma_es.py#L59) before any further calculations. Adding it here fixes the issue since the emitter restarts properly.