- Timestamp:
- 04/24/08 14:29:31 (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.StructureIdentification/Manipulation/ChangeNodeTypeManipulation.cs
r167 r180 128 128 129 129 private IFunctionTree ChangeTerminalType(IFunctionTree parent, IFunctionTree child, int childIndex, TreeGardener gardener, MersenneTwister random) { 130 IList<IFunction> allowed Children;130 IList<IFunction> allowedTerminals; 131 131 if (parent == null) { 132 allowed Children= gardener.Terminals;132 allowedTerminals = gardener.Terminals; 133 133 } else { 134 allowed Children= new List<IFunction>();134 allowedTerminals = new List<IFunction>(); 135 135 var allAllowedChildren = gardener.GetAllowedSubFunctions(parent.Function, childIndex); 136 136 foreach(IFunction c in allAllowedChildren) { 137 if(gardener.IsTerminal(c)) allowed Children.Add(c);137 if(gardener.IsTerminal(c)) allowedTerminals.Add(c); 138 138 } 139 139 } 140 140 // selecting from the terminals should always work since the current child was also a terminal 141 141 // so in the worst case we will just create a new terminal of the same type again. 142 return gardener.CreateRandomTree(allowed Children[random.Next(allowedChildren.Count)], 1, 1, false);142 return gardener.CreateRandomTree(allowedTerminals, 1, 1); 143 143 } 144 144
Note: See TracChangeset
for help on using the changeset viewer.