Free cookie consent management tool by TermsFeed Policy Generator

Changeset 7498


Ignore:
Timestamp:
02/21/12 11:13:16 (13 years ago)
Author:
bburlacu
Message:

#1682: SubtreeCrossover: Minor improvement inside the SelectCrossoverPoint method.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.Crossovers/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Crossovers/SubtreeCrossover.cs

    r7481 r7498  
    133133      List<CutPoint> leafCrossoverPoints = new List<CutPoint>();
    134134      parent0.Root.ForEachNodePostfix((n) => {
    135         if (n.Subtrees.Any() && n != parent0.Root) {
    136           foreach (var child in n.Subtrees) {
    137             if (child.GetLength() <= maxBranchLength &&
    138                 child.GetDepth() <= maxBranchDepth) {
    139               if (child.Subtrees.Any())
    140                 internalCrossoverPoints.Add(new CutPoint(n, child));
    141               else
    142                 leafCrossoverPoints.Add(new CutPoint(n, child));
    143             }
     135        if (n.Parent != null && n.Parent != parent0.Root) {
     136          if (n.GetLength() <= maxBranchLength && n.GetDepth() <= maxBranchDepth) {
     137            if (n.SubtreeCount > 0)
     138              internalCrossoverPoints.Add(new CutPoint(n.Parent, n));
     139            else
     140              leafCrossoverPoints.Add(new CutPoint(n.Parent, n));
    144141          }
    145142          // add one additional extension point if the number of sub trees for the symbol is not full
Note: See TracChangeset for help on using the changeset viewer.