Changeset 2729 for trunk/sources/HeuristicLab.GP/3.3/BaseClasses
- Timestamp:
- 02/01/10 16:40:24 (15 years ago)
- Location:
- trunk/sources/HeuristicLab.GP/3.3/BaseClasses
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.GP/3.3/BaseClasses/Function.cs
r2700 r2729 227 227 public override object Clone(IDictionary<Guid, object> clonedObjects) { 228 228 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(); 236 237 for (int i = 0; i < MaxSubTrees; i++) { 237 238 var allowedSubFunctionsForSlot = new List<IFunction>(); … … 252 253 node.Attributes.Append(minSubTreesAttr); 253 254 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)); 254 259 for (int i = 0; i < MaxSubTrees; i++) { 255 260 XmlNode slotNode = document.CreateElement("AllowedSubFunctions"); … … 269 274 MinSubTrees = XmlConvert.ToInt32(node.Attributes["MinSubTrees"].Value); 270 275 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(); 271 283 foreach (XmlNode allowedSubFunctionsNode in node.SelectNodes("AllowedSubFunctions")) { 272 284 int slot = XmlConvert.ToInt32(allowedSubFunctionsNode.Attributes["Slot"].Value); -
trunk/sources/HeuristicLab.GP/3.3/BaseClasses/FunctionLibraryInjectorBase.cs
r2728 r2729 76 76 return new FunctionLibraryInjectorView(this); 77 77 } 78 79 #region persistence 80 public override object Clone(IDictionary<Guid, object> clonedObjects) { 81 FunctionLibraryInjectorBase clone = (FunctionLibraryInjectorBase)base.Clone(clonedObjects); 82 clone.functionLibrary = (FunctionLibrary)Auxiliary.Clone(functionLibrary, clonedObjects); 83 return clone; 84 } 85 public override XmlNode GetXmlNode(string name, XmlDocument document, IDictionary<Guid, IStorable> persistedObjects) { 86 XmlNode node = base.GetXmlNode(name, document, persistedObjects); 87 node.AppendChild(PersistenceManager.Persist("FunctionLibrary", FunctionLibrary, document, persistedObjects)); 88 return node; 89 } 90 public override void Populate(XmlNode node, IDictionary<Guid, IStorable> restoredObjects) { 91 base.Populate(node, restoredObjects); 92 functionLibrary = (FunctionLibrary)PersistenceManager.Restore(node.SelectSingleNode("FunctionLibrary"), restoredObjects); 93 } 94 #endregion 78 95 } 79 96 }
Note: See TracChangeset
for help on using the changeset viewer.