Free cookie consent management tool by TermsFeed Policy Generator

source: branches/HeuristicLab.EvolutionTracking/HeuristicLab.EvolutionTracking.Tests/QueryMatchPerformanceTest.cs @ 12951

Last change on this file since 12951 was 12951, checked in by bburlacu, 9 years ago

#1772:

  • Slight refactor in QueryMatch.cs
  • Added a parameter to the genealogy analyzer for removing older generations from the graph (useful to conserve memory in experiments)
  • Updated wildcard nodes (added persistence & cloning)
  • Implemented diversification strategy based on schema frequencies & phenotypic similarity as a separate operator (for now keep also the analyzer)
  • Updated license headers
  • Added QueryMatch performance test (to be expanded)
File size: 1.2 KB
Line 
1using System;
2using System.Linq;
3using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
4using HeuristicLab.Problems.DataAnalysis.Symbolic;
5using HeuristicLab.Random;
6using Microsoft.VisualStudio.TestTools.UnitTesting;
7
8namespace HeuristicLab.EvolutionTracking.Tests {
9  [TestClass]
10  public class QueryMatchPerformanceTest {
11    private const int MaxDepth = 12;
12    private const int MaxLength = 50;
13    private const int N = 100000;
14
15
16    [TestMethod]
17    public void TestQueryMatchPerformance() {
18      var grammar = new TypeCoherentExpressionGrammar();
19      grammar.ConfigureAsDefaultRegressionGrammar();
20      var creator = new ProbabilisticTreeCreator();
21      var random = new MersenneTwister();
22
23      var trees = Enumerable.Range(0, N).Select(x => creator.CreateTree(random, grammar, MaxLength, MaxDepth)).ToList();
24      var comparer = new SymbolicExpressionTreeNodeEqualityComparer {
25        MatchConstantValues = false,
26        MatchVariableWeights = false,
27        MatchVariableNames = true
28      };
29      var qm = new QueryMatch(comparer) { MatchParents = true };
30
31      int count = trees.Skip(1).Count(x => qm.Match(x, trees[0]));
32
33      Console.WriteLine("Count: " + count);
34    }
35  }
36}
Note: See TracBrowser for help on using the repository browser.