Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
02/03/15 14:29:06 (9 years ago)
Author:
mkommend
Message:

#2268: Merged r11494, r11495, r11496, r11497, r11498, r11504, r11532, r11536 into stable.

Location:
stable
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • stable

  • stable/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding

  • stable/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/CutPoint.cs

    r11170 r11874  
    2323namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding {
    2424  public class CutPoint {
    25     public ISymbolicExpressionTreeNode Parent { get; set; }
    26     public ISymbolicExpressionTreeNode Child { get; set; }
    27     private int childIndex;
    28     public int ChildIndex {
    29       get { return childIndex; }
    30     }
    31     public CutPoint(ISymbolicExpressionTreeNode parent, ISymbolicExpressionTreeNode child) {
     25    public ISymbolicExpressionTreeNode Parent { get; private set; }
     26    public ISymbolicExpressionTreeNode Child { get; private set; }
     27    private readonly ISymbolicExpressionTreeGrammar grammar;
     28
     29    public int ChildIndex { get; private set; }
     30
     31    public CutPoint(ISymbolicExpressionTreeNode parent, ISymbolicExpressionTreeNode child) {     
    3232      this.Parent = parent;
    3333      this.Child = child;
    34       this.childIndex = parent.IndexOfSubtree(child);
     34      this.ChildIndex = parent.IndexOfSubtree(child);
     35      this.grammar = parent.Grammar;
    3536    }
    3637    public CutPoint(ISymbolicExpressionTreeNode parent, int childIndex) {
    3738      this.Parent = parent;
    38       this.childIndex = childIndex;
     39      this.ChildIndex = childIndex;
    3940      this.Child = null;
     41      this.grammar = parent.Grammar;
    4042    }
    4143
     
    4446      if (newChild == null) {
    4547        // 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 &&
     48        return grammar.GetMinimumSubtreeCount(parent.Symbol) < parent.SubtreeCount &&
    4749          this.ChildIndex == parent.SubtreeCount - 1;
    4850      } else {
    4951        // 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        if (!grammar.ContainsSymbol(newChild.Symbol) ||
     53            !grammar.IsAllowedChildSymbol(parent.Symbol, newChild.Symbol, this.ChildIndex))
    5254          return false;
    5355
     
    5759          result =
    5860            result &&
    59             parent.Grammar.ContainsSymbol(n.Symbol) &&
    60             n.SubtreeCount >= parent.Grammar.GetMinimumSubtreeCount(n.Symbol) &&
    61             n.SubtreeCount <= parent.Grammar.GetMaximumSubtreeCount(n.Symbol);
     61            grammar.ContainsSymbol(n.Symbol) &&
     62            n.SubtreeCount >= grammar.GetMinimumSubtreeCount(n.Symbol) &&
     63            n.SubtreeCount <= grammar.GetMaximumSubtreeCount(n.Symbol);
    6264        });
    6365        return result;
Note: See TracChangeset for help on using the changeset viewer.