Free cookie consent management tool by TermsFeed Policy Generator

Changeset 289


Ignore:
Timestamp:
06/03/08 17:29:31 (16 years ago)
Author:
gkronber
Message:
  • also added code to account for constraints regarding the allowed sub-functions for the clean-up part (where terminals (or if not possible trees of minimal size) are inserted at the open ends. (follow up to r288 and r286)
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.StructureIdentification/TreeGardener.cs

    r288 r289  
    128128          parent.InsertSubTree(a, RandomSelect(GetAllowedSubFunctions(parent.Function, a).Where(f => IsTerminal(f)).ToArray()).GetTreeNode());
    129129        } else {
    130           IFunction selectedFunction = RandomSelect(GetAllowedSubFunctions(parent.Function, a).Where(f => !IsTerminal(f)).ToArray());
     130          IFunction selectedFunction = RandomSelect(GetAllowedSubFunctions(parent.Function, a).Where(
     131            f => !IsTerminal(f) && GetMinimalTreeHeight(f) + (d-1) <= maxDepth).ToArray());
    131132          IFunctionTree newTree = selectedFunction.GetTreeNode();
    132133          parent.RemoveSubTree(a);
     
    153154        int a = (int)nextExtension[1];
    154155        int d = (int)nextExtension[2];
    155         IFunction selectedTerminal = RandomSelect(terminals);
    156156        parent.RemoveSubTree(a);
    157         parent.InsertSubTree(a, selectedTerminal.GetTreeNode());
     157        parent.InsertSubTree(a, CreateRandomTree(GetAllowedSubFunctions(parent.Function, a), 1, 1)); // append a tree with minimal possible height
    158158      }
    159159      return root;
Note: See TracChangeset for help on using the changeset viewer.