Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
11/04/11 14:57:32 (11 years ago)
Author:
bburlacu
Message:

#1654: Enhanced tree creator tests.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Tests/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding-3.4/FullTreeCreatorTest.cs

    r6944 r6949  
    5858      }
    5959      stopwatch.Stop();
    60 
     60      double msPerRandomTreeCreation = stopwatch.ElapsedMilliseconds / (double)POPULATION_SIZE;
     61      int count = 0;
     62      int depth = 0;
     63      int maxLength = 0;
    6164      foreach (var tree in randomTrees) {
    6265        Util.IsValid(tree);
    6366        Assert.IsTrue(tree.Depth == MAX_TREE_DEPTH);
     67        if (maxLength < tree.Length)
     68          maxLength = tree.Length;
     69        count += tree.Length;
     70        depth += tree.Depth;
    6471      }
    65       double msPerRandomTreeCreation = stopwatch.ElapsedMilliseconds / (double)POPULATION_SIZE;
    6672
    6773      Console.WriteLine("FullTreeCreator: " + Environment.NewLine +
    68         msPerRandomTreeCreation + " ms per random tree (~" + Math.Round(1000.0 / (msPerRandomTreeCreation)) + "random trees / s)" + Environment.NewLine +
    69         Util.GetSizeDistributionString(randomTrees, 105, 5) + Environment.NewLine +
     74        msPerRandomTreeCreation + " ms per random tree (~" +
     75        Math.Round(1000.0 / (msPerRandomTreeCreation)) + "random trees / s)" + Environment.NewLine +
     76        Util.GetSizeDistributionString(randomTrees, maxLength, 5) + Environment.NewLine +
    7077        Util.GetFunctionDistributionString(randomTrees) + Environment.NewLine +
    7178        Util.GetNumberOfSubtreesDistributionString(randomTrees) + Environment.NewLine +
    72         Util.GetTerminalDistributionString(randomTrees) + Environment.NewLine
     79        Util.GetTerminalDistributionString(randomTrees) + Environment.NewLine +
     80        "Average tree depth: " + depth / POPULATION_SIZE + Environment.NewLine +
     81        "Average tree length: " + count / POPULATION_SIZE + Environment.NewLine +
     82        "Maximum tree length: " + maxLength + Environment.NewLine +
     83        "Total nodes created: " + count + Environment.NewLine
    7384        );
    7485      Assert.IsTrue(Math.Round(1000.0 / (msPerRandomTreeCreation)) > 300); // must achieve more than 300 random trees / s
Note: See TracChangeset for help on using the changeset viewer.