Perform n-point crossover between genomes at some defined rates.
Ideas on how to use this class:
- Call it directly ( construct, do_crossover )
- Use one of the provided subclasses
- Inherit from it:
replace _generate_locs with a more domain
specific technique
replace _crossover with a more efficient
technique for your point-count
Methods
|
|
__init__
_crossover
_generate_locs
do_crossover
|
|
__init__
|
__init__ (
self,
points,
crossover_prob=.1,
)
Initialize to do crossovers at the specified probability.
|
|
_crossover
|
_crossover (
self,
x,
no,
locs,
)
Generalized Crossover Function:
arguments:
x (int) - genome number [0|1]
no (organism,organism)
- new organisms
locs (int list, int list)
- lists of locations,
[0, +n points+, bound]
for each genome (sync'd with x) return type: sequence (to replace no[x])
|
|
_generate_locs
|
_generate_locs ( self, bound )
Generalized Location Generator:
arguments:
bound (int) - upper bound
returns: [0]+x_0...x_n+[bound]
where n=self._npoints-1
and 0 < x_0 < x_1 ... < bound
|
|
do_crossover
|
do_crossover (
self,
org_1,
org_2,
)
Potentially do a crossover between the two organisms.
|
|