Free cookie consent management tool by TermsFeed Policy Generator

Changeset 5549


Ignore:
Timestamp:
02/22/11 19:04:54 (14 years ago)
Author:
gkronber
Message:

#1418 unified size/height vs. length/depth terminology and adapted unit tests for symbolic expression tree encoding version 3.4

Location:
branches/DataAnalysis Refactoring
Files:
31 edited

Legend:

Unmodified
Added
Removed
  • branches/DataAnalysis Refactoring/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views/3.4/SymbolicExpressionTreeChart.cs

    r5513 r5549  
    124124        graphics.Clear(backgroundColor);
    125125        if (tree != null) {
    126           int height = this.Height / tree.Height;
     126          int height = this.Height / tree.Depth;
    127127          DrawFunctionTree(tree, graphics, 0, 0, this.Width, height);
    128128        }
     
    284284      xBoundaries[0] = x;
    285285      for (int i = 0; i < node.SubTrees.Count(); i++) {
    286         xBoundaries[i + 1] = (int)(xBoundaries[i] + (width * (double)node.SubTrees.ElementAt(i).GetSize()) / (node.GetSize() - 1));
     286        xBoundaries[i + 1] = (int)(xBoundaries[i] + (width * (double)node.SubTrees.ElementAt(i).GetLength()) / (node.GetLength() - 1));
    287287        DrawFunctionTree(node.SubTrees.ElementAt(i), graphics, xBoundaries[i], y + height,
    288288          xBoundaries[i + 1] - xBoundaries[i], height, connectFrom);
     
    305305      Image image = new Bitmap(Width, Height);
    306306      using (Graphics g = Graphics.FromImage(image)) {
    307         int height = this.Height / tree.Height;
     307        int height = this.Height / tree.Depth;
    308308        DrawFunctionTree(tree, g, 0, 0, Width, height);
    309309      }
     
    316316        using (Metafile file = new Metafile(filename, g.GetHdc())) {
    317317          using (Graphics emfFile = Graphics.FromImage(file)) {
    318             int height = this.Height / tree.Height;
     318            int height = this.Height / tree.Depth;
    319319            DrawFunctionTree(tree, emfFile, 0, 0, Width, height);
    320320          }
  • branches/DataAnalysis Refactoring/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Analyzers/MinAverageMaxSymbolicExpressionTreeLengthAnalyzer.cs

    r5510 r5549  
    108108    private void AfterDeserialization() {
    109109      SymbolicExpressionTreeParameter.DepthChanged += new EventHandler(SymbolicExpressionTreeParameter_DepthChanged);
    110       SymbolicExpressionTreeLengthParameter.DepthChanged += new EventHandler(SymbolicExpressionTreeSizeParameter_DepthChanged);
     110      SymbolicExpressionTreeLengthParameter.DepthChanged += new EventHandler(SymbolicExpressionTreeLengthParameter_DepthChanged);
    111111    }
    112112
     
    119119    }
    120120
    121     private void SymbolicExpressionTreeSizeParameter_DepthChanged(object sender, EventArgs e) {
     121    private void SymbolicExpressionTreeLengthParameter_DepthChanged(object sender, EventArgs e) {
    122122      OnDepthParameterChanged();
    123123    }
  • branches/DataAnalysis Refactoring/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Analyzers/SymbolicExpressionTreeLengthCalculator.cs

    r5499 r5549  
    6666
    6767    public override IOperation Apply() {
    68       SymbolicExpressionTreeLength = new DoubleValue(SymbolicExpressionTree.Size);
     68      SymbolicExpressionTreeLength = new DoubleValue(SymbolicExpressionTree.Length);
    6969      return base.Apply();
    7070    }
  • branches/DataAnalysis Refactoring/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/ArchitectureManipulators/ArgumentCreater.cs

    r5529 r5549  
    101101      ArgumentTreeNode newArgumentNode = MakeArgumentNode(newArgumentIndex);
    102102
    103       // this operation potentially creates very big trees so the access to the size property might throw overflow exception
     103      // this operation potentially creates very big trees so the access to the length property might throw overflow exception
    104104      try {
    105         if (CreateNewArgumentForDefun(random, clonedTree, selectedDefunBranch, newArgumentNode) && clonedTree.Size <= maxTreeLength && clonedTree.Height <= maxTreeDepth) {
     105        if (CreateNewArgumentForDefun(random, clonedTree, selectedDefunBranch, newArgumentNode) && clonedTree.Length <= maxTreeLength && clonedTree.Depth <= maxTreeDepth) {
    106106
    107107          // size constraints are fulfilled
  • branches/DataAnalysis Refactoring/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/ArchitectureManipulators/SubroutineCreater.cs

    r5510 r5549  
    8686        // allowed maximum number of ADF reached => abort
    8787        return false;
    88       if (symbolicExpressionTree.Size + 4 > maxTreeLength)
    89         // defining a new function causes an size increase by 4 nodes (max) if the max tree size is reached => abort
     88      if (symbolicExpressionTree.Length + 4 > maxTreeLength)
     89        // defining a new function causes an length increase by 4 nodes (max) if the max tree length is reached => abort
    9090        return false;
    9191      string formatString = new StringBuilder().Append('0', (int)Math.Log10(maxFunctionDefinitions * 10 - 1)).ToString(); // >= 100 functions => ###
     
    9595      // select a random body (either the result producing branch or an ADF branch)
    9696      var bodies = from node in symbolicExpressionTree.Root.SubTrees
    97                    select new { Tree = node, Size = node.GetSize() };
    98       var totalNumberOfBodyNodes = bodies.Select(x => x.Size).Sum();
     97                   select new { Tree = node, Length = node.GetLength() };
     98      var totalNumberOfBodyNodes = bodies.Select(x => x.Length).Sum();
    9999      int r = random.Next(totalNumberOfBodyNodes);
    100100      int aggregatedNumberOfBodyNodes = 0;
    101101      ISymbolicExpressionTreeNode selectedBody = null;
    102102      foreach (var body in bodies) {
    103         aggregatedNumberOfBodyNodes += body.Size;
     103        aggregatedNumberOfBodyNodes += body.Length;
    104104        if (aggregatedNumberOfBodyNodes > r)
    105105          selectedBody = body.Tree;
  • branches/DataAnalysis Refactoring/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/ArchitectureManipulators/SubroutineDeleter.cs

    r5529 r5549  
    9595        var selectedSymbol = allowedSymbolsList.SelectRandom(weights, random);
    9696
    97         int minPossibleSize = invocationCutPoint.Parent.Grammar.GetMinExpressionLength(selectedSymbol);
    98         int maxSize = Math.Max(minPossibleSize, invocationCutPoint.ReplacedChild.GetSize());
    99         int minPossibleHeight = invocationCutPoint.Parent.Grammar.GetMinExpressionDepth(selectedSymbol);
    100         int maxHeight = Math.Max(minPossibleHeight, invocationCutPoint.ReplacedChild.GetHeight());
     97        int minPossibleLength = invocationCutPoint.Parent.Grammar.GetMinExpressionLength(selectedSymbol);
     98        int maxLength = Math.Max(minPossibleLength, invocationCutPoint.ReplacedChild.GetLength());
     99        int minPossibleDepth = invocationCutPoint.Parent.Grammar.GetMinExpressionDepth(selectedSymbol);
     100        int maxDepth = Math.Max(minPossibleDepth, invocationCutPoint.ReplacedChild.GetDepth());
    101101        replacementTree = selectedSymbol.CreateTreeNode();
    102102        if (replacementTree.HasLocalParameters)
     
    105105        invocationCutPoint.Parent.InsertSubTree(invocationCutPoint.ReplacedChildIndex, replacementTree);
    106106
    107         ProbabilisticTreeCreator.PTC2(random, replacementTree, maxSize, maxHeight, 0, 0);
     107        ProbabilisticTreeCreator.PTC2(random, replacementTree, maxLength, maxDepth, 0, 0);
    108108
    109109        invocationCutPoint = (from node in symbolicExpressionTree.IterateNodesPrefix()
  • branches/DataAnalysis Refactoring/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Creators/ProbabilisticTreeCreator.cs

    r5529 r5549  
    3232namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding {
    3333  [StorableClass]
    34   [Item("ProbabilisticTreeCreator", "An operator that creates new symbolic expression trees with uniformly distributed size")]
     34  [Item("ProbabilisticTreeCreator", "An operator that creates new symbolic expression trees with uniformly distributed length")]
    3535  public sealed class ProbabilisticTreeCreator : SymbolicExpressionTreeCreator,
    3636    ISymbolicExpressionTreeSizeConstraintOperator, ISymbolicExpressionTreeGrammarBasedOperator, ISymbolicExpressionTreeArchitectureAlteringOperator {
     
    9898
    9999    public static ISymbolicExpressionTree Create(IRandom random, ISymbolicExpressionTreeGrammar grammar,
    100       int maxTreeSize, int maxTreeHeight,
     100      int maxTreeLength, int maxTreeDepth,
    101101      int maxFunctionDefinitions, int maxFunctionArguments
    102102      ) {
     
    105105      if (rootNode.HasLocalParameters) rootNode.ResetLocalParameters(random);
    106106      rootNode.SetGrammar(new SymbolicExpressionTreeGrammar(grammar));
    107       tree.Root = PTC2(random, rootNode, maxTreeSize, maxTreeHeight, maxFunctionDefinitions, maxFunctionArguments);
     107      tree.Root = PTC2(random, rootNode, maxTreeLength, maxTreeDepth, maxFunctionDefinitions, maxFunctionArguments);
    108108      return tree;
    109109    }
     
    116116
    117117    public static ISymbolicExpressionTreeNode PTC2(IRandom random, ISymbolicExpressionTreeNode seedNode,
    118       int maxTreeSize, int maxDepth, int maxFunctionDefinitions, int maxFunctionArguments) {
    119       // tree size is limited by the grammar and by the explicit size constraints
    120       int allowedMinSize = seedNode.Grammar.GetMinExpressionLength(seedNode.Symbol);
    121       int allowedMaxSize = Math.Min(maxTreeSize, seedNode.Grammar.GetMaxExpressionLength(seedNode.Symbol));
     118      int maxLength, int maxDepth, int maxFunctionDefinitions, int maxFunctionArguments) {
     119      // tree length is limited by the grammar and by the explicit size constraints
     120      int allowedMinLength = seedNode.Grammar.GetMinExpressionLength(seedNode.Symbol);
     121      int allowedMaxLength = Math.Min(maxLength, seedNode.Grammar.GetMaxExpressionLength(seedNode.Symbol));
    122122      int tries = 0;
    123123      while (tries++ < MAX_TRIES) {
    124         // select a target tree size uniformly in the possible range (as determined by explicit limits and limits of the grammar)
    125         int treeSize;
    126         treeSize = random.Next(allowedMinSize, allowedMaxSize + 1);
    127         if (treeSize <= 1 || maxDepth <= 1) return seedNode;
    128 
    129         bool success = CreateFullTreeFromSeed(random, seedNode, seedNode.Grammar, treeSize, maxDepth, maxFunctionDefinitions, maxFunctionArguments);
     124        // select a target tree length uniformly in the possible range (as determined by explicit limits and limits of the grammar)
     125        int targetTreeLength;
     126        targetTreeLength = random.Next(allowedMinLength, allowedMaxLength + 1);
     127        if (targetTreeLength <= 1 || maxDepth <= 1) return seedNode;
     128
     129        bool success = CreateFullTreeFromSeed(random, seedNode, seedNode.Grammar, targetTreeLength, maxDepth, maxFunctionDefinitions, maxFunctionArguments);
    130130
    131131        // if successful => check constraints and return the tree if everything looks ok       
    132         if (success && seedNode.GetSize() <= maxTreeSize && seedNode.GetHeight() <= maxDepth) {
     132        if (success && seedNode.GetLength() <= maxLength && seedNode.GetDepth() <= maxDepth) {
    133133          return seedNode;
    134134        } else {
     
    136136          while (seedNode.SubTrees.Count() > 0) seedNode.RemoveSubTree(0);
    137137        }
    138         // try a different size MAX_TRIES times
     138        // try a different length MAX_TRIES times
    139139      }
    140140      throw new ArgumentException("Couldn't create a random valid tree.");
     
    142142
    143143    private static bool CreateFullTreeFromSeed(IRandom random, ISymbolicExpressionTreeNode root, ISymbolicExpressionTreeGrammar globalGrammar,
    144       int size, int maxDepth, int maxFunctionDefinitions, int maxFunctionArguments) {
     144      int targetLength, int maxDepth, int maxFunctionDefinitions, int maxFunctionArguments) {
    145145      try {
    146         TryCreateFullTreeFromSeed(random, root, globalGrammar, size, maxDepth, maxFunctionDefinitions, maxFunctionArguments);
     146        TryCreateFullTreeFromSeed(random, root, globalGrammar, targetLength, maxDepth, maxFunctionDefinitions, maxFunctionArguments);
    147147        return true;
    148148      }
     
    151151
    152152    private static void TryCreateFullTreeFromSeed(IRandom random, ISymbolicExpressionTreeNode root, ISymbolicExpressionTreeGrammar globalGrammar,
    153       int size, int maxDepth, int maxFunctionDefinitions, int maxFunctionArguments) {
     153      int targetLength, int maxDepth, int maxFunctionDefinitions, int maxFunctionArguments) {
    154154      List<TreeExtensionPoint> extensionPoints = new List<TreeExtensionPoint>();
    155       int currentSize = 1;
    156       int totalListMinSize = globalGrammar.GetMinExpressionLength(root.Symbol) - 1;
    157       int actualArity = SampleArity(random, root, size);
     155      int currentLength = 1;
     156      int totalListMinLength = globalGrammar.GetMinExpressionLength(root.Symbol) - 1;
     157      int actualArity = SampleArity(random, root, targetLength);
    158158      for (int i = 0; i < actualArity; i++) {
    159159        // insert a dummy sub-tree and add the pending extension to the list
     
    163163      }
    164164      // while there are pending extension points and we have not reached the limit of adding new extension points
    165       while (extensionPoints.Count > 0 && totalListMinSize + currentSize < size) {
     165      while (extensionPoints.Count > 0 && totalListMinLength + currentLength < targetLength) {
    166166        int randomIndex = random.Next(extensionPoints.Count);
    167167        TreeExtensionPoint nextExtension = extensionPoints[randomIndex];
     
    176176                                where parent.Grammar.IsAllowedChild(parent.Symbol, s, argumentIndex)
    177177                                where parent.Grammar.GetMinExpressionDepth(s) + extensionDepth - 1 < maxDepth
    178                                 where parent.Grammar.GetMaxExpressionLength(s) > size - totalListMinSize - currentSize
     178                                where parent.Grammar.GetMaxExpressionLength(s) > targetLength - totalListMinLength - currentLength
    179179                                select s)
    180180                               .ToList();
     
    188188          InitializeNewTreeNode(random, root, newTree, maxFunctionDefinitions, maxFunctionArguments);
    189189
    190           currentSize++;
    191           totalListMinSize--;
    192 
    193           actualArity = SampleArity(random, newTree, size - currentSize);
     190          currentLength++;
     191          totalListMinLength--;
     192
     193          actualArity = SampleArity(random, newTree, targetLength - currentLength);
    194194          for (int i = 0; i < actualArity; i++) {
    195195            // insert a dummy sub-tree and add the pending extension to the list
     
    198198            extensionPoints.Add(new TreeExtensionPoint { Parent = newTree, ChildIndex = i, ExtensionPointDepth = extensionDepth + 1 });
    199199          }
    200           totalListMinSize += newTree.Grammar.GetMinExpressionLength(newTree.Symbol);
     200          totalListMinLength += newTree.Grammar.GetMinExpressionLength(newTree.Symbol);
    201201        }
    202202      }
     
    283283    }
    284284
    285     private static int SampleArity(IRandom random, ISymbolicExpressionTreeNode node, int targetSize) {
     285    private static int SampleArity(IRandom random, ISymbolicExpressionTreeNode node, int targetLength) {
    286286      // select actualArity randomly with the constraint that the sub-trees in the minimal arity can become large enough
    287287      int minArity = node.Grammar.GetMinSubtreeCount(node.Symbol);
    288288      int maxArity = node.Grammar.GetMaxSubtreeCount(node.Symbol);
    289       if (maxArity > targetSize) {
    290         maxArity = targetSize;
    291       }
    292       // the min number of sub-trees has to be set to a value that is large enough so that the largest possible tree is at least tree size
    293       // if 1..3 trees are possible and the largest possible first sub-tree is smaller larger than the target size then minArity should be at least 2
     289      if (maxArity > targetLength) {
     290        maxArity = targetLength;
     291      }
     292      // the min number of sub-trees has to be set to a value that is large enough so that the largest possible tree is at least tree length
     293      // if 1..3 trees are possible and the largest possible first sub-tree is smaller larger than the target length then minArity should be at least 2
    294294      long aggregatedLongestExpressionLength = 0;
    295295      for (int i = 0; i < maxArity; i++) {
    296296        aggregatedLongestExpressionLength += (from s in node.Grammar.GetAllowedSymbols(node.Symbol, i)
    297297                                              select node.Grammar.GetMaxExpressionLength(s)).Max();
    298         if (aggregatedLongestExpressionLength < targetSize) minArity = i;
     298        if (aggregatedLongestExpressionLength < targetLength) minArity = i;
    299299        else break;
    300300      }
    301301
    302       // the max number of sub-trees has to be set to a value that is small enough so that the smallest possible tree is at most tree size
    303       // if 1..3 trees are possible and the smallest possible first sub-tree is already larger than the target size then maxArity should be at most 0
     302      // the max number of sub-trees has to be set to a value that is small enough so that the smallest possible tree is at most tree length
     303      // if 1..3 trees are possible and the smallest possible first sub-tree is already larger than the target length then maxArity should be at most 0
    304304      long aggregatedShortestExpressionLength = 0;
    305305      for (int i = 0; i < maxArity; i++) {
    306306        aggregatedShortestExpressionLength += (from s in node.Grammar.GetAllowedSymbols(node.Symbol, i)
    307307                                               select node.Grammar.GetMinExpressionLength(s)).Min();
    308         if (aggregatedShortestExpressionLength > targetSize) {
     308        if (aggregatedShortestExpressionLength > targetLength) {
    309309          maxArity = i;
    310310          break;
  • branches/DataAnalysis Refactoring/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Crossovers/SubtreeCrossover.cs

    r5510 r5549  
    8686    public static ISymbolicExpressionTree Cross(IRandom random,
    8787      ISymbolicExpressionTree parent0, ISymbolicExpressionTree parent1,
    88       double internalCrossoverPointProbability, int maxTreeSize, int maxTreeHeight) {
     88      double internalCrossoverPointProbability, int maxTreeLength, int maxTreeDepth) {
    8989      // select a random crossover point in the first parent
    9090      ISymbolicExpressionTreeNode crossoverPoint0;
    9191      int replacedSubtreeIndex;
    92       SelectCrossoverPoint(random, parent0, internalCrossoverPointProbability, maxTreeSize, maxTreeHeight, out crossoverPoint0, out replacedSubtreeIndex);
    93 
    94       // calculate the max size and height that the inserted branch can have
    95       int maxInsertedBranchSize = maxTreeSize - (parent0.Size - crossoverPoint0.GetSubTree(replacedSubtreeIndex).GetSize());
    96       int maxInsertedBranchHeight = maxTreeHeight - GetBranchLevel(parent0.Root, crossoverPoint0);
     92      SelectCrossoverPoint(random, parent0, internalCrossoverPointProbability, maxTreeLength, maxTreeDepth, out crossoverPoint0, out replacedSubtreeIndex);
     93
     94      // calculate the max length and depth that the inserted branch can have
     95      int maxInsertedBranchLength = maxTreeLength - (parent0.Length - crossoverPoint0.GetSubTree(replacedSubtreeIndex).GetLength());
     96      int maxInsertedBranchDepth = maxTreeDepth - GetBranchLevel(parent0.Root, crossoverPoint0);
    9797
    9898      List<ISymbolicExpressionTreeNode> allowedBranches = new List<ISymbolicExpressionTreeNode>();
    9999      parent1.Root.ForEachNodePostfix((n) => {
    100         if (n.GetSize() <= maxInsertedBranchSize &&
    101           n.GetHeight() <= maxInsertedBranchHeight &&
     100        if (n.GetLength() <= maxInsertedBranchLength &&
     101          n.GetDepth() <= maxInsertedBranchDepth &&
    102102          IsMatchingPointType(crossoverPoint0, replacedSubtreeIndex, n))
    103103          allowedBranches.Add(n);
     
    134134    }
    135135
    136     private static void SelectCrossoverPoint(IRandom random, ISymbolicExpressionTree parent0, double internalNodeProbability, int maxBranchSize, int maxBranchHeight, out ISymbolicExpressionTreeNode crossoverPoint, out int subtreeIndex) {
     136    private static void SelectCrossoverPoint(IRandom random, ISymbolicExpressionTree parent0, double internalNodeProbability, int maxBranchLength, int maxBranchDepth, out ISymbolicExpressionTreeNode crossoverPoint, out int subtreeIndex) {
    137137      if (internalNodeProbability < 0.0 || internalNodeProbability > 1.0) throw new ArgumentException("internalNodeProbability");
    138138      List<CrossoverPoint> internalCrossoverPoints = new List<CrossoverPoint>();
     
    141141        if (n.SubTrees.Count() > 0 && n != parent0.Root) {
    142142          foreach (var child in n.SubTrees) {
    143             if (child.GetSize() <= maxBranchSize &&
    144                 child.GetHeight() <= maxBranchHeight) {
     143            if (child.GetLength() <= maxBranchLength &&
     144                child.GetDepth() <= maxBranchDepth) {
    145145              if (child.SubTrees.Count() > 0)
    146146                internalCrossoverPoints.Add(new CrossoverPoint(n, child));
  • branches/DataAnalysis Refactoring/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Interfaces/ISymbolicExpressionTree.cs

    r5510 r5549  
    2626  public interface ISymbolicExpressionTree : IItem {
    2727    ISymbolicExpressionTreeNode Root { get; set; }
    28     int Size { get; }
    29     int Height { get; }
     28    int Length { get; }
     29    int Depth { get; }
    3030
    3131    IEnumerable<ISymbolicExpressionTreeNode> IterateNodesPrefix();
  • branches/DataAnalysis Refactoring/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Interfaces/ISymbolicExpressionTreeNode.cs

    r5529 r5549  
    3030    bool HasLocalParameters { get; }
    3131
    32     int GetHeight();
    33     int GetSize();
     32    int GetDepth();
     33    int GetLength();
    3434
    3535    IEnumerable<ISymbolicExpressionTreeNode> IterateNodesPostfix();
  • branches/DataAnalysis Refactoring/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Manipulators/ReplaceBranchManipulation.cs

    r5529 r5549  
    7676                               .SelectRandom(random);
    7777
    78       int maxLength = maxTreeLength - symbolicExpressionTree.Size + manipulationPoint.Node.GetSize();
    79       int maxDepth = maxTreeDepth - symbolicExpressionTree.Height + manipulationPoint.Node.GetHeight();
     78      int maxLength = maxTreeLength - symbolicExpressionTree.Length + manipulationPoint.Node.GetLength();
     79      int maxDepth = maxTreeDepth - symbolicExpressionTree.Depth + manipulationPoint.Node.GetDepth();
    8080      // find possible symbols for the node (also considering the existing branches below it)
    8181      var allowedSymbols = (from symbol in manipulationPoint.Parent.Grammar.GetAllowedSymbols(manipulationPoint.Parent.Symbol, manipulationPoint.Index)
  • branches/DataAnalysis Refactoring/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/SymbolicExpressionTree.cs

    r5532 r5549  
    4747    }
    4848
    49     public int Size {
     49    public int Length {
    5050      get {
    5151        if (root == null)
    5252          return 0;
    53         return root.GetSize();
     53        return root.GetLength();
    5454      }
    5555    }
    5656
    57     public int Height {
     57    public int Depth {
    5858      get {
    5959        if (root == null)
    6060          return 0;
    61         return root.GetHeight();
     61        return root.GetDepth();
    6262      }
    6363    }
  • branches/DataAnalysis Refactoring/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/SymbolicExpressionTreeNode.cs

    r5529 r5549  
    3636
    3737    // cached values to prevent unnecessary tree iterations
    38     private ushort size;
    39     private ushort height;
     38    private ushort length;
     39    private ushort depth;
    4040
    4141    public ISymbol Symbol {
     
    9999    }
    100100
    101     public int GetSize() {
    102       if (size > 0) return size;
     101    public int GetLength() {
     102      if (length > 0) return length;
    103103      else {
    104         size = 1;
     104        length = 1;
    105105        if (subTrees != null) {
    106106          for (int i = 0; i < subTrees.Count; i++) {
    107             checked { size += (ushort)subTrees[i].GetSize(); }
     107            checked { length += (ushort)subTrees[i].GetLength(); }
    108108          }
    109109        }
    110         return size;
     110        return length;
    111111      }
    112112    }
    113113
    114     public int GetHeight() {
    115       if (height > 0) return height;
     114    public int GetDepth() {
     115      if (depth > 0) return depth;
    116116      else {
    117117        if (subTrees != null) {
    118           for (int i = 0; i < subTrees.Count; i++) height = Math.Max(height, (ushort)subTrees[i].GetHeight());
     118          for (int i = 0; i < subTrees.Count; i++) depth = Math.Max(depth, (ushort)subTrees[i].GetDepth());
    119119        }
    120         height++;
    121         return height;
     120        depth++;
     121        return depth;
    122122      }
    123123    }
     
    183183
    184184    private void ResetCachedValues() {
    185       size = 0; height = 0;
     185      length = 0; depth = 0;
    186186      SymbolicExpressionTreeNode parentNode = parent as SymbolicExpressionTreeNode;
    187187      if (parentNode != null) parentNode.ResetCachedValues();
  • branches/DataAnalysis Refactoring/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Tests/AllArchitectureAlteringOperatorsTest.cs

    r5445 r5549  
    2525using HeuristicLab.Data;
    2626using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
    27 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.ArchitectureManipulators;
    28 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Creators;
    29 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Crossovers;
    3027using HeuristicLab.Random;
    3128using Microsoft.VisualStudio.TestTools.UnitTesting;
    3229
    33 namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding_3._3.Tests {
     30namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding_3._4.Tests {
    3431  [TestClass]
    3532  public class AllArchitectureAlteringOperatorsTest {
    3633    private const int POPULATION_SIZE = 1000;
    3734    private const int N_ITERATIONS = 20;
    38     private const int MAX_TREE_SIZE = 100;
    39     private const int MAX_TREE_HEIGHT = 10;
     35    private const int MAX_TREE_LENGTH = 100;
     36    private const int MAX_TREE_DEPTH = 10;
    4037    private TestContext testContextInstance;
    4138
     
    5552    [TestMethod()]
    5653    public void AllArchitectureAlteringOperatorsDistributionTest() {
    57       var trees = new List<SymbolicExpressionTree>();
    58       var newTrees = new List<SymbolicExpressionTree>();
     54      var trees = new List<ISymbolicExpressionTree>();
     55      var newTrees = new List<ISymbolicExpressionTree>();
    5956      var grammar = Grammars.CreateArithmeticAndAdfGrammar();
    6057      var random = new MersenneTwister(31415);
    61       IntValue maxTreeSize = new IntValue(MAX_TREE_SIZE);
    62       IntValue maxTreeHeigth = new IntValue(MAX_TREE_HEIGHT);
     58      IntValue maxTreeSize = new IntValue(MAX_TREE_LENGTH);
     59      IntValue maxTreeHeigth = new IntValue(MAX_TREE_DEPTH);
    6360      IntValue maxDefuns = new IntValue(3);
    6461      IntValue maxArgs = new IntValue(3);
    6562      for (int i = 0; i < POPULATION_SIZE; i++) {
    66         var tree = ProbabilisticTreeCreator.Create(random, grammar, MAX_TREE_SIZE, MAX_TREE_HEIGHT, 3, 3);
     63        var tree = ProbabilisticTreeCreator.Create(random, grammar, MAX_TREE_LENGTH, MAX_TREE_DEPTH, 3, 3);
    6764        Util.IsValid(tree);
    6865        trees.Add(tree);
     
    7067      Stopwatch stopwatch = new Stopwatch();
    7168      stopwatch.Start();
    72       var combinedAAOperator = new MultiSymbolicExpressionTreeArchitectureManipulator();
    7369      int failedEvents = 0;
    7470      for (int g = 0; g < N_ITERATIONS; g++) {
     
    7672          if (random.NextDouble() < 0.5) {
    7773            // manipulate
    78             var selectedTree = (SymbolicExpressionTree)trees.SelectRandom(random).Clone();
    79             var op = combinedAAOperator.Operators.SelectRandom(random);
     74            var selectedTree = (ISymbolicExpressionTree)trees.SelectRandom(random).Clone();
    8075            bool success = false;
    81             op.ModifyArchitecture(random, selectedTree, grammar, maxTreeSize, maxTreeHeigth, maxDefuns, maxArgs, out success);
    82             if (!success) failedEvents++; // architecture manipulation might fail
     76            switch (random.Next(6)) {
     77              case 0: success = ArgumentCreater.CreateNewArgument(random, selectedTree, MAX_TREE_LENGTH, MAX_TREE_DEPTH, 3, 3); break;
     78              case 1: success = ArgumentDeleter.DeleteArgument(random, selectedTree, 3, 3); break;
     79              case 2: success = ArgumentDuplicater.DuplicateArgument(random, selectedTree, 3, 3); break;
     80              case 3: success = SubroutineCreater.CreateSubroutine(random, selectedTree, MAX_TREE_LENGTH, MAX_TREE_DEPTH, 3, 3); break;
     81              case 4: success = SubroutineDuplicater.DuplicateSubroutine(random, selectedTree, 3, 3); break;
     82              case 5: success = SubroutineDeleter.DeleteSubroutine(random, selectedTree, 3, 3); break;
     83            }
     84            if (!success) failedEvents++;
    8385            Util.IsValid(selectedTree);
    8486            newTrees.Add(selectedTree);
     
    9092              par0 = (SymbolicExpressionTree)trees.SelectRandom(random).Clone();
    9193              par1 = (SymbolicExpressionTree)trees.SelectRandom(random).Clone();
    92             } while (par0.Size > MAX_TREE_SIZE || par1.Size > MAX_TREE_SIZE);
    93             bool success;
    94             newTrees.Add(SubtreeCrossover.Cross(random, par0, par1, 0.9, MAX_TREE_SIZE, MAX_TREE_HEIGHT, out success));
    95             Assert.IsTrue(success); // crossover must succeed
     94            } while (par0.Length > MAX_TREE_LENGTH || par1.Length > MAX_TREE_LENGTH);
     95            newTrees.Add(SubtreeCrossover.Cross(random, par0, par1, 0.9, MAX_TREE_LENGTH, MAX_TREE_DEPTH));
    9696          }
    9797        }
  • branches/DataAnalysis Refactoring/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Tests/ArgumentCreaterTest.cs

    r5445 r5549  
    2424using System.Collections.Generic;
    2525using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
    26 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.ArchitectureManipulators;
    27 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Creators;
    2826using HeuristicLab.Random;
    2927using Microsoft.VisualStudio.TestTools.UnitTesting;
    30 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Symbols;
    3128
    32 namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding_3._3.Tests {
     29namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding_3._4.Tests {
    3330  [TestClass]
    3431  public class ArgumentCreaterTest {
    3532    private const int POPULATION_SIZE = 1000;
    36     private const int MAX_TREE_SIZE = 100;
    37     private const int MAX_TREE_HEIGHT = 10;
     33    private const int MAX_TREE_LENGTH = 100;
     34    private const int MAX_TREE_DEPTH = 10;
    3835    private TestContext testContextInstance;
    3936
     
    5350    [TestMethod()]
    5451    public void ArgumentCreaterDistributionsTest() {
    55       var trees = new List<SymbolicExpressionTree>();
     52      var trees = new List<ISymbolicExpressionTree>();
    5653      var grammar = Grammars.CreateArithmeticAndAdfGrammar();
    5754      var random = new MersenneTwister(31415);
    5855      int failedOps = 0;
    5956      for (int i = 0; i < POPULATION_SIZE; i++) {
    60         SymbolicExpressionTree tree;
     57        ISymbolicExpressionTree tree;
    6158        do {
    62           tree = ProbabilisticTreeCreator.Create(random, grammar, MAX_TREE_SIZE, MAX_TREE_HEIGHT, 3, 3);
     59          tree = ProbabilisticTreeCreator.Create(random, grammar, MAX_TREE_LENGTH, MAX_TREE_DEPTH, 3, 3);
    6360        } while (!TreeHasAdfWithParameter(tree, 3));
    64         var success = ArgumentCreater.CreateNewArgument(random, tree, grammar, 60000, 100, 3, 3);
     61        var success = ArgumentCreater.CreateNewArgument(random, tree, 60000, 100, 3, 3);
    6562        if (!success) failedOps++;
    6663        Util.IsValid(tree);
     
    7976    }
    8077
    81     private bool TreeHasAdfWithParameter(SymbolicExpressionTree tree, int maxParameters) {
    82       return tree.Root.SubTrees.Count == 2 &&
    83       tree.Root.SubTrees[1].GetAllowedSymbols(0).Where(x => x is Argument).Count() < maxParameters;
     78    private bool TreeHasAdfWithParameter(ISymbolicExpressionTree tree, int maxParameters) {
     79      if(tree.Root.SubTrees.Count() != 2 ) return false;
     80      var firstAdf = tree.Root.GetSubTree(1);
     81      return firstAdf.Grammar.GetAllowedSymbols(firstAdf.Symbol, 0).Where(x => x is Argument).Count() < maxParameters;
    8482    }
    8583  }
  • branches/DataAnalysis Refactoring/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Tests/ArgumentDeleterTest.cs

    r5445 r5549  
    2424using System.Collections.Generic;
    2525using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
    26 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.ArchitectureManipulators;
    27 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Creators;
    2826using HeuristicLab.Random;
    2927using Microsoft.VisualStudio.TestTools.UnitTesting;
    30 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Symbols;
    3128
    32 namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding_3._3.Tests {
     29namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding_3._4.Tests {
    3330  [TestClass]
    3431  public class ArgumentDeleterTest {
    3532    private const int POPULATION_SIZE = 1000;
    36     private const int MAX_TREE_SIZE = 100;
    37     private const int MAX_TREE_HEIGHT = 10;
     33    private const int MAX_TREE_LENGTH = 100;
     34    private const int MAX_TREE_DEPTH = 10;
    3835    private TestContext testContextInstance;
    3936
     
    5350    [TestMethod()]
    5451    public void ArgumentDeleterDistributionsTest() {
    55       var trees = new List<SymbolicExpressionTree>();
     52      var trees = new List<ISymbolicExpressionTree>();
    5653      var grammar = Grammars.CreateArithmeticAndAdfGrammar();
    5754      var random = new MersenneTwister(31415);
    5855      for (int i = 0; i < POPULATION_SIZE; i++) {
    59         SymbolicExpressionTree tree = null;
     56        ISymbolicExpressionTree tree = null;
    6057        do {
    61           tree = ProbabilisticTreeCreator.Create(random, grammar, MAX_TREE_SIZE, MAX_TREE_HEIGHT, 3, 3);
     58          tree = ProbabilisticTreeCreator.Create(random, grammar, MAX_TREE_LENGTH, MAX_TREE_DEPTH, 3, 3);
    6259        } while (!TreeHasAdfWithArguments(tree));
    63         var success = ArgumentDeleter.DeleteArgument(random, tree, grammar, MAX_TREE_SIZE, MAX_TREE_HEIGHT, 3, 3);
     60        var success = ArgumentDeleter.DeleteArgument(random, tree, 3, 3);
    6461        Assert.IsTrue(success);
    6562        Util.IsValid(tree);
     
    7370        );
    7471    }
    75     private bool TreeHasAdfWithArguments(SymbolicExpressionTree tree) {
    76       return tree.Root.SubTrees.Count == 2 &&
    77         tree.Root.SubTrees[1].GetAllowedSymbols(0).Where(x => x is Argument).Count() >= 2;
     72    private bool TreeHasAdfWithArguments(ISymbolicExpressionTree tree) {
     73      if (tree.Root.SubTrees.Count() != 2) return false;
     74      var firstAdf = tree.Root.GetSubTree(1);
     75      return firstAdf.Grammar.GetAllowedSymbols(firstAdf.Symbol, 0).Where(x => x is Argument).Count() >= 2;
    7876    }
    7977  }
  • branches/DataAnalysis Refactoring/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Tests/ArgumentDuplicaterTest.cs

    r5445 r5549  
    2424using System.Collections.Generic;
    2525using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
    26 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.ArchitectureManipulators;
    27 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Creators;
    2826using HeuristicLab.Random;
    2927using Microsoft.VisualStudio.TestTools.UnitTesting;
    30 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Symbols;
    3128
    32 namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding_3._3.Tests {
     29namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding_3._4.Tests {
    3330  [TestClass]
    3431  public class ArgumentDuplicaterTest {
    3532    private const int POPULATION_SIZE = 1000;
    36     private const int MAX_TREE_SIZE = 100;
    37     private const int MAX_TREE_HEIGHT = 10;
     33    private const int MAX_TREE_LENGTH = 100;
     34    private const int MAX_TREE_DEPTH = 10;
    3835    private TestContext testContextInstance;
    3936
     
    5350    [TestMethod()]
    5451    public void ArgumentDuplicaterDistributionsTest() {
    55       var trees = new List<SymbolicExpressionTree>();
     52      var trees = new List<ISymbolicExpressionTree>();
    5653      var grammar = Grammars.CreateArithmeticAndAdfGrammar();
    5754      var random = new MersenneTwister(31415);
    5855      for (int i = 0; i < POPULATION_SIZE; i++) {
    59         SymbolicExpressionTree tree = null;
     56        ISymbolicExpressionTree tree = null;
    6057        do {
    61           tree = ProbabilisticTreeCreator.Create(random, grammar, MAX_TREE_SIZE, MAX_TREE_HEIGHT, 3, 3);
     58          tree = ProbabilisticTreeCreator.Create(random, grammar, MAX_TREE_LENGTH, MAX_TREE_DEPTH, 3, 3);
    6259        } while(!HasAdfWithArguments(tree));
    63         var success = ArgumentDuplicater.DuplicateArgument(random, tree, grammar, MAX_TREE_SIZE, MAX_TREE_HEIGHT, 3, 3);
     60        var success = ArgumentDuplicater.DuplicateArgument(random, tree, 3, 3);
    6461        Assert.IsTrue(success);
    6562        Util.IsValid(tree);
     
    7471    }
    7572
    76     private bool HasAdfWithArguments(SymbolicExpressionTree tree) {
    77       return tree.Root.SubTrees.Count == 2 &&
    78         tree.Root.SubTrees[1].GetAllowedSymbols(0).Where(x => x is Argument).Count() == 1;
     73    private bool HasAdfWithArguments(ISymbolicExpressionTree tree) {
     74      if (tree.Root.SubTrees.Count() != 2) return false;
     75      var firstAdf = tree.Root.GetSubTree(1);
     76      return firstAdf.Grammar.GetAllowedSymbols(firstAdf.Symbol, 0).Where(x => x is Argument).Count() == 1;
    7977    }
    8078  }
  • branches/DataAnalysis Refactoring/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Tests/ChangeNodeTypeManipulationTest.cs

    r5445 r5549  
    2323using System.Collections.Generic;
    2424using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
    25 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Creators;
    26 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Manipulators;
    2725using HeuristicLab.Random;
    2826using Microsoft.VisualStudio.TestTools.UnitTesting;
    2927
    30 namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding_3._3.Tests {
     28namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding_3._4.Tests {
    3129  [TestClass]
    3230  public class ChangeNodeTypeManipulationTest {
    3331    private const int POPULATION_SIZE = 1000;
    34     private const int MAX_TREE_SIZE = 100;
    35     private const int MAX_TREE_HEIGHT = 10;
     32    private const int MAX_TREE_LENGTH = 100;
     33    private const int MAX_TREE_DEPTH = 10;
    3634    private TestContext testContextInstance;
    3735
     
    5149    [TestMethod()]
    5250    public void ChangeNodeTypeManipulationDistributionsTest() {
    53       var trees = new List<SymbolicExpressionTree>();
     51      SymbolicExpressionTreeStringFormatter formatter = new SymbolicExpressionTreeStringFormatter();
     52      var trees = new List<ISymbolicExpressionTree>();
    5453      var grammar = Grammars.CreateArithmeticAndAdfGrammar();
    5554      var random = new MersenneTwister(31415);
    5655      for (int i = 0; i < POPULATION_SIZE; i++) {
    57         var tree = ProbabilisticTreeCreator.Create(random, grammar, MAX_TREE_SIZE, MAX_TREE_HEIGHT, 3, 3);
    58         bool success;
    59         ChangeNodeTypeManipulation.ChangeNodeType(random, tree, grammar, MAX_TREE_SIZE, MAX_TREE_HEIGHT, out success);
    60         Assert.IsTrue(success);
     56        var tree = ProbabilisticTreeCreator.Create(random, grammar, MAX_TREE_LENGTH, MAX_TREE_DEPTH, 3, 3);
     57        string originalTree = formatter.Format(tree);
     58        ChangeNodeTypeManipulation.ChangeNodeType(random, tree);
     59        string manipulatedTree = formatter.Format(tree);
     60        Assert.IsFalse(originalTree == manipulatedTree);
    6161        Util.IsValid(tree);
    6262        trees.Add(tree);
  • branches/DataAnalysis Refactoring/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Tests/Grammars.cs

    r5445 r5549  
    2323using HeuristicLab.Common;
    2424using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
    25 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Symbols;
    2625
    27 namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding_3._3.Tests {
     26namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding_3._4.Tests {
    2827  public static class Grammars {
    2928    private class Addition : Symbol {
     
    109108    }
    110109
    111     public static ISymbolicExpressionGrammar CreateSimpleArithmeticGrammar() {
     110    public static ISymbolicExpressionTreeGrammar CreateSimpleArithmeticGrammar() {
    112111      var g = new GlobalSymbolicExpressionGrammar(new SimpleArithmeticGrammar());
    113112      g.MaxFunctionArguments = 0;
     
    118117    }
    119118
    120     public static ISymbolicExpressionGrammar CreateArithmeticAndAdfGrammar() {
     119    public static ISymbolicExpressionTreeGrammar CreateArithmeticAndAdfGrammar() {
    121120      var g = new GlobalSymbolicExpressionGrammar(new SimpleArithmeticGrammar());
    122121      g.MaxFunctionArguments = 3;
  • branches/DataAnalysis Refactoring/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Tests/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding-3.4.Tests.csproj

    r5477 r5549  
    99    <OutputType>Library</OutputType>
    1010    <AppDesignerFolder>Properties</AppDesignerFolder>
    11     <RootNamespace>HeuristicLab.Encodings.SymbolicExpressionTreeEncoding_3._3.Tests</RootNamespace>
     11    <RootNamespace>HeuristicLab.Encodings.SymbolicExpressionTreeEncoding_3._4.Tests</RootNamespace>
    1212    <AssemblyName>HeuristicLab.Encodings.SymbolicExpressionTreeEncoding-3.4.Tests</AssemblyName>
    1313    <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
     
    153153      <Name>HeuristicLab.Random-3.3</Name>
    154154    </ProjectReference>
    155     <ProjectReference Include="..\..\3.3\HeuristicLab.Encodings.SymbolicExpressionTreeEncoding-3.3.csproj">
    156       <Project>{125D3006-67F5-48CB-913E-73C0548F17FA}</Project>
    157       <Name>HeuristicLab.Encodings.SymbolicExpressionTreeEncoding-3.3</Name>
     155    <ProjectReference Include="..\HeuristicLab.Encodings.SymbolicExpressionTreeEncoding-3.4.csproj">
     156      <Project>{06D4A186-9319-48A0-BADE-A2058D462EEA}</Project>
     157      <Name>HeuristicLab.Encodings.SymbolicExpressionTreeEncoding-3.4</Name>
    158158    </ProjectReference>
    159159  </ItemGroup>
  • branches/DataAnalysis Refactoring/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Tests/ProbabilisticTreeCreaterTest.cs

    r5445 r5549  
    2323using System.Collections.Generic;
    2424using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
    25 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Creators;
    2625using HeuristicLab.Random;
    2726using Microsoft.VisualStudio.TestTools.UnitTesting;
     27using System.Diagnostics;
    2828
    29 namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding_3._3.Tests {
     29namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding_3._4.Tests {
    3030  [TestClass]
    3131  public class ProbabilisticTreeCreaterTest {
    32     private const int POPULATION_SIZE = 1000;
    33     private const int MAX_TREE_SIZE = 100;
    34     private const int MAX_TREE_HEIGHT = 10;
     32    private const int POPULATION_SIZE = 10000;
     33    private const int MAX_TREE_LENGTH = 100;
     34    private const int MAX_TREE_DEPTH = 10;
    3535    private TestContext testContextInstance;
    3636
     
    5050    [TestMethod()]
    5151    public void ProbabilisticTreeCreaterDistributionsTest() {
    52       var randomTrees = new List<SymbolicExpressionTree>();
     52      var randomTrees = new List<ISymbolicExpressionTree>();
    5353      var grammar = Grammars.CreateSimpleArithmeticGrammar();
    5454      var random = new MersenneTwister(31415);
     55      var stopwatch = new Stopwatch();
     56      stopwatch.Start();
    5557      for (int i = 0; i < POPULATION_SIZE; i++) {
    56         randomTrees.Add(ProbabilisticTreeCreator.Create(random, grammar, MAX_TREE_SIZE, MAX_TREE_HEIGHT, 0, 0));
     58        randomTrees.Add(ProbabilisticTreeCreator.Create(random, grammar, MAX_TREE_LENGTH, MAX_TREE_DEPTH, 0, 0));
    5759      }
     60      stopwatch.Stop();
    5861
    5962      foreach (var tree in randomTrees) {
    6063        Util.IsValid(tree);
    6164      }
     65      double msPerRandomTreeCreation = stopwatch.ElapsedMilliseconds / (double)POPULATION_SIZE;
     66
    6267      Console.WriteLine("ProbabilisticTreeCreator: " + Environment.NewLine +
     68        msPerRandomTreeCreation + " ms per random tree (~" + Math.Round(1000.0 / (msPerRandomTreeCreation)) + "random trees / s)" + Environment.NewLine +
    6369        Util.GetSizeDistributionString(randomTrees, 105, 5) + Environment.NewLine +
    6470        Util.GetFunctionDistributionString(randomTrees) + Environment.NewLine +
     
    6672        Util.GetTerminalDistributionString(randomTrees) + Environment.NewLine
    6773        );
     74      Assert.IsTrue(Math.Round(1000.0 / (msPerRandomTreeCreation)) > 2000); // must achieve more than 2000 random trees / s
    6875    }
    6976
     
    7178    [TestMethod()]
    7279    public void ProbabilisticTreeCreaterWithAdfDistributionsTest() {
    73       var randomTrees = new List<SymbolicExpressionTree>();
     80      var randomTrees = new List<ISymbolicExpressionTree>();
    7481      var grammar = Grammars.CreateArithmeticAndAdfGrammar();
    7582      var random = new MersenneTwister(31415);
     83      var stopwatch = new Stopwatch();
     84      stopwatch.Start();
    7685      for (int i = 0; i < POPULATION_SIZE; i++) {
    77         var tree = ProbabilisticTreeCreator.Create(random, grammar, MAX_TREE_SIZE, MAX_TREE_HEIGHT, 3, 3);
    78         Util.IsValid(tree);
     86        var tree = ProbabilisticTreeCreator.Create(random, grammar, MAX_TREE_LENGTH, MAX_TREE_DEPTH, 3, 3);
    7987        randomTrees.Add(tree);
    8088      }
     89      stopwatch.Stop();
     90      foreach (var tree in randomTrees)
     91        Util.IsValid(tree);
     92
     93      double msPerRandomTreeCreation = stopwatch.ElapsedMilliseconds / (double)POPULATION_SIZE;
     94
    8195      Console.WriteLine("ProbabilisticTreeCreator: " + Environment.NewLine +
     96        msPerRandomTreeCreation + " ms per random tree (~" + Math.Round(1000.0 / (msPerRandomTreeCreation)) + "random trees / s)" + Environment.NewLine +
    8297        Util.GetSizeDistributionString(randomTrees, 105, 5) + Environment.NewLine +
    8398        Util.GetFunctionDistributionString(randomTrees) + Environment.NewLine +
     
    85100        Util.GetTerminalDistributionString(randomTrees) + Environment.NewLine
    86101        );
     102
     103      Assert.IsTrue(Math.Round(1000.0 / (msPerRandomTreeCreation)) > 2000); // must achieve more than 2000 random trees / s
    87104    }
    88105  }
  • branches/DataAnalysis Refactoring/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Tests/ReplaceBranchManipulationTest.cs

    r5445 r5549  
    2323using System.Collections.Generic;
    2424using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
    25 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Creators;
    26 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Manipulators;
    2725using HeuristicLab.Random;
    2826using Microsoft.VisualStudio.TestTools.UnitTesting;
    2927
    30 namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding_3._3.Tests {
     28namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding_3._4.Tests {
    3129  [TestClass]
    3230  public class ReplaceBranchManipulationTest {
    3331    private const int POPULATION_SIZE = 1000;
    34     private const int MAX_TREE_SIZE = 100;
    35     private const int MAX_TREE_HEIGHT = 10;
     32    private const int MAX_TREE_LENGTH = 100;
     33    private const int MAX_TREE_DEPTH = 10;
    3634    private TestContext testContextInstance;
    3735
     
    5149    [TestMethod()]
    5250    public void ReplaceBranchManipulationDistributionsTest() {
    53       var trees = new List<SymbolicExpressionTree>();
     51      SymbolicExpressionTreeStringFormatter formatter = new SymbolicExpressionTreeStringFormatter();
     52      var trees = new List<ISymbolicExpressionTree>();
    5453      var grammar = Grammars.CreateArithmeticAndAdfGrammar();
    5554      var random = new MersenneTwister(31415);
    5655      for (int i = 0; i < POPULATION_SIZE; i++) {
    57         var tree = ProbabilisticTreeCreator.Create(random, grammar, MAX_TREE_SIZE, MAX_TREE_HEIGHT, 3, 3);
    58         bool success;
    59         ReplaceBranchManipulation.ReplaceRandomBranch(random, tree, grammar, MAX_TREE_SIZE, MAX_TREE_HEIGHT, out success);
    60         Assert.IsTrue(success);
     56        var tree = ProbabilisticTreeCreator.Create(random, grammar, MAX_TREE_LENGTH, MAX_TREE_DEPTH, 3, 3);
     57        string originalTree = formatter.Format(tree);
     58        ReplaceBranchManipulation.ReplaceRandomBranch(random, tree, MAX_TREE_LENGTH, MAX_TREE_DEPTH);
     59        string manipulatedTree = formatter.Format(tree);
     60        Assert.IsFalse(originalTree == manipulatedTree);
    6161        Util.IsValid(tree);
    6262        trees.Add(tree);
  • branches/DataAnalysis Refactoring/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Tests/SubroutineCreaterTest.cs

    r5445 r5549  
    2121
    2222using System;
     23using System.Linq;
    2324using System.Collections.Generic;
    2425using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
    25 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.ArchitectureManipulators;
    26 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Creators;
    2726using HeuristicLab.Random;
    2827using Microsoft.VisualStudio.TestTools.UnitTesting;
    2928
    30 namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding_3._3.Tests {
     29namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding_3._4.Tests {
    3130  [TestClass]
    3231  public class SubroutineCreaterTest {
    3332    private const int POPULATION_SIZE = 1000;
    34     private const int MAX_TREE_SIZE = 100;
    35     private const int MAX_TREE_HEIGHT = 10;
     33    private const int MAX_TREE_LENGTH = 100;
     34    private const int MAX_TREE_DEPTH = 10;
    3635    private TestContext testContextInstance;
    3736
     
    5150    [TestMethod()]
    5251    public void SubroutineCreaterDistributionsTest() {
    53       var trees = new List<SymbolicExpressionTree>();
     52      var trees = new List<ISymbolicExpressionTree>();
    5453      var grammar = Grammars.CreateArithmeticAndAdfGrammar();
    5554      var random = new MersenneTwister(31415);
    5655      for (int i = 0; i < POPULATION_SIZE; i++) {
    57         SymbolicExpressionTree tree = null;
     56        ISymbolicExpressionTree tree = null;
    5857        do {
    59           tree = ProbabilisticTreeCreator.Create(random, grammar, MAX_TREE_SIZE, MAX_TREE_HEIGHT, 3, 3);
     58          tree = ProbabilisticTreeCreator.Create(random, grammar, MAX_TREE_LENGTH, MAX_TREE_DEPTH, 3, 3);
    6059        } while ( !OneMoreAdfAllowed(tree));
    61         var success = SubroutineCreater.CreateSubroutine(random, tree, grammar, MAX_TREE_SIZE, MAX_TREE_HEIGHT, 3, 3);
     60        var success = SubroutineCreater.CreateSubroutine(random, tree, MAX_TREE_LENGTH, MAX_TREE_DEPTH, 3, 3);
    6261        Assert.IsTrue(success);
    6362        Util.IsValid(tree);
     
    7271    }
    7372
    74     private bool OneMoreAdfAllowed(SymbolicExpressionTree tree) {
    75       return tree.Size < 80 && tree.Root.SubTrees.Count < 4;
     73    private bool OneMoreAdfAllowed(ISymbolicExpressionTree tree) {
     74      return tree.Length < 80 && tree.Root.SubTrees.Count() < 4;
    7675    }
    7776  }
  • branches/DataAnalysis Refactoring/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Tests/SubroutineDeleterTest.cs

    r5445 r5549  
    2121
    2222using System;
     23using System.Linq;
    2324using System.Collections.Generic;
    2425using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
    25 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.ArchitectureManipulators;
    26 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Creators;
    2726using HeuristicLab.Random;
    2827using Microsoft.VisualStudio.TestTools.UnitTesting;
    2928
    30 namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding_3._3.Tests {
     29namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding_3._4.Tests {
    3130  [TestClass]
    3231  public class SubroutineDeleterTest {
    3332    private const int POPULATION_SIZE = 1000;
    34     private const int MAX_TREE_SIZE = 100;
    35     private const int MAX_TREE_HEIGHT = 10;
     33    private const int MAX_TREE_LENGTH = 100;
     34    private const int MAX_TREE_DEPTH = 10;
    3635    private TestContext testContextInstance;
    3736
     
    5150    [TestMethod()]
    5251    public void SubroutineDeleterDistributionsTest() {
    53       var trees = new List<SymbolicExpressionTree>();
     52      var trees = new List<ISymbolicExpressionTree>();
    5453      var grammar = Grammars.CreateArithmeticAndAdfGrammar();
    5554      var random = new MersenneTwister(31415);
    5655      for (int i = 0; i < POPULATION_SIZE; i++) {
    57         SymbolicExpressionTree tree = null;
     56        ISymbolicExpressionTree tree = null;
    5857        do {
    59           tree = ProbabilisticTreeCreator.Create(random, grammar, MAX_TREE_SIZE, MAX_TREE_HEIGHT, 3, 3);
     58          tree = ProbabilisticTreeCreator.Create(random, grammar, MAX_TREE_LENGTH, MAX_TREE_DEPTH, 3, 3);
    6059        } while (!HasAtLeastOneAdf(tree));
    61         var success = SubroutineDeleter.DeleteSubroutine(random, tree, grammar, MAX_TREE_SIZE, MAX_TREE_HEIGHT, 3, 3);
     60        var success = SubroutineDeleter.DeleteSubroutine(random, tree, 3, 3);
    6261        Assert.IsTrue(success);
    6362        Util.IsValid(tree);
     
    7271    }
    7372
    74     private bool HasAtLeastOneAdf(SymbolicExpressionTree tree) {
    75       return tree.Root.SubTrees.Count > 1;
     73    private bool HasAtLeastOneAdf(ISymbolicExpressionTree tree) {
     74      return tree.Root.SubTrees.Count() > 1;
    7675    }
    7776  }
  • branches/DataAnalysis Refactoring/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Tests/SubroutineDuplicaterTest.cs

    r5445 r5549  
    2121
    2222using System;
     23using System.Linq;
    2324using System.Collections.Generic;
    2425using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
    25 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.ArchitectureManipulators;
    26 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Creators;
    2726using HeuristicLab.Random;
    2827using Microsoft.VisualStudio.TestTools.UnitTesting;
    2928
    30 namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding_3._3.Tests {
     29namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding_3._4.Tests {
    3130  [TestClass]
    3231  public class SubroutineDuplicaterTest {
    3332    private const int POPULATION_SIZE = 1000;
    34     private const int MAX_TREE_SIZE = 100;
    35     private const int MAX_TREE_HEIGHT = 10;
     33    private const int MAX_TREE_LENGTH = 100;
     34    private const int MAX_TREE_DEPTH = 10;
    3635    private TestContext testContextInstance;
    3736
     
    5150    [TestMethod()]
    5251    public void SubroutineDuplicaterDistributionsTest() {
    53       var trees = new List<SymbolicExpressionTree>();
     52      var trees = new List<ISymbolicExpressionTree>();
    5453      var grammar = Grammars.CreateArithmeticAndAdfGrammar();
    5554      var random = new MersenneTwister();
    5655      for (int i = 0; i < POPULATION_SIZE; i++) {
    57         SymbolicExpressionTree tree = null;
     56        ISymbolicExpressionTree tree = null;
    5857        do {
    59           tree = ProbabilisticTreeCreator.Create(random, grammar, MAX_TREE_SIZE, MAX_TREE_HEIGHT, 3, 3);
     58          tree = ProbabilisticTreeCreator.Create(random, grammar, MAX_TREE_LENGTH, MAX_TREE_DEPTH, 3, 3);
    6059        } while (!HasOneAdf(tree));
    61         var success = SubroutineDuplicater.DuplicateSubroutine(random, tree, grammar, MAX_TREE_SIZE, MAX_TREE_HEIGHT, 3, 3);
     60        var success = SubroutineDuplicater.DuplicateSubroutine(random, tree, 3, 3);
    6261        Assert.IsTrue(success);
    6362        Util.IsValid(tree);
     
    7271    }
    7372
    74     private bool HasOneAdf(SymbolicExpressionTree tree) {
    75       return tree.Root.SubTrees.Count == 2;
     73    private bool HasOneAdf(ISymbolicExpressionTree tree) {
     74      return tree.Root.SubTrees.Count() == 2;
    7675    }
    7776  }
  • branches/DataAnalysis Refactoring/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Tests/SubtreeCrossoverTest.cs

    r5445 r5549  
    2424using System.Diagnostics;
    2525using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
    26 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Creators;
    27 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Crossovers;
    2826using HeuristicLab.Random;
    2927using Microsoft.VisualStudio.TestTools.UnitTesting;
    3028
    31 namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding_3._3.Tests {
     29namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding_3._4.Tests {
    3230  [TestClass]
    3331  public class SubtreeCrossoverTest {
     
    5149    public void SubtreeCrossoverDistributionsTest() {
    5250      int generations = 5;
    53       var trees = new List<SymbolicExpressionTree>();
     51      var trees = new List<ISymbolicExpressionTree>();
    5452      var grammar = Grammars.CreateArithmeticAndAdfGrammar();
    5553      var random = new MersenneTwister(31415);
    56       List<SymbolicExpressionTree> crossoverTrees;
     54      List<ISymbolicExpressionTree> crossoverTrees;
    5755      double msPerCrossoverEvent;
    5856
     
    6361      stopwatch.Start();
    6462      for (int gCount = 0; gCount < generations; gCount++) {
    65         var newPopulation = new List<SymbolicExpressionTree>();
     63        var newPopulation = new List<ISymbolicExpressionTree>();
    6664        for (int i = 0; i < POPULATION_SIZE; i++) {
    6765          var par0 = (SymbolicExpressionTree)trees.SelectRandom(random).Clone();
    6866          var par1 = (SymbolicExpressionTree)trees.SelectRandom(random).Clone();
    69           bool success;
    70           newPopulation.Add(SubtreeCrossover.Cross(random, par0, par1, 0.9, 100, 10, out success));
    71           Assert.IsTrue(success);
     67          newPopulation.Add(SubtreeCrossover.Cross(random, par0, par1, 0.9, 100, 10));
    7268        }
    7369        crossoverTrees = newPopulation;
  • branches/DataAnalysis Refactoring/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Tests/Util.cs

    r5445 r5549  
    2525using System.Text;
    2626using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
    27 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Symbols;
    2827using Microsoft.VisualStudio.TestTools.UnitTesting;
    2928
    30 namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding_3._3.Tests {
     29namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding_3._4.Tests {
    3130  public static class Util {
    32     public static string GetSizeDistributionString(IList<SymbolicExpressionTree> trees, int maxTreeSize, int binSize) {
    33       int[] histogram = new int[maxTreeSize / binSize];
     31    public static string GetSizeDistributionString(IList<ISymbolicExpressionTree> trees, int maxTreeLength, int binSize) {
     32      int[] histogram = new int[maxTreeLength / binSize];
    3433      for (int i = 0; i < trees.Count; i++) {
    35         int binIndex = Math.Min(histogram.Length - 1, trees[i].Size / binSize);
     34        int binIndex = Math.Min(histogram.Length - 1, trees[i].Length / binSize);
    3635        histogram[binIndex]++;
    3736      }
     
    4948    }
    5049
    51     public static string GetFunctionDistributionString(IList<SymbolicExpressionTree> trees) {
     50    public static string GetFunctionDistributionString(IList<ISymbolicExpressionTree> trees) {
    5251      Dictionary<string, int> occurances = new Dictionary<string, int>();
    5352      double n = 0.0;
    5453      for (int i = 0; i < trees.Count; i++) {
    5554        foreach (var node in trees[i].IterateNodesPrefix()) {
    56           if (node.SubTrees.Count > 0) {
     55          if (node.SubTrees.Count() > 0) {
    5756            if (!occurances.ContainsKey(node.Symbol.Name))
    5857              occurances[node.Symbol.Name] = 0;
     
    7170    }
    7271
    73     public static string GetNumberOfSubTreesDistributionString(IList<SymbolicExpressionTree> trees) {
     72    public static string GetNumberOfSubTreesDistributionString(IList<ISymbolicExpressionTree> trees) {
    7473      Dictionary<int, int> occurances = new Dictionary<int, int>();
    7574      double n = 0.0;
    7675      for (int i = 0; i < trees.Count; i++) {
    7776        foreach (var node in trees[i].IterateNodesPrefix()) {
    78           if (!occurances.ContainsKey(node.SubTrees.Count))
    79             occurances[node.SubTrees.Count] = 0;
    80           occurances[node.SubTrees.Count]++;
     77          if (!occurances.ContainsKey(node.SubTrees.Count()))
     78            occurances[node.SubTrees.Count()] = 0;
     79          occurances[node.SubTrees.Count()]++;
    8180          n++;
    8281        }
     
    9291
    9392
    94     public static string GetTerminalDistributionString(IList<SymbolicExpressionTree> trees) {
     93    public static string GetTerminalDistributionString(IList<ISymbolicExpressionTree> trees) {
    9594      Dictionary<string, int> occurances = new Dictionary<string, int>();
    9695      double n = 0.0;
    9796      for (int i = 0; i < trees.Count; i++) {
    9897        foreach (var node in trees[i].IterateNodesPrefix()) {
    99           if (node.SubTrees.Count == 0) {
     98          if (node.SubTrees.Count() == 0) {
    10099            if (!occurances.ContainsKey(node.Symbol.Name))
    101100              occurances[node.Symbol.Name] = 0;
     
    114113    }
    115114
    116     public static void IsValid(SymbolicExpressionTree tree) {
    117       int reportedSize = tree.Size;
     115    public static void IsValid(ISymbolicExpressionTree tree) {
     116      int reportedSize = tree.Length;
    118117      int actualSize = tree.IterateNodesPostfix().Count();
    119118      Assert.AreEqual(actualSize, reportedSize);
     
    135134    }
    136135
    137     public static void IsValid(SymbolicExpressionTreeNode treeNode) {
     136    public static void IsValid(ISymbolicExpressionTreeNode treeNode) {
    138137      var matchingSymbol = (from symb in treeNode.Grammar.Symbols
    139138                            where symb.Name == treeNode.Symbol.Name
    140139                            select symb).SingleOrDefault();
    141       Assert.IsTrue(treeNode.SubTrees.Count >= treeNode.Grammar.GetMinSubtreeCount(matchingSymbol));
    142       Assert.IsTrue(treeNode.SubTrees.Count <= treeNode.Grammar.GetMaxSubtreeCount(matchingSymbol));
     140      Assert.IsTrue(treeNode.SubTrees.Count() >= treeNode.Grammar.GetMinSubtreeCount(matchingSymbol));
     141      Assert.IsTrue(treeNode.SubTrees.Count() <= treeNode.Grammar.GetMaxSubtreeCount(matchingSymbol));
    143142      Assert.AreNotEqual(0.0, matchingSymbol.InitialFrequency); // check that no deactivated symbols occur in the tree
    144       for (int i = 0; i < treeNode.SubTrees.Count; i++) {
    145         Assert.IsTrue(treeNode.GetAllowedSymbols(i).Select(x => x.Name).Contains(treeNode.SubTrees[i].Symbol.Name));
    146         IsValid(treeNode.SubTrees[i]);
     143      for (int i = 0; i < treeNode.SubTrees.Count(); i++) {
     144        Assert.IsTrue(treeNode.Grammar.GetAllowedSymbols(treeNode.Symbol, i).Select(x => x.Name).Contains(treeNode.GetSubTree(i).Symbol.Name));
     145        IsValid(treeNode.GetSubTree(i));
    147146      }
    148147    }
  • branches/DataAnalysis Refactoring/HeuristicLab.Problems.DataAnalysis.Symbolic.Classification/3.4/MultiObjective/SymbolicClassificationMultiObjectiveMeanSquaredErrorTreeSizeEvaluator.cs

    r5547 r5549  
    5656      IEnumerable<double> boundedEstimationValues = estimatedValues.LimitToRange(lowerEstimationLimit, upperEstimationLimit);
    5757      double mse = OnlineMeanSquaredErrorEvaluator.Calculate(originalValues, boundedEstimationValues);
    58       return new double[2] { mse, solution.Size };
     58      return new double[2] { mse, solution.Length };
    5959    }
    6060  }
  • branches/DataAnalysis Refactoring/HeuristicLab.Problems.DataAnalysis.Symbolic.Classification/3.4/MultiObjective/SymbolicClassificationMultiObjectivePearsonRSquaredTreeSizeEvaluator.cs

    r5547 r5549  
    3535      IEnumerable<double> boundedEstimationValues = estimatedValues.LimitToRange(lowerEstimationLimit, upperEstimationLimit);
    3636      double r2 = OnlinePearsonsRSquaredEvaluator.Calculate(originalValues, boundedEstimationValues);
    37       return new double[2] { r2, solution.Size };
     37      return new double[2] { r2, solution.Length };
    3838    }
    3939  }
  • branches/DataAnalysis Refactoring/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/MultiObjective/SymbolicRegressionMultiObjectiveMeanSquaredErrorTreeSizeEvaluator.cs

    r5548 r5549  
    5656      IEnumerable<double> boundedEstimationValues = estimatedValues.LimitToRange(lowerEstimationLimit, upperEstimationLimit);
    5757      double mse = OnlineMeanSquaredErrorEvaluator.Calculate(originalValues, boundedEstimationValues);
    58       return new double[2] { mse, solution.Size };
     58      return new double[2] { mse, solution.Length };
    5959    }
    6060  }
  • branches/DataAnalysis Refactoring/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/MultiObjective/SymbolicRegressionMultiObjectivePearsonRSquaredTreeSizeEvaluator.cs

    r5548 r5549  
    5656      IEnumerable<double> boundedEstimationValues = estimatedValues.LimitToRange(lowerEstimationLimit, upperEstimationLimit);
    5757      double r2 = OnlinePearsonsRSquaredEvaluator.Calculate(originalValues, boundedEstimationValues);
    58       return new double[2] { r2, solution.Size };
     58      return new double[2] { r2, solution.Length };
    5959    }
    6060  }
Note: See TracChangeset for help on using the changeset viewer.