Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
07/31/09 12:31:32 (15 years ago)
Author:
gkronber
Message:

Worked on persistence of function trees. #713

Location:
branches/GP-Refactoring-713/sources/HeuristicLab.GP.StructureIdentification/3.3/Symbols
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • branches/GP-Refactoring-713/sources/HeuristicLab.GP.StructureIdentification/3.3/Symbols/ConstantFunctionTree.cs

    r2216 r2218  
    2424using HeuristicLab.Data;
    2525using HeuristicLab.GP.Interfaces;
     26using System.Xml;
    2627
    2728namespace HeuristicLab.GP.StructureIdentification {
     
    5657    }
    5758
    58     public override IFunctionTree Clone() {
     59    public override object Clone() {
    5960      return new ConstantFunctionTree(this);
     61    }
     62
     63    public override XmlNode GetXmlNode(string name, XmlDocument document, IDictionary<System.Guid, IStorable> persistedObjects) {
     64      XmlNode node = base.GetXmlNode(name, document, persistedObjects);
     65      XmlAttribute valueAttr = document.CreateAttribute("Value");
     66      valueAttr.Value = XmlConvert.ToString(Value);
     67      node.Attributes.Append(valueAttr);
     68      return node;
     69    }
     70
     71    public override void Populate(XmlNode node, IDictionary<System.Guid, IStorable> restoredObjects) {
     72      base.Populate(node, restoredObjects);
     73      Value = XmlConvert.ToDouble(node.Attributes["Value"].Value);
    6074    }
    6175
  • branches/GP-Refactoring-713/sources/HeuristicLab.GP.StructureIdentification/3.3/Symbols/Differential.cs

    r2212 r2218  
    2121
    2222
     23using HeuristicLab.GP.Interfaces;
    2324namespace HeuristicLab.GP.StructureIdentification {
    2425  public sealed class Differential : Variable {
     
    3132
    3233    public Differential() : base() { }
     34
     35    public override IFunctionTree GetTreeNode() {
     36      return new VariableFunctionTree(this);
     37    }
    3338  }
    3439}
  • branches/GP-Refactoring-713/sources/HeuristicLab.GP.StructureIdentification/3.3/Symbols/Variable.cs

    r2212 r2218  
    4040      }
    4141    }
     42
    4243
    4344    public override IFunctionTree GetTreeNode() {
  • branches/GP-Refactoring-713/sources/HeuristicLab.GP.StructureIdentification/3.3/Symbols/VariableFunctionTree.cs

    r2216 r2218  
    2424using HeuristicLab.Data;
    2525using HeuristicLab.GP.Interfaces;
     26using System.Xml;
    2627
    2728namespace HeuristicLab.GP.StructureIdentification {
     
    6667    }
    6768
    68     public override IFunctionTree Clone() {
     69    public override object Clone() {
    6970      return new VariableFunctionTree(this);
     71    }
     72
     73    public override XmlNode GetXmlNode(string name, XmlDocument document, IDictionary<System.Guid, IStorable> persistedObjects) {
     74      XmlNode node = base.GetXmlNode(name, document, persistedObjects);
     75      XmlAttribute weightAttr = document.CreateAttribute("Weight");
     76      weightAttr.Value = XmlConvert.ToString(Weight);
     77      XmlAttribute variableAttr = document.CreateAttribute("Variable");
     78      variableAttr.Value = VariableName;
     79      XmlAttribute sampleOffsetAttr = document.CreateAttribute("SampleOffset");
     80      sampleOffsetAttr.Value = XmlConvert.ToString(SampleOffset);
     81      node.Attributes.Append(weightAttr);
     82      node.Attributes.Append(sampleOffsetAttr);
     83      node.Attributes.Append(variableAttr);
     84      return node;
     85    }
     86
     87    public override void Populate(XmlNode node, IDictionary<System.Guid, IStorable> restoredObjects) {
     88      base.Populate(node, restoredObjects);
     89      Weight = XmlConvert.ToDouble(node.Attributes["Weight"].Value);
     90      SampleOffset = XmlConvert.ToInt32(node.Attributes["SampleOffset"].Value);
     91      VariableName = node.Attributes["Variable"].Value;
    7092    }
    7193
Note: See TracChangeset for help on using the changeset viewer.