Changeset 11499 for branches/HeuristicLab.EvolutionTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/CutPoint.cs
- Timestamp:
- 10/24/14 18:48:25 (10 years ago)
- Location:
- branches/HeuristicLab.EvolutionTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.EvolutionTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding
- Property svn:mergeinfo changed
/trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding merged: 11494-11497
- Property svn:mergeinfo changed
-
branches/HeuristicLab.EvolutionTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/CutPoint.cs
r11208 r11499 23 23 namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding { 24 24 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) { 32 32 this.Parent = parent; 33 33 this.Child = child; 34 this.childIndex = parent.IndexOfSubtree(child); 34 this.ChildIndex = parent.IndexOfSubtree(child); 35 this.grammar = parent.Grammar; 35 36 } 36 37 public CutPoint(ISymbolicExpressionTreeNode parent, int childIndex) { 37 38 this.Parent = parent; 38 this. childIndex = childIndex;39 this.ChildIndex = childIndex; 39 40 this.Child = null; 41 this.grammar = parent.Grammar; 40 42 } 41 43 … … 44 46 if (newChild == null) { 45 47 // 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 && 47 49 this.ChildIndex == parent.SubtreeCount - 1; 48 50 } else { 49 51 // 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)) 52 54 return false; 53 55 … … 57 59 result = 58 60 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); 62 64 }); 63 65 return result;
Note: See TracChangeset
for help on using the changeset viewer.