Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
03/15/11 13:34:38 (13 years ago)
Author:
mkommend
Message:

#1418: Finally added results from the grammar refactoring.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/DataAnalysis Refactoring/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Tests/ProbabilisticTreeCreaterTest.cs

    r5549 r5686  
    2222using System;
    2323using System.Collections.Generic;
     24using System.Diagnostics;
    2425using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
    2526using HeuristicLab.Random;
    2627using Microsoft.VisualStudio.TestTools.UnitTesting;
    27 using System.Diagnostics;
    2828
    2929namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding_3._4.Tests {
     
    5656      stopwatch.Start();
    5757      for (int i = 0; i < POPULATION_SIZE; i++) {
    58         randomTrees.Add(ProbabilisticTreeCreator.Create(random, grammar, MAX_TREE_LENGTH, MAX_TREE_DEPTH, 0, 0));
     58        randomTrees.Add(ProbabilisticTreeCreator.Create(random, grammar, MAX_TREE_LENGTH, MAX_TREE_DEPTH));
    5959      }
    6060      stopwatch.Stop();
     
    7272        Util.GetTerminalDistributionString(randomTrees) + Environment.NewLine
    7373        );
    74       Assert.IsTrue(Math.Round(1000.0 / (msPerRandomTreeCreation)) > 2000); // must achieve more than 2000 random trees / s
    75     }
    76 
    77 
    78     [TestMethod()]
    79     public void ProbabilisticTreeCreaterWithAdfDistributionsTest() {
    80       var randomTrees = new List<ISymbolicExpressionTree>();
    81       var grammar = Grammars.CreateArithmeticAndAdfGrammar();
    82       var random = new MersenneTwister(31415);
    83       var stopwatch = new Stopwatch();
    84       stopwatch.Start();
    85       for (int i = 0; i < POPULATION_SIZE; i++) {
    86         var tree = ProbabilisticTreeCreator.Create(random, grammar, MAX_TREE_LENGTH, MAX_TREE_DEPTH, 3, 3);
    87         randomTrees.Add(tree);
    88       }
    89       stopwatch.Stop();
    90       foreach (var tree in randomTrees)
    91         Util.IsValid(tree);
    92 
    93       double msPerRandomTreeCreation = stopwatch.ElapsedMilliseconds / (double)POPULATION_SIZE;
    94 
    95       Console.WriteLine("ProbabilisticTreeCreator: " + Environment.NewLine +
    96         msPerRandomTreeCreation + " ms per random tree (~" + Math.Round(1000.0 / (msPerRandomTreeCreation)) + "random trees / s)" + Environment.NewLine +
    97         Util.GetSizeDistributionString(randomTrees, 105, 5) + Environment.NewLine +
    98         Util.GetFunctionDistributionString(randomTrees) + Environment.NewLine +
    99         Util.GetNumberOfSubTreesDistributionString(randomTrees) + Environment.NewLine +
    100         Util.GetTerminalDistributionString(randomTrees) + Environment.NewLine
    101         );
    102 
    103       Assert.IsTrue(Math.Round(1000.0 / (msPerRandomTreeCreation)) > 2000); // must achieve more than 2000 random trees / s
     74      Assert.IsTrue(Math.Round(1000.0 / (msPerRandomTreeCreation)) > 500); // must achieve more than 500 random trees / s
    10475    }
    10576  }
Note: See TracChangeset for help on using the changeset viewer.