Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
02/01/10 16:40:24 (14 years ago)
Author:
gkronber
Message:

Fixed problems in persistence and cloning of functions and function libraries. Added test-functionality to editor for function libraries. Fixed bugs in editor for function libraries. #748 (FunctionLibraryView is empty)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.GP/3.3/BaseClasses/Function.cs

    r2700 r2729  
    227227    public override object Clone(IDictionary<Guid, object> clonedObjects) {
    228228      Function clone = (Function)base.Clone(clonedObjects);
    229       clone.initializer = (IOperator)Auxiliary.Clone(initializer, clonedObjects);
    230       clone.manipulator = (IOperator)Auxiliary.Clone(manipulator, clonedObjects);
    231       clone.maxArity = maxArity;
    232       clone.minArity = minArity;
    233       clone.minTreeHeight = minTreeHeight;
    234       clone.minTreeSize = minTreeSize;
    235       clone.tickets = tickets;
     229      if (initializer != null) clone.initializer = (IOperator)Auxiliary.Clone(initializer, clonedObjects);
     230      else clone.initializer = null;
     231      if (manipulator != null) clone.manipulator = (IOperator)Auxiliary.Clone(manipulator, clonedObjects);
     232      else clone.manipulator = null;
     233      clone.MaxSubTrees = maxArity;
     234      clone.MinSubTrees = minArity;
     235      clone.Tickets = tickets;
     236      clone.allowedSubFunctions.Clear();
    236237      for (int i = 0; i < MaxSubTrees; i++) {
    237238        var allowedSubFunctionsForSlot = new List<IFunction>();
     
    252253      node.Attributes.Append(minSubTreesAttr);
    253254      node.Attributes.Append(maxSubTreesAttr);
     255      if (initializer != null)
     256        node.AppendChild(PersistenceManager.Persist("Initializer", initializer, document, persistedObjects));
     257      if (manipulator != null)
     258        node.AppendChild(PersistenceManager.Persist("Manipulator", manipulator, document, persistedObjects));
    254259      for (int i = 0; i < MaxSubTrees; i++) {
    255260        XmlNode slotNode = document.CreateElement("AllowedSubFunctions");
     
    269274      MinSubTrees = XmlConvert.ToInt32(node.Attributes["MinSubTrees"].Value);
    270275      MaxSubTrees = XmlConvert.ToInt32(node.Attributes["MaxSubTrees"].Value);
     276      if (node.SelectSingleNode("Initializer") != null) {
     277        initializer = (IOperator)PersistenceManager.Restore(node.SelectSingleNode("Initializer"), restoredObjects);
     278      }
     279      if (node.SelectSingleNode("Manipulator") != null) {
     280        manipulator = (IOperator)PersistenceManager.Restore(node.SelectSingleNode("Manipulator"), restoredObjects);
     281      }
     282      foreach (var subFunctionsList in allowedSubFunctions) subFunctionsList.Clear();
    271283      foreach (XmlNode allowedSubFunctionsNode in node.SelectNodes("AllowedSubFunctions")) {
    272284        int slot = XmlConvert.ToInt32(allowedSubFunctionsNode.Attributes["Slot"].Value);
Note: See TracChangeset for help on using the changeset viewer.