Package Bio :: Package GA :: Package Selection :: Module Diversity :: Class DiversitySelection
[hide private]
[frames] | no frames]

Class DiversitySelection

source code

                object --+    
                         |    
Abstract.AbstractSelection --+
                             |
                            DiversitySelection

Implement diversity selection.

Diversity selection is performed by trying to select individuals
from the population that aren't already in the new_population. A group
of selected individuals is then subjected to selection using
a passed selection routine.

If new individuals can not be selected, new individuals will be
randomly generated and inserted into the population.

Instance Methods [hide private]
 
__init__(self, internal_selector, genome_generator)
Initialize a diversity selector.
source code
 
_get_new_organism(self, new_pop, old_pop)
Get a new organism from old_pop that isn't in new_pop.
source code
 
select(self, population)
Perform selection on the current population, encouraging diversity.
source code

Inherited from Abstract.AbstractSelection: mutate_and_crossover

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, internal_selector, genome_generator)
(Constructor)

source code 
Initialize a diversity selector.

Arguments:

o internal_selector - A selection object that will be used to select
individuals based on fitness, perform crossover, mutation and repair.

o genome_generator - A function that, when called, will return a
genome to be used for a new organism. The genome returned must
be a MutableSeq() object.

Overrides: object.__init__

_get_new_organism(self, new_pop, old_pop)

source code 
Get a new organism from old_pop that isn't in new_pop.

This attempts to select an organism from old_pop that isn't in
new_pop. If we can't do this in the number of tries specified
by the class attribute random_tries, we generate a new random
organism and return that.

select(self, population)

source code 
Perform selection on the current population, encouraging diversity.
        

Overrides: Abstract.AbstractSelection.select