Package Bio :: Package GA :: Package Selection :: Module RouletteWheel :: Class RouletteWheelSelection
[hide private]
[frames] | no frames]

Class RouletteWheelSelection

source code

                object --+    
                         |    
Abstract.AbstractSelection --+
                             |
                            RouletteWheelSelection

Roulette wheel selection proportional to individuals fitness.

The implements a roulette wheel selector that selects individuals from the population, and performs mutation and crossover on the selected individuals.

Instance Methods [hide private]
 
__init__(self, mutator, crossover, repairer=None)
Initialize the selector.
source code
 
select(self, population)
Perform selection on the population based using a Roulette model.
source code
 
_set_up_wheel(self, population)
Set up the roulette wheel based on the fitnesses.
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, mutator, crossover, repairer=None)
(Constructor)

source code 

Initialize the selector.

Arguments:

o mutator -- A Mutation object which will perform mutation on an individual.

o crossover -- A Crossover object which will take two individuals and produce two new individuals which may have had crossover occur.

o repairer -- A class which can do repair on rearranged genomes to eliminate infeasible individuals. If set at None, so repair will be done.

Overrides: object.__init__

select(self, population)

source code 

Perform selection on the population based using a Roulette model.

Arguments:

o population -- A population of organisms on which we will perform selection. The individuals are assumed to have fitness values which are due to their current genome.

Overrides: Abstract.AbstractSelection.select

_set_up_wheel(self, population)

source code 

Set up the roulette wheel based on the fitnesses.

This creates a fitness proportional 'wheel' that will be used for selecting based on random numbers.

Returns:

o A dictionary where the keys are the 'high' value that an individual will be selected. The low value is determined by the previous key in a sorted list of keys. For instance, if we have a sorted list of keys like:

[.1, .3, .7, 1]

Then the individual whose key is .1 will be selected if a number between 0 and .1 is chosen, the individual whose key is .3 will be selected if the number is between .1 and .3, and so on.

The values of the dictionary are the organism instances.