Changeset 9237 for branches/HeuristicLab.EvolutionaryTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Manipulators
- Timestamp:
- 02/21/13 15:42:21 (12 years ago)
- Location:
- branches/HeuristicLab.EvolutionaryTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.EvolutionaryTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding
- Property svn:mergeinfo changed (with no actual effect on merging)
-
branches/HeuristicLab.EvolutionaryTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Manipulators
-
Property
svn:mergeinfo
set to
(toggle deleted branches)
/trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Manipulators merged eligible /trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTree/3.4/Manipulators 3219-3222
-
Property
svn:mergeinfo
set to
(toggle deleted branches)
-
branches/HeuristicLab.EvolutionaryTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Manipulators/ChangeNodeTypeManipulation.cs
r9083 r9237 20 20 #endregion 21 21 22 using System.Collections.Generic; 22 23 using System.Linq; 23 24 using HeuristicLab.Common; 24 25 using HeuristicLab.Core; 25 26 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 26 using System.Collections.Generic;27 27 28 28 namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding { -
branches/HeuristicLab.EvolutionaryTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Manipulators/RemoveBranchManipulation.cs
r9083 r9237 31 31 [StorableClass] 32 32 [Item("RemoveBranchManipulation", "Removes a random sub-tree of the input tree and fixes the tree by generating random subtrees if necessary..")] 33 public sealed class RemoveBranchManipulation : SymbolicExpressionTreeManipulator, ISymbolicExpressionTreeSizeConstraintOperator {33 public sealed class RemoveBranchManipulation : TracingSymbolicExpressionTreeManipulator, ISymbolicExpressionTreeSizeConstraintOperator { 34 34 private const int MAX_TRIES = 100; 35 35 private const string MaximumSymbolicExpressionTreeLengthParameterName = "MaximumSymbolicExpressionTreeLength"; -
branches/HeuristicLab.EvolutionaryTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Manipulators/ReplaceBranchManipulation.cs
r9083 r9237 20 20 #endregion 21 21 22 using System.Collections.Generic; 22 23 using System.Linq; 23 24 using HeuristicLab.Common; … … 26 27 using HeuristicLab.Parameters; 27 28 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 28 using System.Collections.Generic;29 29 30 30 namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding { -
branches/HeuristicLab.EvolutionaryTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Manipulators/TracingSymbolicExpressionTreeManipulator.cs
r9083 r9237 65 65 manipulationTypes.Add(typeof(ChangeNodeTypeManipulation), ManipulationType.ChangeNodeTypeManipulation); 66 66 manipulationTypes.Add(typeof(ReplaceBranchManipulation), ManipulationType.ReplaceBranchManipulation); 67 manipulationTypes.Add(typeof(RemoveBranchManipulation), ManipulationType.RemoveBranchManipulation); 67 68 } 68 69 … … 95 96 } 96 97 97 var concreteType = this.GetType();98 // var concreteType = this.GetType(); 98 99 99 if (!manipulationTypes.ContainsKey(concreteType))100 throw new Exception(this.Name + ": Unknown manipulation type (key not found in the dictionary).");100 // if (!manipulationTypes.ContainsKey(concreteType)) 101 // throw new Exception(this.Name + ": Unknown manipulation type (key not found in the dictionary)."); 101 102 102 var nodes0 = tree.IterateNodesBreadth().ToList(); // list of nodes before manipulation 103 // var nodes0 = tree.IterateNodesBreadth().ToList(); // list of nodes before manipulation 104 // Manipulate(RandomParameter.ActualValue, tree); 105 // var nodes1 = tree.IterateNodesBreadth().ToList(); // list of nodes after manipulation 106 107 var comparer = SymbolicExpressionTreeNodeComparer; 108 var clonedTree = (ISymbolicExpressionTree)tree.Clone(); 109 var nodes0 = clonedTree.IterateNodesBreadth().ToList(); 103 110 Manipulate(RandomParameter.ActualValue, tree); 104 var nodes1 = tree.IterateNodesBreadth().ToList(); // list of nodes after manipulation 111 var nodes1 = tree.IterateNodesBreadth().ToList(); 112 105 113 int min = Math.Min(nodes0.Count, nodes1.Count); 114 int i = 0; while (i != min && comparer.Equals(nodes0[i], nodes1[i])) ++i; 115 fragment = new Fragment(i == min ? null : nodes1[i], 1); 116 GlobalFragmentMap[tree] = fragment; 106 117 107 switch (manipulationTypes[concreteType]) { 108 case ManipulationType.FullTreeShaker: { 109 // the FullTreeShaker changes the local parameters of all the nodes in the tree 110 // therefore, the whole tree is considered to be the fragment 111 fragment = new Fragment(tree.Root.GetSubtree(0).GetSubtree(0)); 112 break; 113 } 114 case ManipulationType.OnePointShaker: { 115 var original = (ISymbolicExpressionTree)GlobalCloneMap[tree]; 116 var nodesOriginal = original.IterateNodesBreadth().ToList(); 117 int i = 0; 118 var comparer = SymbolicExpressionTreeNodeComparer; 119 while (i != min && comparer.Equals(nodesOriginal[i], nodes1[i])) ++i; 120 fragment = new Fragment(i == min ? null : nodes1[i], 1); 121 break; 122 } 123 case ManipulationType.ChangeNodeTypeManipulation: { 124 int i = 0; 125 while (i != min && ReferenceEquals(nodes0[i], nodes1[i])) ++i; 126 fragment = new Fragment(i == min ? null : nodes1[i], 1); 127 break; 128 } 129 case ManipulationType.ReplaceBranchManipulation: { 130 int i = 0; 131 while (i != min && ReferenceEquals(nodes0[i], nodes1[i])) ++i; 132 fragment = new Fragment(i == min ? null : nodes1[i]); 133 break; 134 } 135 default: 136 throw new Exception(Name + ": Unknown manipulaton type."); 137 } 118 119 120 // switch (manipulationTypes[concreteType]) { 121 // case ManipulationType.FullTreeShaker: { 122 // // the FullTreeShaker changes the local parameters of all the nodes in the tree 123 // // therefore, the whole tree is considered to be the fragment 124 // fragment = new Fragment(tree.Root.GetSubtree(0).GetSubtree(0)); 125 // break; 126 // } 127 // case ManipulationType.OnePointShaker: { 128 // var original = (ISymbolicExpressionTree)GlobalCloneMap[tree]; 129 // var nodesOriginal = original.IterateNodesBreadth().ToList(); 130 // int i = 0; 131 // var comparer = SymbolicExpressionTreeNodeComparer; 132 // while (i != min && comparer.Equals(nodesOriginal[i], nodes1[i])) ++i; 133 // fragment = new Fragment(i == min ? null : nodes1[i], 1); 134 // break; 135 // } 136 // case ManipulationType.ChangeNodeTypeManipulation: { 137 // int i = 0; 138 // while (i != min && ReferenceEquals(nodes0[i], nodes1[i])) ++i; 139 // fragment = new Fragment(i == min ? null : nodes1[i], 1); 140 // break; 141 // } 142 // case ManipulationType.ReplaceBranchManipulation: { 143 // int i = 0; 144 // while (i != min && ReferenceEquals(nodes0[i], nodes1[i])) ++i; 145 // fragment = new Fragment(i == min ? null : nodes1[i]); 146 // break; 147 // } 148 // case ManipulationType.RemoveBranchManipulation: { 149 // int i = 0; 150 // while (i != min && ReferenceEquals(nodes0[i], nodes1[i])) ++i; 151 // fragment = new Fragment(i == min ? null : nodes1[i]); 152 // break; 153 // } 154 // default: 155 // throw new Exception(Name + ": Unknown manipulaton type."); 156 // } 138 157 139 158 GlobalFragmentMap[tree] = fragment; … … 148 167 public const byte ChangeNodeTypeManipulation = 3; 149 168 public const byte ReplaceBranchManipulation = 4; 169 public const byte RemoveBranchManipulation = 5; 150 170 } 151 171 }
Note: See TracChangeset
for help on using the changeset viewer.