Changeset 8213 for branches/HeuristicLab.EvolutionaryTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Manipulators
- Timestamp:
- 07/04/12 16:12:15 (12 years ago)
- Location:
- branches/HeuristicLab.EvolutionaryTracking
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.EvolutionaryTracking
- Property svn:ignore
-
old new 1 *.suo 1 2 _ReSharper.HeuristicLab.Tracking 2 3 bin
-
- Property svn:ignore
-
branches/HeuristicLab.EvolutionaryTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4
- Property svn:ignore
-
old new 1 *.user 1 2 bin 2 3 obj 3 HeuristicLabEncodingsSymbolicExpressionTreeEncodingPlugin.cs4 *.user5 *.vs10x6 Plugin.cs
-
- Property svn:ignore
-
branches/HeuristicLab.EvolutionaryTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Manipulators/TracingSymbolicExpressionTreeManipulator.cs
r7997 r8213 21 21 22 22 using System; 23 using System. Collections.Generic;23 using System.Linq; 24 24 using HeuristicLab.Common; 25 25 using HeuristicLab.Core; … … 96 96 gScope.Variables.Add(new Variable(GlobalFragmentMapParameterName, new CloneMapType())); 97 97 98 int i = 0; 98 99 if (GlobalTraceMap.ContainsKey(tree)) { 99 100 // tree was affected by crossover before mutation … … 102 103 // In order to preserve information, a tree clone is created before mutation and added to the trace map. 103 104 var clone = (IItem)tree.Clone(); 104 GlobalTraceMap[clone] = GlobalTraceMap[tree]; 105 GlobalTraceMap[tree] = new ItemList<IItem> { clone }; 106 GlobalFragmentMap[clone] = GlobalFragmentMap[tree]; 105 GlobalTraceMap[clone] = GlobalTraceMap[tree]; // clone gets parents of tree 106 GlobalTraceMap[tree] = new ItemList<IItem> { clone }; // tree gets clone as parent 107 var nodes = tree.IterateNodesBreadth().ToList(); 108 for (i = 0; i != nodes.Count; ++i) { 109 if ((GlobalFragmentMap[tree] as GenericWrapper<SymbolicExpressionTreeNode>).Content == nodes[i]) break; 110 } 111 var fragment = (SymbolicExpressionTreeNode)(((SymbolicExpressionTree)clone).IterateNodesBreadth().ElementAt(i)); 112 GlobalFragmentMap[clone] = new GenericWrapper<SymbolicExpressionTreeNode>(fragment); 107 113 } else { 108 114 var original = GlobalCloneMap[tree]; 109 115 GlobalTraceMap[tree] = new ItemList<IItem> { original }; 110 116 } 111 var nodes0 = tree.IterateNodesBreadth() as List<ISymbolicExpressionTreeNode>;117 var nodes0 = tree.IterateNodesBreadth().ToList(); 112 118 Manipulate(RandomParameter.ActualValue, tree); 113 var nodes1 = tree.IterateNodesBreadth() as List<ISymbolicExpressionTreeNode>;114 int i, min = Math.Max(nodes0.Count, nodes1.Count);119 var nodes1 = tree.IterateNodesBreadth().ToList(); 120 int min = Math.Min(nodes0.Count, nodes1.Count); 115 121 for (i = 0; i != min; ++i) 116 122 if (nodes0[i] != nodes1[i]) break; 117 if (i == min) i = 0; 118 GlobalFragmentMap[tree] = new GenericWrapper<ISymbolicExpressionTreeNode>(nodes1[i]); 119 123 GlobalFragmentMap[tree] = new GenericWrapper<SymbolicExpressionTreeNode>(i == min ? null : (SymbolicExpressionTreeNode)nodes1[i]); 120 124 return base.Apply(); 121 125 }
Note: See TracChangeset
for help on using the changeset viewer.