- Timestamp:
- 04/12/10 08:29:50 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.3/Tests/SubroutineCreaterTest.cs
r3297 r3307 8 8 using System.Diagnostics; 9 9 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.ArchitectureAlteringOperators; 10 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.GeneralSymbols; 10 11 11 12 namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding_3._3.Tests { … … 38 39 var random = new MersenneTwister(); 39 40 for (int i = 0; i < populationSize; i++) { 40 randomTrees.Add(ProbabilisticTreeCreator.Create(random, grammar, 100, 10)); 41 var randTree = ProbabilisticTreeCreator.Create(random, grammar, 100, 10); 42 Assert.IsTrue(grammar.IsValidExpression(randTree)); 43 randomTrees.Add(randTree); 41 44 } 42 45 var newPopulation = new List<SymbolicExpressionTree>(); … … 62 65 private class TestGrammar : DefaultSymbolicExpressionGrammar { 63 66 public TestGrammar() 64 : base(0, 0, 0, 0) {67 : base(0, 3, 0, 3) { 65 68 Initialize(); 66 69 } … … 73 76 var terminal = new Terminal(); 74 77 75 var allSymbols = new List<Symbol>() { add, sub, mul, div, terminal }; 78 var defun = new Defun(); 79 var invoke = new InvokeFunction(); 80 81 var allSymbols = new List<Symbol>() { add, sub, mul, div, terminal, invoke }; 76 82 var functionSymbols = new List<Symbol>() { add, sub, mul, div }; 77 allSymbols.ForEach(s => AddAllowedSymbols(StartSymbol, 0, s)); 78 83 foreach (var symb in allSymbols) { 84 AddAllowedSymbols(StartSymbol, 0, symb); 85 AddAllowedSymbols(defun, 0, symb); 86 } 87 SetMinSubTreeCount(invoke, 0); 88 SetMaxSubTreeCount(invoke, 3); 89 for (int i = 0; i < 3; i++) { 90 allSymbols.ForEach(s => AddAllowedSymbols(invoke, i, s)); 91 } 79 92 SetMinSubTreeCount(terminal, 0); 80 93 SetMaxSubTreeCount(terminal, 0);
Note: See TracChangeset
for help on using the changeset viewer.