Module crossover
[hide private]
[frames] | no frames]

Module crossover

source code

crossover

All crossover related operations. In the context of strongly-typed Genetic Programming, this operator is heavily modified to produce offsprings that are compliant with multiple rules and constraints set by the user. In the present version, only a strongly-typed version of Koza 1 point crossover is supported.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.


Author: by Mehdi Khoury

Version: 1.20

Copyright: (c) 2009 Mehdi Khoury under the mit license http://www.opensource.org/licenses/mit-license.html

Contact: mehdi.khoury at gmail.com

Functions [hide private]
 
Koza1PointCrossover(maxdepth, p1, p2, p1_mp, p2_mp, p1_depth, p2_depth)
create 2 offsprings from 2 parents using a modified version of Koza-1-point crossover.
source code
 
Koza2PointsCrossover(maxdepth, parent1, parent2, p1_map, p2_map, p1_depth, p2_depth) source code
Variables [hide private]
  __package__ = None
Function Details [hide private]

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