- Timestamp:
- 01/24/11 19:04:27 (14 years ago)
- Location:
- trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.3
- Files:
-
- 15 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.3/ArchitectureManipulators/ArgumentCreater.cs
r4722 r5367 84 84 // this operation potentially creates very big trees so the access to the size property might throw overflow exception 85 85 try { 86 if (CreateNewArgumentForDefun(random, clonedTree, selectedDefunBranch, newArgumentNode) && clonedTree.Size < maxTreeSize && clonedTree.Height <maxTreeHeight) {86 if (CreateNewArgumentForDefun(random, clonedTree, selectedDefunBranch, newArgumentNode) && clonedTree.Size <= maxTreeSize && clonedTree.Height <= maxTreeHeight) { 87 87 88 88 // size constraints are fulfilled -
trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.3/Crossovers/SubtreeCrossover.cs
r5014 r5367 74 74 List<SymbolicExpressionTreeNode> allowedBranches = new List<SymbolicExpressionTreeNode>(); 75 75 parent1.Root.ForEachNodePostfix((n) => { 76 if (n.GetSize() < maxInsertedBranchSize &&77 n.GetHeight() < maxInsertedBranchHeight &&76 if (n.GetSize() <= maxInsertedBranchSize && 77 n.GetHeight() <= maxInsertedBranchHeight && 78 78 IsMatchingPointType(crossoverPoint0, replacedSubtreeIndex, n)) 79 79 allowedBranches.Add(n); … … 117 117 List<CrossoverPoint> leafCrossoverPoints = new List<CrossoverPoint>(); 118 118 parent0.Root.ForEachNodePostfix((n) => { 119 if (n.SubTrees.Count > 0 && 120 n.GetSize() < maxBranchSize && 121 n.GetHeight() < maxBranchHeight && 122 n != parent0.Root 123 ) { 119 if (n.SubTrees.Count > 0 && n != parent0.Root) { 124 120 foreach (var child in n.SubTrees) { 125 if (child.SubTrees.Count > 0) 126 internalCrossoverPoints.Add(new CrossoverPoint(n, child)); 127 else 128 leafCrossoverPoints.Add(new CrossoverPoint(n, child)); 121 if (child.GetSize() <= maxBranchSize && 122 child.GetHeight() <= maxBranchHeight) { 123 if (child.SubTrees.Count > 0) 124 internalCrossoverPoints.Add(new CrossoverPoint(n, child)); 125 else 126 leafCrossoverPoints.Add(new CrossoverPoint(n, child)); 127 } 129 128 } 130 129 } 131 130 }); 131 132 132 if (random.NextDouble() < internalNodeProbability) { 133 133 // select from internal node if possible -
trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.3/Manipulators/ChangeNodeTypeManipulation.cs
r4722 r5367 59 59 select symbol; 60 60 61 if (allowedSymbols.Count() <= 1) {61 if (allowedSymbols.Count() == 0) { 62 62 success = false; 63 63 return; … … 72 72 where disallowedSubtrees.Count() == 0 73 73 select symbol; 74 if (constrainedSymbols.Count() <= 1) {74 if (constrainedSymbols.Count() == 0) { 75 75 success = false; 76 76 return; -
trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.3/Manipulators/ReplaceBranchManipulation.cs
r5015 r5367 61 61 where manipulationPoint.Node.Grammar.GetMinExpressionLength(symbol) <= maxSize 62 62 select symbol; 63 if (allowedSymbols.Count() <= 1) return;63 if (allowedSymbols.Count() == 0) return; 64 64 65 65 var seedSymbol = SelectRandomSymbol(random, allowedSymbols); // replace the old node with the new node -
trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.3/Tests/AllArchitectureAlteringOperatorsTest.cs
r4068 r5367 59 59 var grammar = Grammars.CreateArithmeticAndAdfGrammar(); 60 60 var random = new MersenneTwister(31415); 61 int failedEvents = 0; 62 IntValue maxTreeSize = new IntValue(100); 63 IntValue maxTreeHeigth = new IntValue(10); 61 IntValue maxTreeSize = new IntValue(MAX_TREE_SIZE); 62 IntValue maxTreeHeigth = new IntValue(MAX_TREE_HEIGHT); 64 63 IntValue maxDefuns = new IntValue(3); 65 64 IntValue maxArgs = new IntValue(3); … … 72 71 stopwatch.Start(); 73 72 var combinedAAOperator = new MultiSymbolicExpressionTreeArchitectureManipulator(); 73 int failedEvents = 0; 74 74 for (int g = 0; g < N_ITERATIONS; g++) { 75 75 for (int i = 0; i < POPULATION_SIZE; i++) { … … 85 85 } else { 86 86 // crossover 87 var par0 = (SymbolicExpressionTree)trees.SelectRandom(random).Clone(); 88 var par1 = (SymbolicExpressionTree)trees.SelectRandom(random).Clone(); 87 SymbolicExpressionTree par0 = null; 88 SymbolicExpressionTree par1 = null; 89 do { 90 par0 = (SymbolicExpressionTree)trees.SelectRandom(random).Clone(); 91 par1 = (SymbolicExpressionTree)trees.SelectRandom(random).Clone(); 92 } while (par0.Size > MAX_TREE_SIZE || par1.Size > MAX_TREE_SIZE); 89 93 bool success; 90 newTrees.Add(SubtreeCrossover.Cross(random, par0, par1, 0.9, 100, 10, out success));91 if (!success) failedEvents++;94 newTrees.Add(SubtreeCrossover.Cross(random, par0, par1, 0.9, MAX_TREE_SIZE, MAX_TREE_HEIGHT, out success)); 95 Assert.IsTrue(success); 92 96 } 93 97 } … … 96 100 stopwatch.Stop(); 97 101 var msPerOperation = stopwatch.ElapsedMilliseconds / (double)POPULATION_SIZE / (double)N_ITERATIONS; 98 Assert.Inconclusive("AllArchitectureAlteringOperators: " + Environment.NewLine + 99 "Failed events: " + failedEvents / (double)POPULATION_SIZE / N_ITERATIONS * 100 + " %" + Environment.NewLine + 102 Console.WriteLine("AllArchitectureAlteringOperators: " + Environment.NewLine + 100 103 "Operations / s: ~" + Math.Round(1000.0 / (msPerOperation)) + "operations / s)" + Environment.NewLine + 104 "Failed events: " + failedEvents / (double)(POPULATION_SIZE * N_ITERATIONS) + "%" + Environment.NewLine + 101 105 Util.GetSizeDistributionString(trees, 200, 5) + Environment.NewLine + 102 106 Util.GetFunctionDistributionString(trees) + Environment.NewLine + -
trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.3/Tests/ArgumentCreaterTest.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 { … … 54 56 var grammar = Grammars.CreateArithmeticAndAdfGrammar(); 55 57 var random = new MersenneTwister(31415); 56 int failedEvents = 0;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 (!ArgumentCreater.CreateNewArgument(random, tree, grammar, MAX_TREE_SIZE, MAX_TREE_HEIGHT, 3, 3)) 60 failedEvents++; 59 SymbolicExpressionTree tree; 60 do { 61 tree = ProbabilisticTreeCreator.Create(random, grammar, MAX_TREE_SIZE, MAX_TREE_HEIGHT, 3, 3); 62 } while (!TreeHasAdfWithParameter(tree, 3)); 63 var success = ArgumentCreater.CreateNewArgument(random, tree, grammar, 10000, 100, 3, 3); 64 Assert.IsTrue(success); 61 65 Util.IsValid(tree); 62 66 trees.Add(tree); 63 67 } 64 Assert.Inconclusive("ArgumentCreator: " + Environment.NewLine + 65 "Failed events: " + failedEvents / (double)POPULATION_SIZE * 100 + " %" + Environment.NewLine + 68 Console.WriteLine("ArgumentCreator: " + Environment.NewLine + 66 69 Util.GetSizeDistributionString(trees, 200, 20) + Environment.NewLine + 67 70 Util.GetFunctionDistributionString(trees) + Environment.NewLine + … … 70 73 ); 71 74 } 75 76 private bool TreeHasAdfWithParameter(SymbolicExpressionTree tree, int maxParameters) { 77 return tree.Root.SubTrees.Count == 2 && 78 tree.Root.SubTrees[1].GetAllowedSymbols(0).Where(x => x is Argument).Count() < maxParameters; 79 } 72 80 } 73 81 } -
trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.3/Tests/ArgumentDeleterTest.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 { … … 54 56 var grammar = Grammars.CreateArithmeticAndAdfGrammar(); 55 57 var random = new MersenneTwister(31415); 56 int failedEvents = 0;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 (!ArgumentDeleter.DeleteArgument(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 (!TreeHasAdfWithArguments(tree)); 63 var success = ArgumentDeleter.DeleteArgument(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("ArgumentDeleter: " + Environment.NewLine + 65 "Failed events: " + failedEvents / (double)POPULATION_SIZE * 100 + " %" + Environment.NewLine + 68 Console.WriteLine("ArgumentDeleter: " + Environment.NewLine + 66 69 Util.GetSizeDistributionString(trees, 105, 5) + Environment.NewLine + 67 70 Util.GetFunctionDistributionString(trees) + Environment.NewLine + … … 70 73 ); 71 74 } 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; 78 } 72 79 } 73 80 } -
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 } -
trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.3/Tests/ChangeNodeTypeManipulationTest.cs
r4722 r5367 53 53 var trees = new List<SymbolicExpressionTree>(); 54 54 var grammar = Grammars.CreateArithmeticAndAdfGrammar(); 55 var random = new MersenneTwister(); 56 int failedEvents = 0; 55 var random = new MersenneTwister(31415); 57 56 for (int i = 0; i < POPULATION_SIZE; i++) { 58 57 var tree = ProbabilisticTreeCreator.Create(random, grammar, MAX_TREE_SIZE, MAX_TREE_HEIGHT, 3, 3); 59 58 bool success; 60 59 ChangeNodeTypeManipulation.ChangeNodeType(random, tree, grammar, MAX_TREE_SIZE, MAX_TREE_HEIGHT, out success); 61 if (!success) 62 failedEvents++; 60 Assert.IsTrue(success); 63 61 Util.IsValid(tree); 64 62 trees.Add(tree); 65 63 } 66 Assert.Inconclusive("ChangeNodeTypeManipulation: " + Environment.NewLine + 67 "Failed events: " + failedEvents / (double)POPULATION_SIZE * 100 + " %" + Environment.NewLine + 64 Console.WriteLine("ChangeNodeTypeManipulation: " + Environment.NewLine + 68 65 Util.GetSizeDistributionString(trees, 105, 5) + Environment.NewLine + 69 66 Util.GetFunctionDistributionString(trees) + Environment.NewLine + -
trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.3/Tests/ProbabilisticTreeCreaterTest.cs
r4106 r5367 60 60 Util.IsValid(tree); 61 61 } 62 Assert.Inconclusive("ProbabilisticTreeCreator: " + Environment.NewLine +62 Console.WriteLine("ProbabilisticTreeCreator: " + Environment.NewLine + 63 63 Util.GetSizeDistributionString(randomTrees, 105, 5) + Environment.NewLine + 64 64 Util.GetFunctionDistributionString(randomTrees) + Environment.NewLine + … … 79 79 randomTrees.Add(tree); 80 80 } 81 Assert.Inconclusive("ProbabilisticTreeCreator: " + Environment.NewLine +81 Console.WriteLine("ProbabilisticTreeCreator: " + Environment.NewLine + 82 82 Util.GetSizeDistributionString(randomTrees, 105, 5) + Environment.NewLine + 83 83 Util.GetFunctionDistributionString(randomTrees) + Environment.NewLine + -
trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.3/Tests/ReplaceBranchManipulationTest.cs
r4722 r5367 54 54 var grammar = Grammars.CreateArithmeticAndAdfGrammar(); 55 55 var random = new MersenneTwister(31415); 56 int failedEvents = 0;57 56 for (int i = 0; i < POPULATION_SIZE; i++) { 58 57 var tree = ProbabilisticTreeCreator.Create(random, grammar, MAX_TREE_SIZE, MAX_TREE_HEIGHT, 3, 3); 59 58 bool success; 60 59 ReplaceBranchManipulation.ReplaceRandomBranch(random, tree, grammar, MAX_TREE_SIZE, MAX_TREE_HEIGHT, out success); 61 if (!success) { 62 failedEvents++; 63 } else { 64 Util.IsValid(tree); 65 trees.Add(tree); 66 } 60 Assert.IsTrue(success); 61 Util.IsValid(tree); 62 trees.Add(tree); 67 63 } 68 Assert.Inconclusive("ReplaceBranchManipulation: " + Environment.NewLine + 69 "Failed events: " + failedEvents / (double)POPULATION_SIZE * 100 + " %" + Environment.NewLine + 64 Console.WriteLine("ReplaceBranchManipulation: " + Environment.NewLine + 70 65 Util.GetSizeDistributionString(trees, 105, 5) + Environment.NewLine + 71 66 Util.GetFunctionDistributionString(trees) + Environment.NewLine + -
trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.3/Tests/SubroutineCreaterTest.cs
r4068 r5367 54 54 var grammar = Grammars.CreateArithmeticAndAdfGrammar(); 55 55 var random = new MersenneTwister(31415); 56 int failedEvents = 0;57 56 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 (!SubroutineCreater.CreateSubroutine(random, tree, grammar, MAX_TREE_SIZE, MAX_TREE_HEIGHT, 3, 3)) 60 failedEvents++; 57 SymbolicExpressionTree tree = null; 58 do { 59 tree = ProbabilisticTreeCreator.Create(random, grammar, MAX_TREE_SIZE, MAX_TREE_HEIGHT, 3, 3); 60 } while ( !OneMoreAdfAllowed(tree)); 61 var success = SubroutineCreater.CreateSubroutine(random, tree, grammar, MAX_TREE_SIZE, MAX_TREE_HEIGHT, 3, 3); 62 Assert.IsTrue(success); 61 63 Util.IsValid(tree); 62 64 trees.Add(tree); 63 65 } 64 Assert.Inconclusive("SubroutineCreator: " + Environment.NewLine + 65 "Failed events: " + failedEvents / (double)POPULATION_SIZE * 100 + " %" + Environment.NewLine + 66 Console.WriteLine("SubroutineCreator: " + Environment.NewLine + 66 67 Util.GetSizeDistributionString(trees, 105, 5) + Environment.NewLine + 67 68 Util.GetFunctionDistributionString(trees) + Environment.NewLine + … … 70 71 ); 71 72 } 73 74 private bool OneMoreAdfAllowed(SymbolicExpressionTree tree) { 75 return tree.Size < 80 && tree.Root.SubTrees.Count < 4; 76 } 72 77 } 73 78 } -
trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.3/Tests/SubroutineDeleterTest.cs
r4068 r5367 54 54 var grammar = Grammars.CreateArithmeticAndAdfGrammar(); 55 55 var random = new MersenneTwister(31415); 56 int failedEvents = 0;57 56 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 (!SubroutineDeleter.DeleteSubroutine(random, tree, grammar, MAX_TREE_SIZE, MAX_TREE_HEIGHT, 3, 3)) 60 failedEvents++; 57 SymbolicExpressionTree tree = null; 58 do { 59 tree = ProbabilisticTreeCreator.Create(random, grammar, MAX_TREE_SIZE, MAX_TREE_HEIGHT, 3, 3); 60 } while (!HasAtLeastOneAdf(tree)); 61 var success = SubroutineDeleter.DeleteSubroutine(random, tree, grammar, MAX_TREE_SIZE, MAX_TREE_HEIGHT, 3, 3); 62 Assert.IsTrue(success); 61 63 Util.IsValid(tree); 62 64 trees.Add(tree); 63 65 } 64 Assert.Inconclusive("SubroutineDeleter: " + Environment.NewLine + 65 "Failed events: " + failedEvents / (double)POPULATION_SIZE * 100 + " %" + Environment.NewLine + 66 Console.WriteLine("SubroutineDeleter: " + Environment.NewLine + 66 67 Util.GetSizeDistributionString(trees, 105, 5) + Environment.NewLine + 67 68 Util.GetFunctionDistributionString(trees) + Environment.NewLine + … … 70 71 ); 71 72 } 73 74 private bool HasAtLeastOneAdf(SymbolicExpressionTree tree) { 75 return tree.Root.SubTrees.Count > 1; 76 } 72 77 } 73 78 } -
trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.3/Tests/SubroutineDuplicaterTest.cs
r4068 r5367 54 54 var grammar = Grammars.CreateArithmeticAndAdfGrammar(); 55 55 var random = new MersenneTwister(); 56 int failedEvents = 0;57 56 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 (!SubroutineDuplicater.DuplicateSubroutine(random, tree, grammar, MAX_TREE_SIZE, MAX_TREE_HEIGHT, 3, 3)) 60 failedEvents++; 57 SymbolicExpressionTree tree = null; 58 do { 59 tree = ProbabilisticTreeCreator.Create(random, grammar, MAX_TREE_SIZE, MAX_TREE_HEIGHT, 3, 3); 60 } while (!HasOneAdf(tree)); 61 var success = SubroutineDuplicater.DuplicateSubroutine(random, tree, grammar, MAX_TREE_SIZE, MAX_TREE_HEIGHT, 3, 3); 62 Assert.IsTrue(success); 61 63 Util.IsValid(tree); 62 64 trees.Add(tree); 63 65 } 64 Assert.Inconclusive("SubroutineDuplicater: " + Environment.NewLine + 65 "Failed events: " + failedEvents / (double)POPULATION_SIZE * 100 + " %" + Environment.NewLine + 66 Console.WriteLine("SubroutineDuplicater: " + Environment.NewLine + 66 67 Util.GetSizeDistributionString(trees, 105, 5) + Environment.NewLine + 67 68 Util.GetFunctionDistributionString(trees) + Environment.NewLine + … … 70 71 ); 71 72 } 73 74 private bool HasOneAdf(SymbolicExpressionTree tree) { 75 return tree.Root.SubTrees.Count == 2; 76 } 72 77 } 73 78 } -
trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.3/Tests/SubtreeCrossoverTest.cs
r4068 r5367 53 53 var trees = new List<SymbolicExpressionTree>(); 54 54 var grammar = Grammars.CreateArithmeticAndAdfGrammar(); 55 var random = new MersenneTwister(); 56 int failedEvents = 0; 55 var random = new MersenneTwister(31415); 57 56 List<SymbolicExpressionTree> crossoverTrees; 58 57 double msPerCrossoverEvent; … … 70 69 bool success; 71 70 newPopulation.Add(SubtreeCrossover.Cross(random, par0, par1, 0.9, 100, 10, out success)); 72 if (!success) failedEvents++;71 Assert.IsTrue(success); 73 72 } 74 73 crossoverTrees = newPopulation; … … 80 79 msPerCrossoverEvent = stopwatch.ElapsedMilliseconds / (double)POPULATION_SIZE / (double)generations; 81 80 82 Assert.Inconclusive("SubtreeCrossover: " + Environment.NewLine + 83 "Failed events: " + failedEvents / (double)POPULATION_SIZE * 100 + " %" + Environment.NewLine + 81 Console.WriteLine("SubtreeCrossover: " + Environment.NewLine + 84 82 msPerCrossoverEvent + " ms per crossover event (~" + Math.Round(1000.0 / (msPerCrossoverEvent)) + "crossovers / s)" + Environment.NewLine + 85 83 Util.GetSizeDistributionString(trees, 105, 5) + Environment.NewLine +
Note: See TracChangeset
for help on using the changeset viewer.