Free cookie consent management tool by TermsFeed Policy Generator

Changeset 3252


Ignore:
Timestamp:
04/01/10 20:59:17 (13 years ago)
Author:
gkronber
Message:

Fixed issues with persistence. #937 (Data types and operators for symbolic expression tree encoding)

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

Legend:

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

    r3244 r3252  
    3232  [StorableClass]
    3333  [Item("SymbolicExpressionTree", "Represents a symbolic expression tree.")]
    34   public class SymbolicExpressionTree : Item {
     34  public class SymbolicExpressionTree : Item {   
     35    [Storable]
    3536    private SymbolicExpressionTreeNode root;
    3637    public SymbolicExpressionTreeNode Root {
  • trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.3/SymbolicExpressionTreeNode.cs

    r3244 r3252  
    3030namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding {
    3131  [StorableClass]
    32   public class SymbolicExpressionTreeNode : DeepCloneable {
     32  public class SymbolicExpressionTreeNode : ICloneable {
     33    [Storable]
    3334    private List<SymbolicExpressionTreeNode> subTrees;
     35    [Storable]
    3436    private Symbol symbol;
    3537
    36     public SymbolicExpressionTreeNode() {
    37     }
     38    public SymbolicExpressionTreeNode() { }
    3839
    3940    public SymbolicExpressionTreeNode(Symbol symbol) {
     
    4243    }
    4344
    44     //protected SymbolicExpressionTreeNode(SymbolicExpressionTreeNode original) {
    45     //  this.symbol = original.Symbol;
    46     //  this.subTrees = new List<SymbolicExpressionTreeNode>(original.SubTrees.Count);
    47     //  foreach (SymbolicExpressionTreeNode originalSubTree in original.SubTrees) {
    48     //    this.SubTrees.Add((SymbolicExpressionTreeNode)originalSubTree.Clone());
    49     //  }
    50     //}
     45    // copy constructor
     46    protected SymbolicExpressionTreeNode(SymbolicExpressionTreeNode original) {
     47      symbol = original.symbol;
     48      this.subTrees = new List<SymbolicExpressionTreeNode>();
     49      foreach (var subtree in original.SubTrees) {
     50        AddSubTree((SymbolicExpressionTreeNode)subtree.Clone());
     51      }
     52    }
    5153
    5254    public virtual bool HasLocalParameters {
     
    9597    }
    9698
    97     public override IDeepCloneable Clone(Cloner cloner) {
    98       SymbolicExpressionTreeNode clone = new SymbolicExpressionTreeNode(symbol);
    99       cloner.RegisterClonedObject(this, clone);
    100       foreach (var subtree in SubTrees) {
    101         clone.AddSubTree((SymbolicExpressionTreeNode)subtree.Clone(cloner));
    102       }
    103       return clone;
     99    #region ICloneable Members
     100
     101    public virtual object Clone() {
     102      return new SymbolicExpressionTreeNode(this);
    104103    }
     104
     105    #endregion
    105106  }
    106107}
Note: See TracChangeset for help on using the changeset viewer.