Changeset 15817
- Timestamp:
- 02/26/18 14:13:38 (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2886_SymRegGrammarEnumeration/HeuristicLab.Algorithms.DataAnalysis.SymRegGrammarEnumeration/GrammarEnumeration/Grammar.cs
r15812 r15817 22 22 public NonterminalSymbol ExpFactor; 23 23 public NonterminalSymbol SinFactor; 24 public NonterminalSymbol CosFactor; 24 25 25 26 public NonterminalSymbol SimpleExpr; … … 34 35 public TerminalSymbol Exp; 35 36 public TerminalSymbol Sin; 37 public TerminalSymbol Cos; 36 38 public TerminalSymbol Inv; 37 39 … … 54 56 private ISymbol divSy; 55 57 private ISymbol sinSy; 56 58 private ISymbol cosSy; 59 57 60 private ISymbol rootSy; 58 61 private ISymbol startSy; … … 69 72 ExpFactor = new NonterminalSymbol("ExpFactor"); 70 73 SinFactor = new NonterminalSymbol("SinFactor"); 71 74 CosFactor = new NonterminalSymbol("CosFactor"); 75 72 76 SimpleExpr = new NonterminalSymbol("SimpleExpr"); 73 77 SimpleTerm = new NonterminalSymbol("SimpleTerm"); … … 81 85 Exp = new TerminalSymbol("exp"); 82 86 Sin = new TerminalSymbol("sin"); 87 Cos = new TerminalSymbol("cos"); 83 88 Inv = new TerminalSymbol("inv"); 84 89 … … 101 106 Factor.AddProduction(ExpFactor); 102 107 Factor.AddProduction(SinFactor); 108 Factor.AddProduction(CosFactor); 103 109 104 110 LogFactor.AddProduction(SimpleExpr, Log); 105 111 ExpFactor.AddProduction(SimpleTerm, Exp); 106 112 SinFactor.AddProduction(SimpleExpr, Sin); 113 CosFactor.AddProduction(SimpleExpr, Cos); 107 114 108 115 SimpleExpr.AddProduction(SimpleTerm, SimpleExpr, Addition); … … 131 138 divSy = symbolicExpressionGrammar.Symbols.OfType<Division>().First(); 132 139 sinSy = symbolicExpressionGrammar.Symbols.OfType<Sine>().First(); 140 cosSy = symbolicExpressionGrammar.Symbols.OfType<Cosine>().First(); 133 141 134 142 rootSy = symbolicExpressionGrammar.Symbols.OfType<ProgramRootSymbol>().First(); … … 223 231 // LOG, EXP, SIN, INV 224 232 if (ReferenceEquals(currentSymbol, Log) || ReferenceEquals(currentSymbol, Exp) || 225 ReferenceEquals(currentSymbol, Sin) || ReferenceEquals(currentSymbol, Inv)) { 233 ReferenceEquals(currentSymbol, Sin) || ReferenceEquals(currentSymbol, Cos) || 234 ReferenceEquals(currentSymbol, Inv)) { 226 235 return new[] { aggregateHashes(parseStack.Peek(), GetSubtreeHashes(parseStack, aggregateHashes)) }; 227 236 } … … 308 317 parsedSubTree.AddSubtree(ParseSymbolicExpressionTree(parseStack)); 309 318 319 } else if (ReferenceEquals(currentSymbol, Cos)) { 320 parsedSubTree = cosSy.CreateTreeNode(); 321 parsedSubTree.AddSubtree(ParseSymbolicExpressionTree(parseStack)); 322 310 323 } else if (ReferenceEquals(currentSymbol, Inv)) { 311 324 parsedSubTree = divSy.CreateTreeNode(); … … 350 363 351 364 } else if (ReferenceEquals(head, Log) || ReferenceEquals(head, Exp) 352 || ReferenceEquals(head, Sin) || ReferenceEquals(head, Inv)) { 365 || ReferenceEquals(head, Sin) || ReferenceEquals(head, Cos) 366 || ReferenceEquals(head, Inv)) { 353 367 result.Add(head); 354 368 result.Add(OpeningBracket);
Note: See TracChangeset
for help on using the changeset viewer.