Changeset 189 for trunk/sources/HeuristicLab.StructureIdentification
- Timestamp:
- 04/25/08 12:13:34 (17 years ago)
- Location:
- trunk/sources/HeuristicLab.StructureIdentification
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.StructureIdentification/Manipulation/ChangeNodeTypeManipulation.cs
r180 r189 156 156 int maxArity; 157 157 // create a new tree-node for a randomly selected function 158 IFunctionTree newTree = new FunctionTree(allowedFunctions[random.Next(allowedFunctions.Count)]);158 IFunctionTree newTree = allowedFunctions[random.Next(allowedFunctions.Count)].GetTreeNode(); 159 159 gardener.GetMinMaxArity(newTree.Function, out minArity, out maxArity); 160 160 // if the old child had too many sub-trees then the new child should keep as many sub-trees as possible -
trunk/sources/HeuristicLab.StructureIdentification/Recombination/SizeFairCrossOver.cs
r161 r189 223 223 if(possibleParents.Count == 0) throw new InvalidProgramException(); 224 224 // and select a random one 225 IFunctionTree parent = new FunctionTree(possibleParents.ElementAt(random.Next(possibleParents.Count())));225 IFunctionTree parent = possibleParents.ElementAt(random.Next(possibleParents.Count())).GetTreeNode(); 226 226 227 227 int minArity; -
trunk/sources/HeuristicLab.StructureIdentification/TreeGardener.cs
r182 r189 141 141 142 142 // build the tree 143 IFunctionTree root = new FunctionTree(selectedFunction);143 IFunctionTree root = selectedFunction.GetTreeNode(); 144 144 if(balanceTrees) { 145 145 MakeBalancedTree(root, maxTreeSize - 1, maxTreeHeight - 1); … … 376 376 if(maxTreeHeight == 1 || maxTreeSize == 1) { 377 377 IFunction selectedTerminal = RandomSelect(terminals); 378 return new FunctionTree(selectedTerminal);378 return selectedTerminal.GetTreeNode(); 379 379 } else { 380 380 IFunction[] possibleFunctions = allFunctions.Where(f => GetMinimalTreeHeight(f) <= maxTreeHeight && 381 381 GetMinimalTreeSize(f) <= maxTreeSize).ToArray(); 382 382 IFunction selectedFunction = RandomSelect(possibleFunctions); 383 return new FunctionTree(selectedFunction);383 return selectedFunction.GetTreeNode(); 384 384 } 385 385 } … … 400 400 GetMinimalTreeSize(f) <= maxSubTreeSize).ToArray(); 401 401 IFunction selectedFunction = RandomSelect(possibleFunctions); 402 FunctionTree newSubTree = new FunctionTree(selectedFunction);402 IFunctionTree newSubTree = selectedFunction.GetTreeNode(); 403 403 MakeUnbalancedTree(newSubTree, maxSubTreeSize - 1, maxTreeHeight - 1); 404 404 parent.InsertSubTree(i, newSubTree); … … 424 424 IFunction[] possibleTerminals = GetAllowedSubFunctions(parent.Function, i).Where(f => IsTerminal(f)).ToArray(); 425 425 IFunction selectedTerminal = RandomSelect(possibleTerminals); 426 IFunctionTree newTree = new FunctionTree(selectedTerminal);426 IFunctionTree newTree = selectedTerminal.GetTreeNode(); 427 427 parent.InsertSubTree(i, newTree); 428 428 } else { … … 432 432 !IsTerminal(f)).ToArray(); 433 433 IFunction selectedFunction = RandomSelect(possibleFunctions); 434 FunctionTree newTree = new FunctionTree(selectedFunction);434 IFunctionTree newTree = selectedFunction.GetTreeNode(); 435 435 parent.InsertSubTree(i, newTree); 436 436 MakeBalancedTree(newTree, maxSubTreeSize - 1, maxTreeHeight - 1);
Note: See TracChangeset
for help on using the changeset viewer.