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.
Methods
|
|
__init__
_set_up_wheel
select
|
|
__init__
|
__init__ (
self,
mutator,
crossover,
repairer=None,
)
Initialize the selector.
Arguments:
mutator -- A Mutation object which will perform mutation
on an individual.
crossover -- A Crossover object which will take two
individuals and produce two new individuals which may
have had crossover occur.
repairer -- A class which can do repair on rearranged genomes
to eliminate infeasible individuals. If set at None, so repair
will be done.
|
|
_set_up_wheel
|
_set_up_wheel ( self, population )
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:
[.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.
|
|
select
|
select ( self, population )
Perform selection on the population based using a Roulette model.
Arguments:
|
|