#508·deap

Direct evaluation of batches of individuals?

Author: pabloprfCreated Sep 10, 2020Updated Jun 14, 2024

Not sure if this is a naive question, but... is there a way for DEAP to send a batch of individuals (e.g. entire population at the current generation) to the evaluator instead of doing one by one? I know that there are parallelization strategies like scoop and multiprocessing, but I think it can be extremely effective if I were able to make operations on many individuals at a time (e.g. using numpy, pandas, torch... and many others already made very effective at dealing with multidimensional arrays).

Naive example, assuming that individuals have dimensions batch x dim, return the mean of the design variables:

# Standard one-by-one evaluation
def myEvaluator(ind):
       return np.mean(ind)
for x in individuals: print( myEvaluator(x) )

# All at once 
def myEvaluator(ind):
       return np.mean(ind,axis=1)
print( myEvaluator(individuals) )