google / evojax

Apache License 2.0
826 stars 78 forks source link

Add FPGPEC and minor fix of FCRFMC #51

Closed dietmarwo closed 1 year ago

dietmarwo commented 1 year ago

This PR adds another algorithm implementation, FPGPEC, wrapping the fcmaes C++ PGPE implementation complementing and derived from pgpe.py. Benchmark results at https://github.com/dietmarwo/fast-cma-es/blob/master/tutorials/EvoJax.adoc now include FPGPEC results.

Tested on my AMD 5950x + Nvidia 3090, it performs as well as its JAX-equivalent. For lower dimensions (slimevolley), weak GPU or on a pure CPU backend it is significantly faster although utilizing only a single CPU thread.

During testing I found out that random generation plays an important role:

Finally I replaced the random generator used for all fcmaes algorithms by [EigenRand]https://github.com/bab2min/EigenRand which solved the issue. This also affects CRFMNES which should by slightly faster after an "pip install fcmaes --upgrade".

Additionally this PR unifies the FCRFMC, CRFMNES and FPGPEC initialization by adding the "init_params" parameter supported already by PGPE.

Note that (as for FCRFMC) a gcc-9 runtime is required, which easily can be added to older linux installations in Anaconda using conda-forge: "conda install -c conda-forge gxx_linux-64==9.5.0". And you need fcmaes version 1.4.7 ("pip install fcmaes --upgrade").

Minor fix of FCRFMC: Forgot that fitness is maximised, assigned the wrong solution - the worst of the final population. Results shown at https://github.com/dietmarwo/fast-cma-es/blob/master/tutorials/EvoJax.adoc are not affected since I use only the (correct) fitness value there.

Minor fix of sim_mgr.py: Got /home/xxx/git/evojax/evojax/sim_mgr.py:380: FutureWarning: jax.tree_map is deprecated, and will be removed in a future release. Use jax.tree_util.tree_map instead.

Since we have

from jax.tree_util import tree_map

we just need to remove the 'jax.'