Closed osm3000 closed 7 years ago
Example (where creator.Individual has been already created using creator.create):
toolbox.register("attribute", random.randint, 0, 100)
toolbox.register("individual", tools.initRepeat, creator.Individual, toolbox.attribute, n=3)
To answer you second question: The first line of code creates an "attribute" of the "individual", which is a random integer number bounded between 0 and 100. To answer your first question: While registering an "individual" you can pass the argument (n=3), which is the "length" of the individual. The "population" list of 100 "individuals" (each of length "n=3") can now be created as follows:
toolbox.register("population", tools.initRepeat, list, toolbox.individual)
population = toolbox.population(n=100)
Thank you @sarajcev for your reply.
I understand what you said in case of evolutionary algorithms, but not in case of evolutionary strategies. In the examples provided, the population is not generated explicitly
creator.create("Individual", list, fitness=creator.FitnessMin)
then directly:
strategy = cma.Strategy(centroid=[5.0]*N, sigma=5.0, lambda_=20*N) toolbox.register("generate", strategy.generate, creator.Individual) toolbox.register("update", strategy.update)
So this explicit generation I didn't see in case of CMA-ES examples.
Is my observation correct? or am I missing something?
It seems I've misunderstood your question.
I believe that the "N" in the code strategy = cma.Strategy(centroid=[5.0]*N, sigma=5.0, lambda_=20*N)
is the size of the individual.
The reason for the discrepancy between the two type of algorithms is because evolution strategies generate the populations randomly while adjusting the distribution parameters. Evolutionary algorithms for their part modify (mate and mutate) actual individuals using natural selection.
In evolutionary computation in general, the number of generated individuals each generation is usually noted lambda while the number of selected individuals is mu.
Le 15 mai 2017 05:35, "sarajcev" notifications@github.com a écrit :
It seems I've misunderstood your question.
I believe that the "N" in the code strategy = cma.Strategy(centroid=[5.0]N, sigma=5.0, lambda_=20N) is the size of the individual.
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/DEAP/deap/issues/200#issuecomment-301425525, or mute the thread https://github.com/notifications/unsubscribe-auth/AA6rwkSnHkPSHA-QePJryJbnOikyio4Xks5r6BxsgaJpZM4NagGq .
This is more an question than an issue, please use the mailing list for such conversations.
Hi everyone,
I am new to DEAP. I've two quick questions about the CMA-ES example https://github.com/DEAP/deap/blob/759473d39dc307aa986f6035bbc5a8fd5e058db3/examples/es/cma_minfct.py
Thank you in advance