Changeset 1200


Ignore:
Timestamp:
02/03/09 17:35:58 (12 years ago)
Author:
gkronber
Message:

Set probability of creating larger trees to zero when max-tree size is reached in SizeFairCrossOver #479 (Crossover operators create trees that are larger than the allowed max size).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/CEDMA-Refactoring-Ticket419/HeuristicLab.GP/Recombination/SizeFairCrossOver.cs

    r1196 r1200  
    8383      if (shorterBranches.Count > 0 && longerBranches.Count > 0) {
    8484        double pEqualLength = equalLengthBranches.Count > 0 ? 1.0 / removedBranchSize : 0.0;
    85         double pLonger = (1.0 - pEqualLength) / (longerBranches.Count * (1.0 + longerBranches.Average(p => p.branchSize) / shorterBranches.Average(p => p.branchSize)));
     85        double pLonger;
     86        if (parent.Size == maxTreeSize) {
     87          pLonger = 0.0;
     88        } else {
     89          pLonger = (1.0 - pEqualLength) / (longerBranches.Count * (1.0 + longerBranches.Average(p => p.branchSize) / shorterBranches.Average(p => p.branchSize)));
     90        }
    8691        double pShorter = (1.0 - pEqualLength - pLonger);
    8792
Note: See TracChangeset for help on using the changeset viewer.