Changeset 5367 for trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.3/Tests/ArgumentDuplicaterTest.cs
- Timestamp:
- 01/24/11 19:04:27 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.3/Tests/ArgumentDuplicaterTest.cs
r4068 r5367 21 21 22 22 using System; 23 using System.Linq; 23 24 using System.Collections.Generic; 24 25 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding; … … 27 28 using HeuristicLab.Random; 28 29 using Microsoft.VisualStudio.TestTools.UnitTesting; 30 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Symbols; 29 31 30 32 namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding_3._3.Tests { … … 53 55 var trees = new List<SymbolicExpressionTree>(); 54 56 var grammar = Grammars.CreateArithmeticAndAdfGrammar(); 55 var random = new MersenneTwister(); 56 int failedEvents = 0; 57 var random = new MersenneTwister(31415); 57 58 for (int i = 0; i < POPULATION_SIZE; i++) { 58 var tree = ProbabilisticTreeCreator.Create(random, grammar, MAX_TREE_SIZE, MAX_TREE_HEIGHT, 3, 3); 59 if (!ArgumentDuplicater.DuplicateArgument(random, tree, grammar, MAX_TREE_SIZE, MAX_TREE_HEIGHT, 3, 3)) 60 failedEvents++; 59 SymbolicExpressionTree tree = null; 60 do { 61 tree = ProbabilisticTreeCreator.Create(random, grammar, MAX_TREE_SIZE, MAX_TREE_HEIGHT, 3, 3); 62 } while(!HasAdfWithArguments(tree)); 63 var success = ArgumentDuplicater.DuplicateArgument(random, tree, grammar, MAX_TREE_SIZE, MAX_TREE_HEIGHT, 3, 3); 64 Assert.IsTrue(success); 61 65 Util.IsValid(tree); 62 66 trees.Add(tree); 63 67 } 64 Assert.Inconclusive("ArgumentDuplicater: " + Environment.NewLine + 65 "Failed events: " + failedEvents / (double)POPULATION_SIZE * 100 + " %" + Environment.NewLine + 68 Console.WriteLine("ArgumentDuplicater: " + Environment.NewLine + 66 69 Util.GetSizeDistributionString(trees, 200, 5) + Environment.NewLine + 67 70 Util.GetFunctionDistributionString(trees) + Environment.NewLine + … … 70 73 ); 71 74 } 75 76 private bool HasAdfWithArguments(SymbolicExpressionTree tree) { 77 return tree.Root.SubTrees.Count == 2 && 78 tree.Root.SubTrees[1].GetAllowedSymbols(0).Where(x => x is Argument).Count() == 1; 79 } 72 80 } 73 81 }
Note: See TracChangeset
for help on using the changeset viewer.