Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
02/21/12 10:57:40 (12 years ago)
Author:
bburlacu
Message:

#1682: * Moved Swap method into base class

  • Simplified selection of allowed branches
  • Replaced while loop with a more simple reversed for loop
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.Crossovers/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Crossovers/SymbolicDataAnalysisExpressionCrossover.cs

    r7481 r7494  
    149149      return rows.Where(i => i < testPartitionStart || testPartitionEnd <= i);
    150150    }
     151
     152    protected static void Swap(CutPoint crossoverPoint, ISymbolicExpressionTreeNode selectedBranch) {
     153      if (crossoverPoint.Child != null) {
     154        // manipulate the tree of parent0 in place
     155        // replace the branch in tree0 with the selected branch from tree1
     156        crossoverPoint.Parent.RemoveSubtree(crossoverPoint.ChildIndex);
     157        if (selectedBranch != null) {
     158          crossoverPoint.Parent.InsertSubtree(crossoverPoint.ChildIndex, selectedBranch);
     159        }
     160      } else {
     161        // child is null (additional child should be added under the parent)
     162        if (selectedBranch != null) {
     163          crossoverPoint.Parent.AddSubtree(selectedBranch);
     164        }
     165      }
     166    }
    151167  }
    152168}
Note: See TracChangeset for help on using the changeset viewer.