Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
02/10/09 12:59:37 (15 years ago)
Author:
gkronber
Message:

merged r1200 and r1209 from CEDMA refactoring branch into trunk. #479 (Crossover operators create trees that are larger than the allowed max size)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.GP/Recombination/SizeConstrictedGPCrossoverBase.cs

    r1197 r1212  
    5050      int tries = 0;
    5151      do {
     52        if (tries++ > MaxRecombinationTries)
     53          // if after so many tries it was not possible to create a solution within the given size constraints just return the tree without changes.
     54          return tree0;
    5255        if (tree0.SubTrees.Count > 0) {
    5356          newTree = Cross(gardener, random, (IFunctionTree)tree0.Clone(), (IFunctionTree)tree1.Clone(), maxTreeSize, maxTreeHeight);
     
    5558          newTree = Cross(gardener, random, (IFunctionTree)tree1.Clone(), (IFunctionTree)tree0.Clone(), maxTreeSize, maxTreeHeight);
    5659        } else newTree = tree0;
    57         if (tries++ > MaxRecombinationTries)
    58           throw new InvalidOperationException("Couldn't recombine parents to create a valid child not larger than " + maxTreeSize + " and not higher than " + maxTreeHeight + ".");
    5960      } while (newTree.Size > maxTreeSize || newTree.Height > maxTreeHeight);
    6061      return newTree;
Note: See TracChangeset for help on using the changeset viewer.