Changeset 5686 for branches/DataAnalysis Refactoring/HeuristicLab.Problems.ArtificialAnt/3.4/ArtificialAntExpressionGrammar.cs
- Timestamp:
- 03/15/11 13:34:38 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/DataAnalysis Refactoring/HeuristicLab.Problems.ArtificialAnt/3.4/ArtificialAntExpressionGrammar.cs
r5517 r5686 28 28 namespace HeuristicLab.Problems.ArtificialAnt { 29 29 [StorableClass] 30 public class ArtificialAntExpressionGrammar : DefaultSymbolicExpressionGrammar {30 public class ArtificialAntExpressionGrammar : SymbolicExpressionGrammar { 31 31 32 32 public ArtificialAntExpressionGrammar() … … 53 53 54 54 allSymbols.ForEach(s => AddSymbol(s)); 55 SetMinSubtreeCount(ifFoodAhead, 2); 56 SetMaxSubtreeCount(ifFoodAhead, 2); 57 SetMinSubtreeCount(prog2, 2); 58 SetMaxSubtreeCount(prog2, 2); 59 SetMinSubtreeCount(prog3, 3); 60 SetMaxSubtreeCount(prog3, 3); 61 SetMinSubtreeCount(move, 0); 62 SetMaxSubtreeCount(move, 0); 63 SetMinSubtreeCount(left, 0); 64 SetMaxSubtreeCount(left, 0); 65 SetMinSubtreeCount(right, 0); 66 SetMaxSubtreeCount(right, 0); 55 SetSubtreeCount(ifFoodAhead, 2, 3); 56 SetSubtreeCount(prog2, 2, 2); 57 SetSubtreeCount(prog3, 3, 3); 58 SetSubtreeCount(move, 0, 0); 59 SetSubtreeCount(left, 0, 0); 60 SetSubtreeCount(right, 0, 0); 67 61 68 62 // each symbols is allowed as child of the start symbol 69 allSymbols.ForEach(s => SetAllowedChild(StartSymbol, s, 0)); 63 allSymbols.ForEach(s => AddAllowedChildSymbol(StartSymbol, s)); 64 allSymbols.ForEach(s => AddAllowedChildSymbol(DefunSymbol, s)); 70 65 71 66 // each symbol is allowed as child of all other symbols (except for terminals that have MaxSubtreeCount == 0 72 foreach (var parent in allSymbols) { 73 for (int argIndex = 0; argIndex < GetMaxSubtreeCount(parent); argIndex++) { 74 foreach (var child in allSymbols) { 75 SetAllowedChild(parent, child, argIndex); 76 } 67 foreach (var parent in nonTerminalSymbols) { 68 foreach (var child in allSymbols) { 69 AddAllowedChildSymbol(parent, child); 77 70 } 78 71 }
Note: See TracChangeset
for help on using the changeset viewer.