Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
04/28/08 21:35:23 (17 years ago)
Author:
gkronber
Message:

bug fixes in struct-id operators

File:
1 edited

Legend:

Unmodified
Added
Removed
  • TabularUnified trunk/sources/HeuristicLab.StructureIdentification/Manipulation/ChangeNodeTypeManipulation.cs

    r189 r202  
    156156      int maxArity;
    157157      // create a new tree-node for a randomly selected function
    158       IFunctionTree newTree = allowedFunctions[random.Next(allowedFunctions.Count)].GetTreeNode();
    159       gardener.GetMinMaxArity(newTree.Function, out minArity, out maxArity);
     158      IFunction selectedFunction = allowedFunctions[random.Next(allowedFunctions.Count)];
     159      gardener.GetMinMaxArity(selectedFunction, out minArity, out maxArity);
    160160      // if the old child had too many sub-trees then the new child should keep as many sub-trees as possible
    161161      if (actualArity > maxArity)
     
    165165      // create a list that holds old sub-trees that we can reuse in the new tree
    166166      List<IFunctionTree> availableSubTrees = new List<IFunctionTree>(child.SubTrees);
    167       List<IFunctionTree> freshSubTrees = new List<IFunctionTree>() { newTree };
     167      List<IFunctionTree> freshSubTrees = new List<IFunctionTree>();
     168      IFunctionTree newTree = selectedFunction.GetTreeNode();
    168169      // randomly select the sub-trees that we keep
    169170      for (int i = 0; i < actualArity; i++) {
     
    172173        // then use a random existing sub-tree. When there are no existing sub-trees
    173174        // that fit in the given slot then create a new random tree and use it for the slot
    174         ICollection<IFunction> allowedSubFunctions = gardener.GetAllowedSubFunctions(newTree.Function, i);
     175        ICollection<IFunction> allowedSubFunctions = gardener.GetAllowedSubFunctions(selectedFunction, i);
    175176        var matchingSubTrees = availableSubTrees.Where(subTree => allowedSubFunctions.Contains(subTree.Function));
    176177        if (matchingSubTrees.Count() > 0) {
     
    186187        }
    187188      }
     189      freshSubTrees.Add(newTree);
    188190      uninitializedBranches = freshSubTrees;
    189191      return newTree;
Note: See TracChangeset for help on using the changeset viewer.