deap

Python Deap library, how to access initRepeat mapping

∥☆過路亽.° 提交于 2019-12-11 07:28:14
问题 What I want my algorithm to do I want to have a bunch of random words as individuals in my population, whos fitness is compared to an "optimal" word. If the length of the words are equivalent, that's +1 in fitness. For each char that is the same, that's also +1 in fitness, +1.1 if it is in the same index. Unfortunately I'm having a really though time understanding deaps docs. This is what I have tried among other things so far. Attempted Code from deap import creator from deap import tools

How to add elimination mechanism in Python genetic algorithm based on DEAP

99封情书 提交于 2019-12-11 02:42:06
问题 Here is my question. I'm dealing with one optimization problem using DEAP. For now, I use toolbox.register("select", tools.selNSGA2) to select some fittest indivual to survive. But I want to add some threshold by user-defined function. Can the algorithm achieve two step of selection? Select several individuals by the tournament or selNSGA2 method Eliminate several individuals by pre-defined thresholds. 回答1: This should work. def myselect(pop, k, check): return [ind for in in tools.selNSGA2

Deap python package: create individuals with different ranges and mix of integers and floats

十年热恋 提交于 2019-12-03 16:18:13
I am trying to use DEAP to maximise a function. I understand how to do it with the basic example: toolbox.register("attr_bool", random.randint, 0, 1) toolbox.register("individual", tools.initRepeat, creator.Individual, toolbox.attr_bool, 100) which creates 100 random values or either 0 or 1. You then go on and create a population and mutate ... How do you build a population when you have for example two parameters: parameter 1 integer with range [0,1] parameter 2 float with range [0,2] Then create an individual combining both randomly sampled parameters? or for parameter 2 sample with an

Using DEAP (genetic algorithm library) with spark

倖福魔咒の 提交于 2019-12-01 00:18:39
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. 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

Using DEAP (genetic algorithm library) with spark

蓝咒 提交于 2019-11-30 18:31:06
问题 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. 回答1: 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