Changeset 7926


Ignore:
Timestamp:
05/29/12 16:08:52 (9 years ago)
Author:
mkommend
Message:

#1081: Added interpreter performance unit test for type coherent grammar.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Tests/HeuristicLab.Problems.DataAnalysis.Symbolic-3.4/SymbolicDataAnalysisExpressionTreeInterpreterTest.cs

    r7915 r7926  
    2525using System.Linq;
    2626using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
     27using HeuristicLab.Problems.DataAnalysis.Symbolic;
    2728using HeuristicLab.Random;
    2829using Microsoft.VisualStudio.TestTools.UnitTesting;
    29 using HeuristicLab.Problems.DataAnalysis.Symbolic;
    3030namespace HeuristicLab.Problems.DataAnalysis.Symbolic_34.Tests {
    3131
     
    5252
    5353    [TestMethod]
     54    public void SymbolicDataAnalysisExpressionTreeInterpreterTypeCoherentGrammarPerformanceTest() {
     55      TypeCoherentGrammarPerformanceTest(new SymbolicDataAnalysisExpressionTreeInterpreter(), 12.5e6);
     56    }
     57    [TestMethod]
    5458    public void SymbolicDataAnalysisExpressionTreeInterpreterFullGrammarPerformanceTest() {
    5559      FullGrammarPerformanceTest(new SymbolicDataAnalysisExpressionTreeInterpreter(), 12.5e6);
     
    6165
    6266    [TestMethod]
     67    public void SymbolicDataAnalysisExpressionTreeILEmittingInterpreterTypeCoherentGrammarPerformanceTest() {
     68      TypeCoherentGrammarPerformanceTest(new SymbolicDataAnalysisExpressionTreeILEmittingInterpreter(), 7.5e6);
     69    }
     70    [TestMethod]
    6371    public void SymbolicDataAnalysisExpressionTreeILEmittingInterpreterFullGrammarPerformanceTest() {
    6472      FullGrammarPerformanceTest(new SymbolicDataAnalysisExpressionTreeILEmittingInterpreter(), 7.5e6);
     
    6775    public void SymbolicDataAnalysisExpressionTreeILEmittingInterpreterArithmeticGrammarPerformanceTest() {
    6876      ArithmeticGrammarPerformanceTest(new SymbolicDataAnalysisExpressionTreeILEmittingInterpreter(), 7.5e6);
     77    }
     78
     79    private void TypeCoherentGrammarPerformanceTest(ISymbolicDataAnalysisExpressionTreeInterpreter interpreter, double nodesPerSecThreshold) {
     80      var twister = new MersenneTwister(31415);
     81      var dataset = Util.CreateRandomDataset(twister, Rows, Columns);
     82      var grammar = new TypeCoherentExpressionGrammar();
     83      grammar.ConfigureAsDefaultRegressionGrammar();
     84      grammar.MaximumFunctionArguments = 0;
     85      grammar.MaximumFunctionDefinitions = 0;
     86      grammar.MinimumFunctionArguments = 0;
     87      grammar.MinimumFunctionDefinitions = 0;
     88      var randomTrees = Util.CreateRandomTrees(twister, dataset, grammar, N, 1, 100, 0, 0);
     89      foreach (ISymbolicExpressionTree tree in randomTrees) {
     90        Util.InitTree(tree, twister, new List<string>(dataset.VariableNames));
     91      }
     92      double nodesPerSec = Util.CalculateEvaluatedNodesPerSec(randomTrees, interpreter, dataset, 3);
     93      Assert.IsTrue(nodesPerSec > nodesPerSecThreshold); // evaluated nodes per seconds must be larger than 15mNodes/sec
    6994    }
    7095
Note: See TracChangeset for help on using the changeset viewer.