Changeset 5549 for branches/DataAnalysis Refactoring/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Tests/ArgumentDeleterTest.cs
- Timestamp:
- 02/22/11 19:04:54 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/DataAnalysis Refactoring/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Tests/ArgumentDeleterTest.cs
r5445 r5549 24 24 using System.Collections.Generic; 25 25 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding; 26 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.ArchitectureManipulators;27 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Creators;28 26 using HeuristicLab.Random; 29 27 using Microsoft.VisualStudio.TestTools.UnitTesting; 30 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Symbols;31 28 32 namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding_3._ 3.Tests {29 namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding_3._4.Tests { 33 30 [TestClass] 34 31 public class ArgumentDeleterTest { 35 32 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; 38 35 private TestContext testContextInstance; 39 36 … … 53 50 [TestMethod()] 54 51 public void ArgumentDeleterDistributionsTest() { 55 var trees = new List< SymbolicExpressionTree>();52 var trees = new List<ISymbolicExpressionTree>(); 56 53 var grammar = Grammars.CreateArithmeticAndAdfGrammar(); 57 54 var random = new MersenneTwister(31415); 58 55 for (int i = 0; i < POPULATION_SIZE; i++) { 59 SymbolicExpressionTree tree = null;56 ISymbolicExpressionTree tree = null; 60 57 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); 62 59 } 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); 64 61 Assert.IsTrue(success); 65 62 Util.IsValid(tree); … … 73 70 ); 74 71 } 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; 78 76 } 79 77 }
Note: See TracChangeset
for help on using the changeset viewer.