Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
02/22/11 19:04:54 (13 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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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  }
Note: See TracChangeset for help on using the changeset viewer.