Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
08/01/09 13:36:13 (15 years ago)
Author:
gkronber
Message:

fixed serialization of function trees and GPModels. (#713)

Location:
branches/GP-Refactoring-713/sources/HeuristicLab.GP/3.3/BaseClasses
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/GP-Refactoring-713/sources/HeuristicLab.GP/3.3/BaseClasses/FunctionBase.cs

    r2216 r2219  
    156156
    157157    public override object Clone(IDictionary<Guid, object> clonedObjects) {
    158       throw new NotSupportedException();
     158      FunctionBase clone = (FunctionBase)base.Clone(clonedObjects);
     159      clone.initializer = (IOperator)Auxiliary.Clone(initializer, clonedObjects);
     160      clone.manipulator = (IOperator)Auxiliary.Clone(manipulator, clonedObjects);
     161      clone.maxArity = maxArity;
     162      clone.minArity = minArity;
     163      clone.minTreeHeight = minTreeHeight;
     164      clone.minTreeSize = minTreeSize;
     165      clone.tickets = tickets;
     166      for (int i = 0; i < MaxSubTrees; i++) {
     167        var allowedSubFunctionsForSlot = new List<IFunction>();
     168        foreach (IFunction f in GetAllowedSubFunctions(i)) {
     169          allowedSubFunctionsForSlot.Add((IFunction)Auxiliary.Clone(f, clonedObjects));
     170        }
     171        clone.allowedSubFunctions.Add(allowedSubFunctionsForSlot);
     172      }
     173      return clone;
    159174    }
    160175
  • branches/GP-Refactoring-713/sources/HeuristicLab.GP/3.3/BaseClasses/FunctionTreeBase.cs

    r2218 r2219  
    111111
    112112    public virtual XmlNode GetXmlNode(string name, XmlDocument document, IDictionary<Guid, IStorable> persistedObjects) {
    113       XmlNode node = document.CreateElement(name);
    114       //XmlAttribute typeAttr = document.CreateAttribute("Type");
    115       //typeAttr.Value = PersistenceManager.BuildTypeString(GetType());
    116       //node.Attributes.Append(typeAttr);
    117       foreach (IFunctionTree subTree in SubTrees) {
    118         XmlNode funNode = PersistenceManager.Persist(Function, document, persistedObjects);
    119         node.AppendChild(funNode);
    120         funNode.AppendChild(subTree.GetXmlNode("Tree", document, persistedObjects));
    121       }
    122       return node;
     113      return null;
    123114    }
    124115
    125116    public virtual void Populate(XmlNode node, IDictionary<Guid, IStorable> restoredObjects) {
    126       for (int i = 0; i < node.ChildNodes.Count; i++) {
    127         XmlNode childNode = node.ChildNodes[i];
    128         IFunction function = (IFunction)PersistenceManager.Restore(childNode, restoredObjects);
    129         IFunctionTree tree = function.GetTreeNode();
    130         tree.Populate(childNode.SelectSingleNode("Tree"), restoredObjects);
    131         AddSubTree(tree);
    132       }
    133117    }
    134118
Note: See TracChangeset for help on using the changeset viewer.