Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
04/25/08 12:13:34 (17 years ago)
Author:
gkronber
Message:

fixed #131

Location:
trunk/sources/HeuristicLab.StructureIdentification
Files:
3 edited

Legend:

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

    r180 r189  
    156156      int maxArity;
    157157      // 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();
    159159      gardener.GetMinMaxArity(newTree.Function, 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
  • trunk/sources/HeuristicLab.StructureIdentification/Recombination/SizeFairCrossOver.cs

    r161 r189  
    223223      if(possibleParents.Count == 0) throw new InvalidProgramException();
    224224      // 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();
    226226
    227227      int minArity;
  • trunk/sources/HeuristicLab.StructureIdentification/TreeGardener.cs

    r182 r189  
    141141
    142142      // build the tree
    143       IFunctionTree root = new FunctionTree(selectedFunction);
     143      IFunctionTree root = selectedFunction.GetTreeNode();
    144144      if(balanceTrees) {
    145145        MakeBalancedTree(root, maxTreeSize - 1, maxTreeHeight - 1);
     
    376376      if(maxTreeHeight == 1 || maxTreeSize == 1) {
    377377        IFunction selectedTerminal = RandomSelect(terminals);
    378         return new FunctionTree(selectedTerminal);
     378        return selectedTerminal.GetTreeNode();
    379379      } else {
    380380        IFunction[] possibleFunctions = allFunctions.Where(f => GetMinimalTreeHeight(f) <= maxTreeHeight &&
    381381          GetMinimalTreeSize(f) <= maxTreeSize).ToArray();
    382382        IFunction selectedFunction = RandomSelect(possibleFunctions);
    383         return new FunctionTree(selectedFunction);
     383        return selectedFunction.GetTreeNode();
    384384      }
    385385    }
     
    400400            GetMinimalTreeSize(f) <= maxSubTreeSize).ToArray();
    401401          IFunction selectedFunction = RandomSelect(possibleFunctions);
    402           FunctionTree newSubTree = new FunctionTree(selectedFunction);
     402          IFunctionTree newSubTree = selectedFunction.GetTreeNode();
    403403          MakeUnbalancedTree(newSubTree, maxSubTreeSize - 1, maxTreeHeight - 1);
    404404          parent.InsertSubTree(i, newSubTree);
     
    424424            IFunction[] possibleTerminals = GetAllowedSubFunctions(parent.Function, i).Where(f => IsTerminal(f)).ToArray();
    425425            IFunction selectedTerminal = RandomSelect(possibleTerminals);
    426             IFunctionTree newTree = new FunctionTree(selectedTerminal);
     426            IFunctionTree newTree = selectedTerminal.GetTreeNode();
    427427            parent.InsertSubTree(i, newTree);
    428428          } else {
     
    432432              !IsTerminal(f)).ToArray();
    433433            IFunction selectedFunction = RandomSelect(possibleFunctions);
    434             FunctionTree newTree = new FunctionTree(selectedFunction);
     434            IFunctionTree newTree = selectedFunction.GetTreeNode();
    435435            parent.InsertSubTree(i, newTree);
    436436            MakeBalancedTree(newTree, maxSubTreeSize - 1, maxTreeHeight - 1);
Note: See TracChangeset for help on using the changeset viewer.