This module contains the GPopulation.GPopulation class, which is reponsible to keep the population and the statistics.
Sort Type
>>> Consts.sortType["scaled"]The scaled sort type
Minimax
>>> Consts.minimaxType["maximize"]Maximize the evaluation function
Scale Method
The Linear Scaling scheme
GPopulation Class - The container for the population
>>> pop = ga_engine.getPopulation()
>>> bestIndividual = pop.bestFitness()
>>> bestIndividual = pop.bestRaw()
>>> stats = pop.getStatistics()
>>> print stats["rawMax"]
10.4
>>> for ind in pop:
>>> print ind
(...)
>>> for i in xrange(len(pop)):
>>> print pop[i]
(...)
>>> pop[10] = newGenome
>>> pop[10].fitness
12.5
Parameter: | genome – the Sample genome, or a GPopulation object, when cloning. |
---|
Return the best scaled fitness individual of population
Parameter: | index – the index best individual |
---|---|
Return type: | the individual |
Return the best raw score individual of population
Parameter: | index – the index best raw individual |
---|---|
Return type: | the individual |
New in version 0.6: The parameter index.
Copy current population to ‘pop’
Parameter: | pop – the destination population |
---|
Warning
this method do not copy the individuals, only the population logic
Evaluate all individuals in population, calls the evaluate() method of individuals
Parameter: | args – this params are passed to the evaluation function |
---|
Gets an internal parameter
>>> population.getParam("tournamentPool")
5
Parameters: |
|
---|
Return a Statistics class for statistics
Return type: | the Statistics.Statistics instance |
---|
Scale the population using the scaling method
Parameter: | args – this parameter is passed to the scale method |
---|
Sets the population minimax
>>> pop.setMinimax(Consts.minimaxType["maximize"])
Parameter: | minimax – the minimax type |
---|
Sets the flag to enable/disable the use of python multiprocessing module. Use this option when you have more than one core on your CPU and when your evaluation function is very slow. The parameter “full_copy” defines where the individual data should be copied back after the evaluation or not. This parameter is useful when you change the individual in the evaluation function.
Parameters: |
|
---|
Warning
Use this option only when your evaluation function is slow, se you will get a good tradeoff between the process communication speed and the parallel evaluation.
New in version 0.6: The setMultiProcessing method.
Gets an internal parameter
>>> population.setParams(tournamentPool=5)
Parameter: | args – parameters to set |
---|
New in version 0.6: The setParams method.
Set the population size
Parameter: | size – the population size |
---|
Sets the sort type
>>> pop.setSortType(Consts.sortType["scaled"])
Parameter: | sort_type – the Sort Type |
---|
A key function to return fitness score, used by max()/min()
Parameter: | individual – the individual instance |
---|---|
Return type: | the individual fitness score |
Note
this function is used by the max()/min() python functions
A key function to return raw score
Parameter: | individual – the individual instance |
---|---|
Return type: | the individual raw score |
Note
this function is used by the max()/min() python functions