Changeset 5686 for branches/DataAnalysis Refactoring/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Tests/ArgumentCreaterTest.cs
- Timestamp:
- 03/15/11 13:34:38 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/DataAnalysis Refactoring/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Tests/ArgumentCreaterTest.cs
r5549 r5686 21 21 22 22 using System; 23 using System.Collections.Generic; 23 24 using System.Linq; 24 using System.Collections.Generic;25 25 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding; 26 26 using HeuristicLab.Random; … … 57 57 ISymbolicExpressionTree tree; 58 58 do { 59 tree = ProbabilisticTreeCreator.Create(random, grammar, MAX_TREE_LENGTH, MAX_TREE_DEPTH, 3, 3); 59 tree = ProbabilisticTreeCreator.Create(random, grammar, MAX_TREE_LENGTH, MAX_TREE_DEPTH); 60 SubroutineCreater.CreateSubroutine(random, tree, MAX_TREE_LENGTH, MAX_TREE_DEPTH, 3, 3); 60 61 } while (!TreeHasAdfWithParameter(tree, 3)); 61 62 var success = ArgumentCreater.CreateNewArgument(random, tree, 60000, 100, 3, 3); … … 66 67 // difficult to make sure that create argument operations succeed because trees are macro-expanded can potentially become very big 67 68 // => just test if only a small proportion fails 68 Assert.IsTrue(failedOps < POPULATION_SIZE * 0.01 69 Assert.IsTrue(failedOps < POPULATION_SIZE * 0.01); // only 1% may fail 69 70 Console.WriteLine("ArgumentCreator: " + Environment.NewLine + 70 71 "Failed operations: " + failedOps * 100.0 / POPULATION_SIZE + " %" + Environment.NewLine + … … 77 78 78 79 private bool TreeHasAdfWithParameter(ISymbolicExpressionTree tree, int maxParameters) { 79 if (tree.Root.SubTrees.Count() != 2) return false;80 if (tree.Root.SubTrees.Count() != 2) return false; 80 81 var firstAdf = tree.Root.GetSubTree(1); 81 return firstAdf.Grammar.GetAllowed Symbols(firstAdf.Symbol, 0).Where(x => x is Argument).Count() < maxParameters;82 return firstAdf.Grammar.GetAllowedChildSymbols(firstAdf.Symbol, 0).Where(x => x is Argument).Count() < maxParameters; 82 83 } 83 84 }
Note: See TracChangeset
for help on using the changeset viewer.