Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
10/24/14 18:48:25 (10 years ago)
Author:
bburlacu
Message:

#1772: Merged trunk changes.

Location:
branches/HeuristicLab.EvolutionTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding
Files:
3 deleted
9 edited
1 copied

Legend:

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

  • branches/HeuristicLab.EvolutionTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Creators/FullTreeCreator.cs

    r11208 r11499  
    3838    private const string MaximumSymbolicExpressionTreeLengthParameterName = "MaximumSymbolicExpressionTreeLength";
    3939    private const string MaximumSymbolicExpressionTreeDepthParameterName = "MaximumSymbolicExpressionTreeDepth";
    40     private const string SymbolicExpressionTreeGrammarParameterName = "SymbolicExpressionTreeGrammar";
    41     private const string ClonedSymbolicExpressionTreeGrammarParameterName = "ClonedSymbolicExpressionTreeGrammar";
    4240
    4341    #region Parameter Properties
     
    4947      get { return (IValueLookupParameter<IntValue>)Parameters[MaximumSymbolicExpressionTreeDepthParameterName]; }
    5048    }
    51 
    52     public IValueLookupParameter<ISymbolicExpressionGrammar> SymbolicExpressionTreeGrammarParameter {
    53       get { return (IValueLookupParameter<ISymbolicExpressionGrammar>)Parameters[SymbolicExpressionTreeGrammarParameterName]; }
    54     }
    55 
    56     public ILookupParameter<ISymbolicExpressionGrammar> ClonedSymbolicExpressionTreeGrammarParameter {
    57       get { return (ILookupParameter<ISymbolicExpressionGrammar>)Parameters[ClonedSymbolicExpressionTreeGrammarParameterName]; }
    58     }
    59 
    6049    #endregion
    6150    #region Properties
     
    6655    public IntValue MaximumSymbolicExpressionTreeLength {
    6756      get { return MaximumSymbolicExpressionTreeLengthParameter.ActualValue; }
    68     }
    69 
    70     public ISymbolicExpressionGrammar ClonedSymbolicExpressionTreeGrammar {
    71       get { return ClonedSymbolicExpressionTreeGrammarParameter.ActualValue; }
    7257    }
    7358
     
    8469      Parameters.Add(new ValueLookupParameter<IntValue>(MaximumSymbolicExpressionTreeDepthParameterName,
    8570        "The maximal depth of the symbolic expression tree (a tree with one node has depth = 0)."));
    86       Parameters.Add(new ValueLookupParameter<ISymbolicExpressionGrammar>(SymbolicExpressionTreeGrammarParameterName,
    87         "The tree grammar that defines the correct syntax of symbolic expression trees that should be created."));
    88       Parameters.Add(new LookupParameter<ISymbolicExpressionGrammar>(ClonedSymbolicExpressionTreeGrammarParameterName,
    89         "An immutable clone of the concrete grammar that is actually used to create and manipulate trees."));
    9071    }
    9172
     
    9475    }
    9576
    96     public override IOperation InstrumentedApply() {
    97       if (ClonedSymbolicExpressionTreeGrammarParameter.ActualValue == null) {
    98         SymbolicExpressionTreeGrammarParameter.ActualValue.ReadOnly = true;
    99         IScope globalScope = ExecutionContext.Scope;
    100         while (globalScope.Parent != null)
    101           globalScope = globalScope.Parent;
    102 
    103         globalScope.Variables.Add(new Variable(ClonedSymbolicExpressionTreeGrammarParameterName,
    104           (ISymbolicExpressionGrammar)SymbolicExpressionTreeGrammarParameter.ActualValue.Clone()));
    105       }
    106       return base.InstrumentedApply();
    107     }
    10877
    10978    protected override ISymbolicExpressionTree Create(IRandom random) {
    110       return Create(random, ClonedSymbolicExpressionTreeGrammar, MaximumSymbolicExpressionTreeLength.Value, MaximumSymbolicExpressionTreeDepth.Value);
     79      return Create(random, ClonedSymbolicExpressionTreeGrammarParameter.ActualValue, MaximumSymbolicExpressionTreeLength.Value, MaximumSymbolicExpressionTreeDepth.Value);
    11180    }
    11281
     
    12998      var rootNode = (SymbolicExpressionTreeTopLevelNode)grammar.ProgramRootSymbol.CreateTreeNode();
    13099      if (rootNode.HasLocalParameters) rootNode.ResetLocalParameters(random);
    131       rootNode.SetGrammar(new SymbolicExpressionTreeGrammar(grammar));
     100      rootNode.SetGrammar(grammar.CreateExpressionTreeGrammar());
    132101
    133102      var startNode = (SymbolicExpressionTreeTopLevelNode)grammar.StartSymbol.CreateTreeNode();
    134103      if (startNode.HasLocalParameters) startNode.ResetLocalParameters(random);
    135       startNode.SetGrammar(new SymbolicExpressionTreeGrammar(grammar));
     104      startNode.SetGrammar(grammar.CreateExpressionTreeGrammar());
    136105
    137106      rootNode.AddSubtree(startNode);
  • branches/HeuristicLab.EvolutionTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Creators/GrowTreeCreator.cs

    r11208 r11499  
    3838    private const string MaximumSymbolicExpressionTreeLengthParameterName = "MaximumSymbolicExpressionTreeLength";
    3939    private const string MaximumSymbolicExpressionTreeDepthParameterName = "MaximumSymbolicExpressionTreeDepth";
    40     private const string SymbolicExpressionTreeGrammarParameterName = "SymbolicExpressionTreeGrammar";
    41     private const string ClonedSymbolicExpressionTreeGrammarParameterName = "ClonedSymbolicExpressionTreeGrammar";
    4240
    4341    #region Parameter Properties
     
    4846    public IValueLookupParameter<IntValue> MaximumSymbolicExpressionTreeDepthParameter {
    4947      get { return (IValueLookupParameter<IntValue>)Parameters[MaximumSymbolicExpressionTreeDepthParameterName]; }
    50     }
    51 
    52     public IValueLookupParameter<ISymbolicExpressionGrammar> SymbolicExpressionTreeGrammarParameter {
    53       get { return (IValueLookupParameter<ISymbolicExpressionGrammar>)Parameters[SymbolicExpressionTreeGrammarParameterName]; }
    54     }
    55 
    56     public ILookupParameter<ISymbolicExpressionGrammar> ClonedSymbolicExpressionTreeGrammarParameter {
    57       get { return (ILookupParameter<ISymbolicExpressionGrammar>)Parameters[ClonedSymbolicExpressionTreeGrammarParameterName]; }
    5848    }
    5949
     
    6757      get { return MaximumSymbolicExpressionTreeLengthParameter.ActualValue; }
    6858    }
    69 
    70     public ISymbolicExpressionGrammar ClonedSymbolicExpressionTreeGrammar {
    71       get { return ClonedSymbolicExpressionTreeGrammarParameter.ActualValue; }
    72     }
    73 
    7459    #endregion
    7560
     
    8469      Parameters.Add(new ValueLookupParameter<IntValue>(MaximumSymbolicExpressionTreeDepthParameterName,
    8570        "The maximal depth of the symbolic expression tree (a tree with one node has depth = 0)."));
    86       Parameters.Add(new ValueLookupParameter<ISymbolicExpressionGrammar>(SymbolicExpressionTreeGrammarParameterName,
    87         "The tree grammar that defines the correct syntax of symbolic expression trees that should be created."));
    88       Parameters.Add(new LookupParameter<ISymbolicExpressionGrammar>(ClonedSymbolicExpressionTreeGrammarParameterName,
    89         "An immutable clone of the concrete grammar that is actually used to create and manipulate trees."));
    9071    }
    9172
     
    9475    }
    9576
    96     public override IOperation InstrumentedApply() {
    97       if (ClonedSymbolicExpressionTreeGrammarParameter.ActualValue == null) {
    98         SymbolicExpressionTreeGrammarParameter.ActualValue.ReadOnly = true;
    99         IScope globalScope = ExecutionContext.Scope;
    100         while (globalScope.Parent != null)
    101           globalScope = globalScope.Parent;
    102 
    103         globalScope.Variables.Add(new Variable(ClonedSymbolicExpressionTreeGrammarParameterName,
    104           (ISymbolicExpressionGrammar)SymbolicExpressionTreeGrammarParameter.ActualValue.Clone()));
    105       }
    106       return base.InstrumentedApply();
    107     }
    10877
    10978    protected override ISymbolicExpressionTree Create(IRandom random) {
    110       return Create(random, ClonedSymbolicExpressionTreeGrammar,
     79      return Create(random, ClonedSymbolicExpressionTreeGrammarParameter.ActualValue,
    11180        MaximumSymbolicExpressionTreeLength.Value, MaximumSymbolicExpressionTreeDepth.Value);
    11281    }
     
    12897      var tree = new SymbolicExpressionTree();
    12998      var rootNode = (SymbolicExpressionTreeTopLevelNode)grammar.ProgramRootSymbol.CreateTreeNode();
    130       rootNode.SetGrammar(new SymbolicExpressionTreeGrammar(grammar));
    13199      if (rootNode.HasLocalParameters) rootNode.ResetLocalParameters(random);
     100      rootNode.SetGrammar(grammar.CreateExpressionTreeGrammar());
     101
    132102
    133103      var startNode = (SymbolicExpressionTreeTopLevelNode)grammar.StartSymbol.CreateTreeNode();
    134104      if (startNode.HasLocalParameters) startNode.ResetLocalParameters(random);
    135       startNode.SetGrammar(new SymbolicExpressionTreeGrammar(grammar));
     105      startNode.SetGrammar(grammar.CreateExpressionTreeGrammar());
    136106
    137107      rootNode.AddSubtree(startNode);
  • branches/HeuristicLab.EvolutionTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Creators/ProbabilisticTreeCreator.cs

    r11208 r11499  
    3939    private const string MaximumSymbolicExpressionTreeLengthParameterName = "MaximumSymbolicExpressionTreeLength";
    4040    private const string MaximumSymbolicExpressionTreeDepthParameterName = "MaximumSymbolicExpressionTreeDepth";
    41     private const string SymbolicExpressionTreeGrammarParameterName = "SymbolicExpressionTreeGrammar";
    42     private const string ClonedSymbolicExpressionTreeGrammarParameterName = "ClonedSymbolicExpressionTreeGrammar";
    4341    #region Parameter Properties
    4442    public IValueLookupParameter<IntValue> MaximumSymbolicExpressionTreeLengthParameter {
     
    4745    public IValueLookupParameter<IntValue> MaximumSymbolicExpressionTreeDepthParameter {
    4846      get { return (IValueLookupParameter<IntValue>)Parameters[MaximumSymbolicExpressionTreeDepthParameterName]; }
    49     }
    50     public IValueLookupParameter<ISymbolicExpressionGrammar> SymbolicExpressionTreeGrammarParameter {
    51       get { return (IValueLookupParameter<ISymbolicExpressionGrammar>)Parameters[SymbolicExpressionTreeGrammarParameterName]; }
    52     }
    53     public ILookupParameter<ISymbolicExpressionGrammar> ClonedSymbolicExpressionTreeGrammarParameter {
    54       get { return (ILookupParameter<ISymbolicExpressionGrammar>)Parameters[ClonedSymbolicExpressionTreeGrammarParameterName]; }
    5547    }
    5648    #endregion
     
    6153    public IntValue MaximumSymbolicExpressionTreeDepth {
    6254      get { return MaximumSymbolicExpressionTreeDepthParameter.ActualValue; }
    63     }
    64     public ISymbolicExpressionGrammar SymbolicExpressionTreeGrammar {
    65       get { return ClonedSymbolicExpressionTreeGrammarParameter.ActualValue; }
    6655    }
    6756    #endregion
     
    7463      Parameters.Add(new ValueLookupParameter<IntValue>(MaximumSymbolicExpressionTreeLengthParameterName, "The maximal length (number of nodes) of the symbolic expression tree."));
    7564      Parameters.Add(new ValueLookupParameter<IntValue>(MaximumSymbolicExpressionTreeDepthParameterName, "The maximal depth of the symbolic expression tree (a tree with one node has depth = 0)."));
    76       Parameters.Add(new ValueLookupParameter<ISymbolicExpressionGrammar>(SymbolicExpressionTreeGrammarParameterName, "The tree grammar that defines the correct syntax of symbolic expression trees that should be created."));
    77       Parameters.Add(new LookupParameter<ISymbolicExpressionGrammar>(ClonedSymbolicExpressionTreeGrammarParameterName, "An immutable clone of the concrete grammar that is actually used to create and manipulate trees."));
    7865    }
    7966
     
    8168      return new ProbabilisticTreeCreator(this, cloner);
    8269    }
    83     [StorableHook(HookType.AfterDeserialization)]
    84     private void AfterDeserialization() {
    85       if (!Parameters.ContainsKey(ClonedSymbolicExpressionTreeGrammarParameterName))
    86         Parameters.Add(new LookupParameter<ISymbolicExpressionGrammar>(ClonedSymbolicExpressionTreeGrammarParameterName, "An immutable clone of the concrete grammar that is actually used to create and manipulate trees."));
    87     }
    88 
    89     public override IOperation InstrumentedApply() {
    90       if (ClonedSymbolicExpressionTreeGrammarParameter.ActualValue == null) {
    91         SymbolicExpressionTreeGrammarParameter.ActualValue.ReadOnly = true;
    92         IScope globalScope = ExecutionContext.Scope;
    93         while (globalScope.Parent != null)
    94           globalScope = globalScope.Parent;
    95 
    96         globalScope.Variables.Add(new Variable(ClonedSymbolicExpressionTreeGrammarParameterName, (ISymbolicExpressionGrammar)SymbolicExpressionTreeGrammarParameter.ActualValue.Clone()));
    97       }
    98       return base.InstrumentedApply();
    99     }
     70
    10071
    10172    protected override ISymbolicExpressionTree Create(IRandom random) {
    102       return Create(random, SymbolicExpressionTreeGrammar, MaximumSymbolicExpressionTreeLength.Value, MaximumSymbolicExpressionTreeDepth.Value);
     73      return Create(random, ClonedSymbolicExpressionTreeGrammarParameter.ActualValue, MaximumSymbolicExpressionTreeLength.Value, MaximumSymbolicExpressionTreeDepth.Value);
    10374    }
    10475
     
    11182      var rootNode = (SymbolicExpressionTreeTopLevelNode)grammar.ProgramRootSymbol.CreateTreeNode();
    11283      if (rootNode.HasLocalParameters) rootNode.ResetLocalParameters(random);
    113       rootNode.SetGrammar(new SymbolicExpressionTreeGrammar(grammar));
     84      rootNode.SetGrammar(grammar.CreateExpressionTreeGrammar());
     85
    11486      var startNode = (SymbolicExpressionTreeTopLevelNode)grammar.StartSymbol.CreateTreeNode();
    115       startNode.SetGrammar(new SymbolicExpressionTreeGrammar(grammar));
    11687      if (startNode.HasLocalParameters) startNode.ResetLocalParameters(random);
     88      startNode.SetGrammar(grammar.CreateExpressionTreeGrammar());
     89
    11790      rootNode.AddSubtree(startNode);
    11891      PTC2(random, startNode, maxTreeLength, maxTreeDepth);
  • branches/HeuristicLab.EvolutionTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Creators/RampedHalfAndHalfTreeCreator.cs

    r11208 r11499  
    3636    private const string MaximumSymbolicExpressionTreeLengthParameterName = "MaximumSymbolicExpressionTreeLength";
    3737    private const string MaximumSymbolicExpressionTreeDepthParameterName = "MaximumSymbolicExpressionTreeDepth";
    38     private const string SymbolicExpressionTreeGrammarParameterName = "SymbolicExpressionTreeGrammar";
    39     private const string ClonedSymbolicExpressionTreeGrammarParameterName = "ClonedSymbolicExpressionTreeGrammar";
    4038
    4139    #region Parameter Properties
     
    4846    }
    4947
    50     public IValueLookupParameter<ISymbolicExpressionGrammar> SymbolicExpressionTreeGrammarParameter {
    51       get {
    52         return (IValueLookupParameter<ISymbolicExpressionGrammar>)Parameters[SymbolicExpressionTreeGrammarParameterName];
    53       }
    54     }
    55 
    56     public ILookupParameter<ISymbolicExpressionGrammar> ClonedSymbolicExpressionTreeGrammarParameter {
    57       get {
    58         return (ILookupParameter<ISymbolicExpressionGrammar>)Parameters[ClonedSymbolicExpressionTreeGrammarParameterName];
    59       }
    60     }
    61 
    6248    #endregion
    6349    #region Properties
     
    6854    public IntValue MaximumSymbolicExpressionTreeLength {
    6955      get { return MaximumSymbolicExpressionTreeLengthParameter.ActualValue; }
    70     }
    71 
    72     public ISymbolicExpressionGrammar ClonedSymbolicExpressionTreeGrammar {
    73       get { return ClonedSymbolicExpressionTreeGrammarParameter.ActualValue; }
    7456    }
    7557    #endregion
     
    8567      Parameters.Add(new ValueLookupParameter<IntValue>(MaximumSymbolicExpressionTreeDepthParameterName,
    8668        "The maximal depth of the symbolic expression tree (a tree with one node has depth = 0)."));
    87       Parameters.Add(new ValueLookupParameter<ISymbolicExpressionGrammar>(SymbolicExpressionTreeGrammarParameterName,
    88         "The tree grammar that defines the correct syntax of symbolic expression trees that should be created."));
    89       Parameters.Add(new LookupParameter<ISymbolicExpressionGrammar>(ClonedSymbolicExpressionTreeGrammarParameterName,
    90         "An immutable clone of the concrete grammar that is actually used to create and manipulate trees."));
    9169    }
    9270
     
    9573    }
    9674
    97     public override IOperation InstrumentedApply() {
    98       if (ClonedSymbolicExpressionTreeGrammarParameter.ActualValue == null) {
    99         SymbolicExpressionTreeGrammarParameter.ActualValue.ReadOnly = true;
    100         IScope globalScope = ExecutionContext.Scope;
    101         while (globalScope.Parent != null)
    102           globalScope = globalScope.Parent;
    103 
    104         globalScope.Variables.Add(new Variable(ClonedSymbolicExpressionTreeGrammarParameterName,
    105           (ISymbolicExpressionGrammar)SymbolicExpressionTreeGrammarParameter.ActualValue.Clone()));
    106       }
    107       return base.InstrumentedApply();
    108     }
    109 
    11075    protected override ISymbolicExpressionTree Create(IRandom random) {
    111       return Create(random, ClonedSymbolicExpressionTreeGrammar, MaximumSymbolicExpressionTreeLength.Value, MaximumSymbolicExpressionTreeDepth.Value);
     76      return Create(random, ClonedSymbolicExpressionTreeGrammarParameter.ActualValue, MaximumSymbolicExpressionTreeLength.Value, MaximumSymbolicExpressionTreeDepth.Value);
    11277    }
    11378
     
    12994      var rootNode = (SymbolicExpressionTreeTopLevelNode)grammar.ProgramRootSymbol.CreateTreeNode();
    13095      if (rootNode.HasLocalParameters) rootNode.ResetLocalParameters(random);
    131       rootNode.SetGrammar(new SymbolicExpressionTreeGrammar(grammar));
     96      rootNode.SetGrammar(grammar.CreateExpressionTreeGrammar());
    13297
    13398      var startNode = (SymbolicExpressionTreeTopLevelNode)grammar.StartSymbol.CreateTreeNode();
    13499      if (startNode.HasLocalParameters) startNode.ResetLocalParameters(random);
    135       startNode.SetGrammar(new SymbolicExpressionTreeGrammar(grammar));
     100      startNode.SetGrammar(grammar.CreateExpressionTreeGrammar());
    136101
    137102      rootNode.AddSubtree(startNode);
  • branches/HeuristicLab.EvolutionTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Creators/SymbolicExpressionTreeCreator.cs

    r11208 r11499  
    3333  public abstract class SymbolicExpressionTreeCreator : SymbolicExpressionTreeOperator, ISymbolicExpressionTreeCreator {
    3434    private const string SymbolicExpressionTreeParameterName = "SymbolicExpressionTree";
     35    private const string SymbolicExpressionTreeGrammarParameterName = "SymbolicExpressionTreeGrammar";
     36    private const string ClonedSymbolicExpressionTreeGrammarParameterName = "ClonedSymbolicExpressionTreeGrammar";
     37
    3538    #region Parameter Properties
    3639    public ILookupParameter<ISymbolicExpressionTree> SymbolicExpressionTreeParameter {
    3740      get { return (ILookupParameter<ISymbolicExpressionTree>)Parameters[SymbolicExpressionTreeParameterName]; }
    3841    }
     42
     43    public IValueLookupParameter<ISymbolicExpressionGrammar> SymbolicExpressionTreeGrammarParameter {
     44      get { return (IValueLookupParameter<ISymbolicExpressionGrammar>)Parameters[SymbolicExpressionTreeGrammarParameterName]; }
     45    }
     46
     47    public ILookupParameter<ISymbolicExpressionGrammar> ClonedSymbolicExpressionTreeGrammarParameter {
     48      get { return (ILookupParameter<ISymbolicExpressionGrammar>)Parameters[ClonedSymbolicExpressionTreeGrammarParameterName]; }
     49    }
    3950    #endregion
    4051
    41     #region Properties
    42     public ISymbolicExpressionTree SymbolicExpressionTree {
    43       get { return SymbolicExpressionTreeParameter.ActualValue; }
    44       set { SymbolicExpressionTreeParameter.ActualValue = value; }
    45     }
    46 
    47     #endregion
    4852    [StorableConstructor]
    4953    protected SymbolicExpressionTreeCreator(bool deserializing) : base(deserializing) { }
     
    5256      : base() {
    5357      Parameters.Add(new LookupParameter<ISymbolicExpressionTree>(SymbolicExpressionTreeParameterName, "The symbolic expression tree that should be created."));
     58      Parameters.Add(new ValueLookupParameter<ISymbolicExpressionGrammar>(SymbolicExpressionTreeGrammarParameterName,
     59        "The tree grammar that defines the correct syntax of symbolic expression trees that should be created."));
     60      Parameters.Add(new LookupParameter<ISymbolicExpressionGrammar>(ClonedSymbolicExpressionTreeGrammarParameterName,
     61        "An immutable clone of the concrete grammar that is actually used to create and manipulate trees."));
     62    }
     63
     64    [StorableHook(HookType.AfterDeserialization)]
     65    private void AfterDeserialization() {
     66      if (!Parameters.ContainsKey(ClonedSymbolicExpressionTreeGrammarParameterName))
     67        Parameters.Add(new LookupParameter<ISymbolicExpressionGrammar>(ClonedSymbolicExpressionTreeGrammarParameterName, "An immutable clone of the concrete grammar that is actually used to create and manipulate trees."));
    5468    }
    5569
    5670    public override IOperation InstrumentedApply() {
    57       SymbolicExpressionTree = Create(Random);
     71      if (ClonedSymbolicExpressionTreeGrammarParameter.ActualValue == null) {
     72        SymbolicExpressionTreeGrammarParameter.ActualValue.ReadOnly = true;
     73        IScope globalScope = ExecutionContext.Scope;
     74        while (globalScope.Parent != null)
     75          globalScope = globalScope.Parent;
     76
     77        globalScope.Variables.Add(new Variable(ClonedSymbolicExpressionTreeGrammarParameterName,
     78          (ISymbolicExpressionGrammar)SymbolicExpressionTreeGrammarParameter.ActualValue.Clone()));
     79      }
     80      SymbolicExpressionTreeParameter.ActualValue = Create(Random);
    5881      return base.InstrumentedApply();
    5982    }
  • branches/HeuristicLab.EvolutionTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/CutPoint.cs

    r11208 r11499  
    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;
  • branches/HeuristicLab.EvolutionTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding-3.4.csproj

    r10524 r11499  
    187187    <Compile Include="Formatters\SymbolicExpressionTreeGraphvizFormatter.cs" />
    188188    <Compile Include="Formatters\SymbolicExpressionTreeHierarchicalFormatter.cs" />
     189    <Compile Include="Grammars\EmptySymbolicExpressionTreeGrammar.cs" />
    189190    <Compile Include="Interfaces\IReadOnlySymbol.cs" />
    190191    <Compile Include="Interfaces\ISymbolicExpressionGrammar.cs" />
     
    217218    <Compile Include="Manipulators\SymbolicExpressionTreeManipulator.cs" />
    218219    <Compile Include="Plugin.cs" />
    219     <Compile Include="SymbolicExpressionGrammarBase.cs" />
    220     <Compile Include="SymbolicExpressionGrammar.cs" />
    221     <Compile Include="SymbolicExpressionTreeGrammar.cs" />
     220    <Compile Include="Grammars\SymbolicExpressionGrammarBase.cs" />
     221    <Compile Include="Grammars\SymbolicExpressionGrammar.cs" />
     222    <Compile Include="Grammars\SymbolicExpressionTreeGrammar.cs" />
    222223    <Compile Include="SymbolicExpressionTreeTopLevelNode.cs" />
    223224    <Compile Include="Crossovers\SubtreeCrossover.cs">
  • branches/HeuristicLab.EvolutionTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Interfaces/ISymbolicExpressionGrammar.cs

    r11208 r11499  
    4848    void StartGrammarManipulation();
    4949    void FinishedGrammarManipulation();
     50
     51    ISymbolicExpressionTreeGrammar CreateExpressionTreeGrammar();
    5052  }
    5153}
Note: See TracChangeset for help on using the changeset viewer.