Where communities thrive

  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
Repo info
  • Dec 02 21:08
    SyrexMinus edited #678
  • Dec 02 21:07
    SyrexMinus edited #678
  • Dec 02 20:54
    SyrexMinus commented #491
  • Dec 02 20:54
    SyrexMinus commented #491
  • Dec 02 20:53
    SyrexMinus commented #491
  • Dec 02 20:48
    SyrexMinus opened #678
  • Nov 30 12:37
    romanovzky commented #677
  • Nov 30 12:29
    romanovzky commented #677
  • Nov 29 21:57
    romanovzky opened #677
  • Nov 17 15:22
    r8vnhill commented #676
  • Nov 16 16:33
    r8vnhill opened #676
  • Nov 05 14:04
    fmder commented #675
  • Nov 05 14:04
    fmder closed #675
  • Nov 03 05:54
    Dineshgvs closed #670
  • Nov 03 05:51
    Dineshgvs opened #675
  • Oct 30 23:44
    ethantenison commented #667
  • Oct 30 23:38
    ethantenison opened #674
  • Oct 26 08:01
    romanovzky commented #673
  • Oct 25 14:37
    fmder commented #673
  • Oct 18 14:06
    romanovzky opened #673
Hmmm, it seems that fit_attr must be a type of DEAP class Fitness in order to access that .values?
How can I have multiple gene types ?
I need 2 floats, 1 bool and 1 int
lol this chat is so dead
Nirvana Dogra
Can I use DEAP to do a time series prediction ?
François-Michel De Rainville
@xCuri0 There is a tutorial for that in the documentation
@NirvanaDogra yes, plenty of people use GA to analyse data for the financial market
@jcbro not the best place to post code try the mailing list with gist or Pastebin
Nirvana Dogra
I am pretty new to this field and am working with GP to predict time series data. I am no being able to understand how can I create a expression by looking data.
François-Michel De Rainville
@NirvanaDogra isn't it some kind of regression then with the obtained function you enter a time in the future? There might be more than one way.
Nirvana Dogra
@fmder Thank you, for answering to my questions but can you please tell, where I can read about this topic to get greater details about this. If you know of some Git Repo which I can view to get some insight do let me know. Thanks.
maybe not the best place to ask, but... any advice on which Python neural network library to use with DEAP? I need to train a NN by maximizing the result of a simulation
François-Michel De Rainville
@Nitrooo your description is way too vague, a better place to ask this would be DEAP users mailing list.
Franek Magiera
Hello everyone :) !
I am working on a problem that requires creating a function with n inputs and k outputs. From what I know a GP tree can have only one output, so I thought I would use a list of k trees each getting the same n inputs and producing one of the k outputs.
It seems like a good idea but I am hesitant if it is a correct approach. How will crossover and mutation operators work in case of a list of trees? Will that make sense? Maybe there is a better way?
Source code I have so far below:
pset = gp.PrimitiveSet("MAIN", arity=n, prefix='x')
pset.addPrimitive(operators.addition, 2)
pset.addPrimitive(operators.subtract, 2)
pset.addPrimitive(operators.multiply, 2)
# and many more...
# One optimization objective.
creator.create("FitnessMin", base.Fitness, weights=(-1.0,))
# Arithmetic expression.
creator.create("Tree", gp.PrimitiveTree, pset=pset)
# Individual is a list consisting of n_components trees.
creator.create("Individual", list, fitness=creator.FitnessMin)

toolbox = base.Toolbox()
toolbox.register("expr", gp.genHalfAndHalf, pset=pset, min_=MIN_TREE_HEIGHT, max_=MAX_TREE_HEIGHT)
toolbox.register("tree", tools.initIterate, creator.Tree, toolbox.expr)
toolbox.register("individual", tools.initRepeat, creator.Individual, toolbox.tree, n=pop_size)

# Population.
toolbox.register("population", tools.initRepeat, list, toolbox.individual)
Hi, I am working with genetic algorithm in DEAP. I want to parallelize the evalution part that's why I am using multiprocessing. The problem is evaluation function works for only one individual and after that it throws an error above ( Can't pickle <function evaluation at 0x000001ED70DA28C8>: it's not the same object as ga_evaluation.evaluation). How can I solve this issue, any ideas?
François-Michel De Rainville
@franekmagiera I think you should mate and mutate trees by pair using a for loop on zip(individual1, individual2)
François-Michel De Rainville
@buseoz_gitlab That is a function pickling problem. Functions are tricky to pickle, but from you error message here is what I would try first : https://stackoverflow.com/questions/1412787/picklingerror-cant-pickle-class-decimal-decimal-its-not-the-same-object
Philipp Kraus
Hello, I'm new with EAP, but I have got a very complex individual (as a class), My class has got a mutate and combine method and a method which return two fitness values which should be maximized. In my case the constructure of the class need some initializing parameters. I don't find a tutorial which explain to use the Toolbox with a individual class. Can anybody help me?
Xiao Liang
Almost all toolbox methods are user-defined? If I am not mistaken. If so, there's no need to use toolbox at all?
Philipp Kraus
I need only the "population creation" and the "individual selection" calls from the toolbox, I would like to use the SwarmParticle System https://deap.readthedocs.io/en/master/examples/pso_basic.html because I have got 2 maximazing parameters
In my case I need an own generator which returns a list of my class individuals, an own mutate & combine function and an own evaluate function
How can I do this?
Xiao Liang
@flashpixx IIRC, population creation and individual selection functionality shown in the tutorials using toolbox are all user-defined. The purpose of toolbox is simply providing one level of abstraction which doesn't add any(?) on top of the user-defined functions.
FullStack Engineer
@fmder Is multiprocessing working with deap in python3.6?
deap is surely the most complicated ga package...not clear
Why the population size in the onemax examples decreases from 300 as the starting population size to 180 in the last generation?
Oren Amsalem
Hello, how can I use the history class to extract the generation number from an individual?
Francisco Palomares
Hi, How can I create a condition based on a list of numbers in python, for example that the second component of the list always has to be greater than the third one?
François-Michel De Rainville
@Terahertz0 this column is the number of evaluations, some individuals are copied as is, this they are not reevaluated.
@FranciscoPalomares use the feasibility function as in the constraint tutorial.
Francisco Palomares
def feasible(individual):
    """Feasability function for the individual. Returns True if feasible False
    if int(individual[2]) < int(individual[1]):
        return True
    return False

toolbox.register("evaluate", evalOneMax)
toolbox.decorate("evaluate", tools.DeltaPenality(feasible,7.0))
7.0 is necessary? @fmder . If I don't insert 7 it gives me an error
Francisco Palomares
Hi, How can I apply diversity to the population? in multiple generations the individuals in the population are almost equal
François-Michel De Rainville

@FranciscoPalomares Documentation for DeltaPenalty and tutorial . 7.0 is the penalty applied to invalid individuals. It is a required argument.

Diversity strongly depends on your response domain. If your population converges too fast you can try to play with crossover and mutation parameters. Moreover having selection with randomness (like tournament with a low number of participant) may help.

Hananel Hazan
Hello, thanks for this wonderful tool!
I have two parameters that I want to maximize with some fitness function. But each parameter has a certain limit to its range, i.e. parameter value is limit between -1 to 100, and parameter b range limit is between -50 to -10.
How can I limit the evolution of values to a certain range?
Thanks to the helpers :-)
François-Michel De Rainville
@Hananel-Hazan Hey, you can either use soft constraints, operators that handle bounds (bounded operators), or repair in your evaluation function.
Hananel Hazan
Thanks @fmder
François-Michel De Rainville
@nbro I suggest you try to run the first few lines of the symbreg and generate individuals one at a time to see what they look like.
You'll get a sense of how it works. From there you can move to ant (which is a lot more complex)
Simo Alami
Hi ! Thank you for this great tool. In my case, the evaluate function includeson a neural network and each individual is the weights of the network. for each indivual i perform model.predict(individual). It works fine but when I can't find how to make it work using multiprocessing. Is there someone who already did this and has an example on how to do it ? thanks.
mohammad saleh tabari

Hi everyOne, I am new to DEAP library. I am trying to make an independent evolutionary core that works with the external app. This is a process I want to have:
1.Population variables and their fitness values production in an external app
2.passing the Population and fitness to the DEAP core to do the selection, mutation, and mating process and making a new offspring.
3.passing the offsprings to the external app and, as a response getting the fitness value.

And doing this process in a loop to reach the final goal. The problem that I have is that I don't, know how can I create a population from defined individual values. In all examples, POPULATIONS are created from random functions. Is there any way to generate a population from a defined set of variables and defining the fitness attribute for them?

Hello everyone! I would like to insert a "while" loop operator in a genetic programming configuration. How can I do that?
Jason Zutty
Hey, I am noticing some issues with the deap version in pypi, namely the windows version of 1.3.1 when installed with pip doesn't seem to match the source code. This is evident in tools.emo.selTournamentDCD if you look at the two cases that throw errors.
workflow, download tar.gz from pypi and check the file, vs install via pip and browse to sitepackages and check the file
Jason Zutty
Sorry mis-remembered. the tarball matches, but different distributions are ahead of the tarball and match the source from git, while the windows and the tar seem similar but don't match the git and say linux or mac.
Hi, I am using deap library to apply genetic algorithm (GA) in a problem. In particular generations of GA (for example, gen =5 and 10) I want to add a number of individuals (suppose 3 individuals) to the population and remove the same number of other individuals (again 3 individuals but different from the added individuals) from the population. That is, I want to manually import several individuals and delete several other individuals and keep the size of population constant. The type of individuals is list of lists and the population is a list of individuals. When I do the above action, I get the error: "AttributeError: 'list' object has no attribute 'fitness'." I have checked the population before and after the above action several times and the characteristics of population are completely the same before and after changing its individuals. That is, the population before and after changing is a list of individuals and individuals are list of lists. But, if I don't apply the above action the GA is implemented without any error however after changing the individuals of the population I get the error. Could you please help me to resolve this problem?
Martin West
Hello, Has anyone checked DEAP on python 3.10? I've hit a problem with a pip install
2 replies
Ethan Tenison
Can anyone tell me what reference points are used for in NSGAIII? How is it created? I'm trying to optimize the outputs of a multioutput regression problem (3+). Also, I'm new to optimization problems, so there's a lot of vocabulary that I don't know.