Koza1PointCrossover(maxdepth,
p1,
p2,
p1_mp,
p2_mp,
p1_depth,
p2_depth)
| source code
|
Function: Koza1PointCrossover
create 2 offsprings from 2 parents using a modified version of
Koza-1-point crossover. This version try to produce offsprings
compliant with the constraints and rules used to build an individual.
If it does not manage, it produce a report showing if the offsprings
produced are compatible.
- Parameters:
maxdepth - maximum depth of the mutated offspring
p1 - parent tree 1 e.g.
a=buildtree.buildTree().AddHalfNode((0,2,'root'),0,2,7)
p2 - parent tree 2 e.g.
a=buildtree.buildTree().AddHalfNode((0,2,'root'),0,2,7)
p1_mp - parent tree index mapping e.g
a_map=crossutil.get_indices_mapping_from_tree(a)
p2_mp - parent tree index mapping e.g
a_map=crossutil.get_indices_mapping_from_tree(a)
p1_depth - parent tree depth e.g.
a_depth=crossutil.get_depth_from_indices_mapping(a_map)
p2_depth - parent tree depth e.g.
a_depth=crossutil.get_depth_from_indices_mapping(a_map)
- Returns:
- a tuple containing 3 elements
-
The first one is a list of 1 and 0 indicating if the first
and second offspring are rule compliant. [1,1,1,1]
frag2_leaf_compatible_p1 and frag1_leaf_compatible_p2 and
frag2_branch_compatible_p1 and frag1_branch_compatible_p2
[1,0,1,1] frag2_leaf_compatible_p1 and not
frag1_leaf_compatible_p2 and frag2_branch_compatible_p1 and
frag1_branch_compatible_p2 [1,1,0,1] frag2_leaf_compatible_p1
and frag1_leaf_compatible_p2 and not
frag2_branch_compatible_p1 and frag1_branch_compatible_p2 and
so on... This information can be use to decide if we want to
introduce non-compliant offsprings into the population.
-
The second one is the first offspring
-
The third one is the second offspring
|