Changeset 5792 for branches/DataAnalysis Refactoring/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Tests
- Timestamp:
- 03/22/11 15:07:20 (14 years ago)
- Location:
- branches/DataAnalysis Refactoring/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Tests
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/DataAnalysis Refactoring/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Tests/AllArchitectureAlteringOperatorsTest.cs
r5759 r5792 32 32 public class AllArchitectureAlteringOperatorsTest { 33 33 private const int POPULATION_SIZE = 1000; 34 private const int N_ITERATIONS = 100;34 private const int N_ITERATIONS = 200; 35 35 private const int MAX_TREE_LENGTH = 100; 36 36 private const int MAX_TREE_DEPTH = 10; … … 99 99 par1 = (SymbolicExpressionTree)trees.SelectRandom(random).Clone(); 100 100 } while (par0.Length > MAX_TREE_LENGTH || par1.Length > MAX_TREE_LENGTH); 101 newTrees.Add(SubtreeCrossover.Cross(random, par0, par1, 0.9, MAX_TREE_LENGTH, MAX_TREE_DEPTH)); 101 var newTree = SubtreeCrossover.Cross(random, par0, par1, 0.9, MAX_TREE_LENGTH, MAX_TREE_DEPTH); 102 Util.IsValid(newTree); 103 newTrees.Add(newTree); 102 104 } 103 105 } 104 trees = newTrees; 106 trees = new List<ISymbolicExpressionTree>(newTrees); 107 newTrees.Clear(); 105 108 } 106 109 var msPerOperation = stopwatch.ElapsedMilliseconds / (double)POPULATION_SIZE / (double)N_ITERATIONS; -
branches/DataAnalysis Refactoring/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Tests/SubtreeCrossoverTest.cs
r5733 r5792 52 52 var grammar = Grammars.CreateArithmeticAndAdfGrammar(); 53 53 var random = new MersenneTwister(31415); 54 List<ISymbolicExpressionTree> crossoverTrees;55 54 double msPerCrossoverEvent; 56 55 … … 63 62 stopwatch.Start(); 64 63 for (int gCount = 0; gCount < generations; gCount++) { 65 var newPopulation = new List<ISymbolicExpressionTree>();66 64 for (int i = 0; i < POPULATION_SIZE; i++) { 67 var par0 = ( SymbolicExpressionTree)trees.SelectRandom(random).Clone();68 var par1 = ( SymbolicExpressionTree)trees.SelectRandom(random).Clone();69 newPopulation.Add(SubtreeCrossover.Cross(random, par0, par1, 0.9, 100, 10));65 var par0 = (ISymbolicExpressionTree)trees.SelectRandom(random).Clone(); 66 var par1 = (ISymbolicExpressionTree)trees.SelectRandom(random).Clone(); 67 SubtreeCrossover.Cross(random, par0, par1, 0.9, 100, 10); 70 68 } 71 crossoverTrees = newPopulation;72 69 } 73 70 stopwatch.Stop(); -
branches/DataAnalysis Refactoring/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Tests/Util.cs
r5733 r5792 141 141 142 142 } 143 143 144 foreach (var subtree in tree.Root.Subtrees) { 144 145 Assert.AreNotSame(subtree.Grammar, tree.Root.Grammar); … … 159 160 } 160 161 } 162 163 foreach (var symbol in grammar.ModifyableSymbols) { 164 //check if ever symbol has at least on 165 for (int i = 0; i < grammar.GetMaximumSubtreeCount(symbol); i++) 166 Assert.IsTrue(grammar.GetAllowedChildSymbols(symbol, i).Any()); 167 168 //if (symbol is ProgramRootSymbol) continue; 169 ////check if symbol is allowed as at least one child symbol 170 //bool result = false; 171 //foreach (var parentSymbol in grammar.Symbols) { 172 // if (result) break; 173 // for (int i = 0; i < grammar.GetMaximumSubtreeCount(parentSymbol); i++) 174 // result = result || grammar.IsAllowedChildSymbol(parentSymbol, symbol, i); 175 //} 176 //Assert.IsTrue(result); 177 178 } 161 179 } 162 180
Note: See TracChangeset
for help on using the changeset viewer.