Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Range of individuals in CMA-ES #200

Closed
osm3000 opened this issue May 14, 2017 · 5 comments
Closed

Range of individuals in CMA-ES #200

osm3000 opened this issue May 14, 2017 · 5 comments

Comments

@osm3000
Copy link

osm3000 commented May 14, 2017

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

  1. How can I control the 'length' of the individual (the length of the list representing the individual?
  2. How can I control the range of individuals' values? (I want the genes of the individuals - the elements in the list - to be constrained in a certain range.

Thank you in advance

@sarajcev
Copy link

sarajcev commented May 15, 2017

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)

@osm3000
Copy link
Author

osm3000 commented May 15, 2017

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?

@sarajcev
Copy link

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.

@fmder
Copy link
Member

fmder commented May 15, 2017 via email

@fmder
Copy link
Member

fmder commented May 15, 2017

This is more an question than an issue, please use the mailing list for such conversations.

@fmder fmder closed this as completed May 15, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants