Free cookie consent management tool by TermsFeed Policy Generator

Changeset 3486 for trunk/sources


Ignore:
Timestamp:
04/22/10 09:32:46 (15 years ago)
Author:
gkronber
Message:

Bug fixes in persistence #937 (Data types and operators for symbolic expression tree encoding)

Location:
trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.3
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.3/SymbolicExpressionTreeNode.cs

    r3484 r3486  
    5151    }
    5252
    53     public SymbolicExpressionTreeNode() { }
     53    public SymbolicExpressionTreeNode() {
     54      // don't allocate subtrees list here!
     55      // because we don't want to allocate it in terminal nodes
     56    }
    5457
    5558    public SymbolicExpressionTreeNode(Symbol symbol) {
     
    6467      foreach (var subtree in original.SubTrees) {
    6568        AddSubTree((SymbolicExpressionTreeNode)subtree.Clone());
     69      }
     70    }
     71
     72    [StorableHook(HookType.AfterDeserialization)]
     73    private void AfterDeserializationHook() {
     74      foreach (var subtree in SubTrees) {
     75        subtree.Parent = this;
    6676      }
    6777    }
     
    112122    public IEnumerable<SymbolicExpressionTreeNode> IterateNodesPrefix() {
    113123      yield return this;
    114       foreach (var subtree in subTrees) {
    115         foreach (var n in subtree.IterateNodesPrefix())
    116           yield return n;
     124      if (SubTrees != null) {
     125        foreach (var subtree in SubTrees) {
     126          foreach (var n in subtree.IterateNodesPrefix())
     127            yield return n;
     128        }
    117129      }
    118130    }
    119131
    120132    public IEnumerable<SymbolicExpressionTreeNode> IterateNodesPostfix() {
    121       foreach (var subtree in subTrees) {
    122         foreach (var n in subtree.IterateNodesPrefix())
    123           yield return n;
     133      if (SubTrees != null) {
     134        foreach (var subtree in SubTrees) {
     135          foreach (var n in subtree.IterateNodesPrefix())
     136            yield return n;
     137        }
    124138      }
    125139      yield return this;
     
    146160      return Symbol.Name;
    147161    }
    148 
    149162  }
    150163}
  • trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.3/SymbolicExpressionTreeTopLevelNode.cs

    r3462 r3486  
    4444    }
    4545
     46    [Storable]
    4647    private ISymbolicExpressionGrammar grammar;
    47 
    4848    internal override ISymbolicExpressionGrammar Grammar {
    49       get {
    50         return grammar;
    51       }
    52       set {
    53         grammar = value;
    54       }
     49      get { return grammar; }
     50      set { grammar = value; }
    5551    }
    5652
  • trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.3/Symbols/ArgumentTreeNode.cs

    r3484 r3486  
    2424namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Symbols {
    2525  [StorableClass]
    26   public sealed class ArgumentTreeNode : SymbolicExpressionTreeNode {
     26  public sealed class ArgumentTreeNode : SymbolicExpressionTreeTerminalNode {
    2727    internal new Argument Symbol {
    2828      get { return (Argument)base.Symbol; }
Note: See TracChangeset for help on using the changeset viewer.