Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
02/22/11 19:04:54 (14 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/ArgumentDeleterTest.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 ArgumentDeleterTest {
    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 ArgumentDeleterDistributionsTest() {
    55       var trees = new List<SymbolicExpressionTree>();
     52      var trees = new List<ISymbolicExpressionTree>();
    5653      var grammar = Grammars.CreateArithmeticAndAdfGrammar();
    5754      var random = new MersenneTwister(31415);
    5855      for (int i = 0; i < POPULATION_SIZE; i++) {
    59         SymbolicExpressionTree tree = null;
     56        ISymbolicExpressionTree tree = null;
    6057        do {
    61           tree = ProbabilisticTreeCreator.Create(random, grammar, MAX_TREE_SIZE, MAX_TREE_HEIGHT, 3, 3);
     58          tree = ProbabilisticTreeCreator.Create(random, grammar, MAX_TREE_LENGTH, MAX_TREE_DEPTH, 3, 3);
    6259        } while (!TreeHasAdfWithArguments(tree));
    63         var success = ArgumentDeleter.DeleteArgument(random, tree, grammar, MAX_TREE_SIZE, MAX_TREE_HEIGHT, 3, 3);
     60        var success = ArgumentDeleter.DeleteArgument(random, tree, 3, 3);
    6461        Assert.IsTrue(success);
    6562        Util.IsValid(tree);
     
    7370        );
    7471    }
    75     private bool TreeHasAdfWithArguments(SymbolicExpressionTree tree) {
    76       return tree.Root.SubTrees.Count == 2 &&
    77         tree.Root.SubTrees[1].GetAllowedSymbols(0).Where(x => x is Argument).Count() >= 2;
     72    private bool TreeHasAdfWithArguments(ISymbolicExpressionTree tree) {
     73      if (tree.Root.SubTrees.Count() != 2) return false;
     74      var firstAdf = tree.Root.GetSubTree(1);
     75      return firstAdf.Grammar.GetAllowedSymbols(firstAdf.Symbol, 0).Where(x => x is Argument).Count() >= 2;
    7876    }
    7977  }
Note: See TracChangeset for help on using the changeset viewer.