Changeset 199
- Timestamp:
- 04/27/08 19:42:37 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.StructureIdentification/TreeGardener.cs
r189 r199 421 421 int maxSubTreeSize = maxTreeSize / actualArity; 422 422 for(int i = 0; i < actualArity; i++) { 423 if(maxTreeHeight == 1 || maxSubTreeSize == 1) { 424 IFunction[] possibleTerminals = GetAllowedSubFunctions(parent.Function, i).Where(f => IsTerminal(f)).ToArray(); 425 IFunction selectedTerminal = RandomSelect(possibleTerminals); 423 // first try to find a function that fits into the maxHeight and maxSize limits 424 IFunction[] possibleFunctions = GetAllowedSubFunctions(parent.Function, i).Where( 425 f => GetMinimalTreeHeight(f) <= maxTreeHeight && 426 GetMinimalTreeSize(f) <= maxSubTreeSize && 427 !IsTerminal(f)).ToArray(); 428 // no possible function found => extend function set to terminals 429 if(possibleFunctions.Length == 0) { 430 possibleFunctions = GetAllowedSubFunctions(parent.Function, i).Where(f => IsTerminal(f)).ToArray(); 431 IFunction selectedTerminal = RandomSelect(possibleFunctions); 426 432 IFunctionTree newTree = selectedTerminal.GetTreeNode(); 427 433 parent.InsertSubTree(i, newTree); 428 434 } else { 429 IFunction[] possibleFunctions = GetAllowedSubFunctions(parent.Function, i).Where(430 f => GetMinimalTreeHeight(f) <= maxTreeHeight &&431 GetMinimalTreeSize(f) <= maxSubTreeSize &&432 !IsTerminal(f)).ToArray();433 435 IFunction selectedFunction = RandomSelect(possibleFunctions); 434 436 IFunctionTree newTree = selectedFunction.GetTreeNode();
Note: See TracChangeset
for help on using the changeset viewer.