Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using DEAP (genetic algorithm library) with spark

Is IT possible to use DEAP ( http://deap.readthedocs.io/en/master/) with a spark cluster to map the fitness evaluation function. I would like to run a GA but the fitness function is rather long and I was planning on distributing it on a spark cluster.

like image 995
Julien Denos Avatar asked Sep 25 '26 08:09

Julien Denos


1 Answers

You should look at the Using Multiple Processors section in the DEAP documentation and at this example. They explain how to replace the map function in the DEAP toolbox by a map function of your choice.

To use pyspark to map the fitness evaluation function, you could do something like that:

from pyspark import SparkContext

sc = SparkContext(appName="DEAP")

def sparkMap(algorithm, population):
    return sc.parallelize(population).map(algorithm)

toolbox.register("map", sparkMap)
like image 169
frenchoverflow Avatar answered Sep 28 '26 23:09

frenchoverflow