Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
02/24/12 17:30:16 (12 years ago)
Author:
bburlacu
Message:

#1772: Merged changes from trunk, rigged the TournamentSelector to track clones, improved tracking code.

Location:
branches/HeuristicLab.EvolutionaryTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.EvolutionaryTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • branches/HeuristicLab.EvolutionaryTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/CutPoint.cs

    r7439 r7522  
    2222
    2323namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding {
    24   internal class CutPoint {
     24  public class CutPoint {
    2525    public ISymbolicExpressionTreeNode Parent { get; set; }
    2626    public ISymbolicExpressionTreeNode Child { get; set; }
     
    3939      this.Child = null;
    4040    }
     41
     42    public bool IsMatchingPointType(ISymbolicExpressionTreeNode newChild) {
     43      var parent = this.Parent;
     44      if (newChild == null) {
     45        // make sure that one subtree can be removed and that only the last subtree is removed
     46        return parent.Grammar.GetMinimumSubtreeCount(parent.Symbol) < parent.SubtreeCount &&
     47          this.ChildIndex == parent.SubtreeCount - 1;
     48      } else {
     49        // check syntax constraints of direct parent - child relation
     50        if (!parent.Grammar.ContainsSymbol(newChild.Symbol) ||
     51            !parent.Grammar.IsAllowedChildSymbol(parent.Symbol, newChild.Symbol, this.ChildIndex))
     52          return false;
     53
     54        bool result = true;
     55        // check point type for the whole branch
     56        newChild.ForEachNodePostfix((n) => {
     57          result =
     58            result &&
     59            parent.Grammar.ContainsSymbol(n.Symbol) &&
     60            n.SubtreeCount >= parent.Grammar.GetMinimumSubtreeCount(n.Symbol) &&
     61            n.SubtreeCount <= parent.Grammar.GetMaximumSubtreeCount(n.Symbol);
     62        });
     63        return result;
     64      }
     65    }
    4166  }
    4267}
Note: See TracChangeset for help on using the changeset viewer.