CMA-ES / pycma

Python implementation of CMA-ES
Other
1.1k stars 178 forks source link

CPU bottleneck when benchmarking with large population size #232

Open nikohansen opened 1 year ago

nikohansen commented 1 year ago

When the objective function is quick to optimize, the bottleneck is (still) the SolutionDict.

Replacing the SolutionDict (which maps back the phenotypes to genotypes in tell) with an empty class like

import cma

cma.evolution_strategy._CMASolutionDict = cma.evolution_strategy._CMASolutionDict_empty

gives a more than six times faster execution when the population size is large as shown below. This changes the algorithm when boundary handling is applied (or when the gp attribute represents not the identity for some other reason), so whether this is the case needs to be carefully checked in each case.

Times recorded by the notebook cells and shown in the printed lines for running 20 iterations with popsize 3000:

Screenshot 2023-04-04 at 21 45 20

We may also want to investigate whether the SolutionDict implementation can still be improved.