Base class for Selector classes.
This classes provides useful functions for different selector classes
and also defines the functions that all selector classes must
implement.
This class should not be used directly, but rather should be subclassed.
Methods
|
|
__init__
mutate_and_crossover
select
|
|
__init__
|
__init__ (
self,
mutator,
crossover,
repairer=None,
)
Initialize a 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.
|
|
mutate_and_crossover
|
mutate_and_crossover (
self,
org_1,
org_2,
)
Perform mutation and crossover on the two organisms.
This uses the classes mutator and crossover functions to
perform the manipulations.
If a repair class is available, then the rearranged genomes will
be repaired to make them feasible.
The newly created individuals are returned.
|
|
select
|
select ( self, population )
Exceptions
|
|
NotImplementedError( "Derived classes must implement." )
|
|
|