Changeset 5686 for branches/DataAnalysis Refactoring/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Tests/Grammars.cs
- Timestamp:
- 03/15/11 13:34:38 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/DataAnalysis Refactoring/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Tests/Grammars.cs
r5567 r5686 94 94 } 95 95 96 private class SimpleArithmeticGrammar : DefaultSymbolicExpressionGrammar {96 private class SimpleArithmeticGrammar : SymbolicExpressionGrammar { 97 97 protected SimpleArithmeticGrammar(SimpleArithmeticGrammar original, Cloner cloner) : base(original, cloner) { } 98 98 public SimpleArithmeticGrammar() … … 119 119 120 120 foreach (var funSymb in functionSymbols) { 121 SetMinSubtreeCount(funSymb, 1); 122 SetMaxSubtreeCount(funSymb, 3); 121 SetSubtreeCount(funSymb, 1, 3); 123 122 } 124 SetMinSubtreeCount(terminal, 0); 125 SetMaxSubtreeCount(terminal, 0); 123 SetSubtreeCount(terminal, 0, 0); 126 124 125 SetSubtreeCount(StartSymbol, 1, 1); 127 126 // allow each symbol as child of the start symbol 128 127 foreach (var symb in allSymbols) { 129 SetAllowedChild(StartSymbol, symb, 0); 128 AddAllowedChildSymbol(StartSymbol, symb); 129 AddAllowedChildSymbol(DefunSymbol, symb); 130 130 } 131 131 132 132 // allow each symbol as child of every other symbol (except for terminals that have maxSubtreeCount == 0) 133 foreach (var parent in allSymbols) { 134 for (int i = 0; i < GetMaxSubtreeCount(parent); i++) 135 foreach (var child in allSymbols) { 136 SetAllowedChild(parent, child, i); 137 } 133 foreach (var parent in functionSymbols) { 134 foreach (var child in allSymbols) { 135 AddAllowedChildSymbol(parent, child); 136 } 138 137 } 139 138 } 140 139 } 141 140 142 public static ISymbolicExpression TreeGrammar CreateSimpleArithmeticGrammar() {143 var g = new GlobalSymbolicExpressionGrammar(new SimpleArithmeticGrammar());144 g.Max FunctionArguments = 0;145 g.Min FunctionArguments = 0;146 g.Max FunctionDefinitions = 0;147 g.Min FunctionDefinitions = 0;141 public static ISymbolicExpressionGrammar CreateSimpleArithmeticGrammar() { 142 var g = new SimpleArithmeticGrammar(); 143 g.MaximumFunctionArguments = 0; 144 g.MinimumFunctionArguments = 0; 145 g.MaximumFunctionDefinitions = 0; 146 g.MinimumFunctionDefinitions = 0; 148 147 return g; 149 148 } 150 149 151 public static ISymbolicExpression TreeGrammar CreateArithmeticAndAdfGrammar() {152 var g = new GlobalSymbolicExpressionGrammar(new SimpleArithmeticGrammar());153 g.Max FunctionArguments = 3;154 g.Min FunctionArguments = 0;155 g.Max FunctionDefinitions = 3;156 g.Min FunctionDefinitions = 0;150 public static ISymbolicExpressionGrammar CreateArithmeticAndAdfGrammar() { 151 var g = new SimpleArithmeticGrammar(); 152 g.MaximumFunctionArguments = 3; 153 g.MinimumFunctionArguments = 0; 154 g.MaximumFunctionDefinitions = 3; 155 g.MinimumFunctionDefinitions = 0; 157 156 return g; 158 157 }
Note: See TracChangeset
for help on using the changeset viewer.