Changeset 15849 for branches/2886_SymRegGrammarEnumeration/HeuristicLab.Algorithms.DataAnalysis.SymRegGrammarEnumeration
- Timestamp:
- 03/20/18 13:49:19 (7 years ago)
- Location:
- branches/2886_SymRegGrammarEnumeration/HeuristicLab.Algorithms.DataAnalysis.SymRegGrammarEnumeration
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2886_SymRegGrammarEnumeration/HeuristicLab.Algorithms.DataAnalysis.SymRegGrammarEnumeration/GrammarEnumeration/Grammar.cs
r15834 r15849 42 42 public TerminalSymbol Inv; 43 43 44 // For infix notation 45 public TerminalSymbol OpeningBracket; 46 public TerminalSymbol ClosingBracket; 44 public TerminalSymbol Const; 47 45 48 46 #endregion … … 93 91 Inv = new TerminalSymbol("inv"); 94 92 95 OpeningBracket = new TerminalSymbol("("); 96 ClosingBracket = new TerminalSymbol(")"); 93 Const = new TerminalSymbol("c"); 97 94 #endregion 98 95 … … 107 104 108 105 productions[Expr] = new[] { 109 new Production( Term, Expr, Addition),110 new Production( Term)106 new Production(Const, Term, Multiplication, Expr, Addition), 107 new Production(Const, Term, Multiplication, Const, Addition) 111 108 }; 112 109 … … 126 123 127 124 productions[LogFactor] = new[] { new Production(SimpleExpr, Log) }; 128 productions[ExpFactor] = new[] { new Production( SimpleTerm, Exp) };125 productions[ExpFactor] = new[] { new Production(Const, SimpleTerm, Multiplication, Exp) }; 129 126 productions[SinFactor] = new[] { new Production(SimpleExpr, Sin) }; 130 127 productions[CosFactor] = new[] { new Production(SimpleExpr, Cos) }; 131 128 132 129 productions[SimpleExpr] = new[] { 133 new Production( SimpleTerm, SimpleExpr, Addition),134 new Production( SimpleTerm)130 new Production(Const, SimpleTerm, Multiplication, SimpleExpr, Addition), 131 new Production(Const, SimpleTerm, Multiplication, Const, Addition) 135 132 }; 136 133 … … 141 138 142 139 productions[InvExpr] = new[] { 143 new Production( InvTerm, InvExpr, Addition),144 new Production( InvTerm)140 new Production(Const, InvTerm, Multiplication, InvExpr, Addition), 141 new Production(Const, InvTerm, Multiplication, Const, Addition) 145 142 }; 146 143 … … 206 203 if (currentSymbol == Addition) { 207 204 parsedSubTree = addSy.CreateTreeNode(); 208 parsedSubTree.AddSubtree(ParseSymbolicExpressionTree(parseStack)); // left part 209 parsedSubTree.AddSubtree(ParseSymbolicExpressionTree(parseStack)); // right part 205 ISymbolicExpressionTreeNode rightSubtree = ParseSymbolicExpressionTree(parseStack); 206 if (rightSubtree is ConstantTreeNode) { 207 ((ConstantTreeNode)rightSubtree).Value = 0.0; 208 } 209 parsedSubTree.AddSubtree(rightSubtree); // left part 210 211 ISymbolicExpressionTreeNode leftSubtree = ParseSymbolicExpressionTree(parseStack); 212 if (leftSubtree is ConstantTreeNode) { 213 ((ConstantTreeNode)leftSubtree).Value = 0.0; 214 } 215 parsedSubTree.AddSubtree(leftSubtree); // right part 210 216 211 217 } else if (currentSymbol == Multiplication) { … … 236 242 parsedSubTree.AddSubtree(dividend); 237 243 parsedSubTree.AddSubtree(ParseSymbolicExpressionTree(parseStack)); 244 245 } else if (currentSymbol == Const) { 246 ConstantTreeNode constNode = (ConstantTreeNode)constSy.CreateTreeNode(); 247 constNode.Value = 1.0; 248 parsedSubTree = constNode; 238 249 239 250 } else if (currentSymbol is VariableTerminalSymbol) { -
branches/2886_SymRegGrammarEnumeration/HeuristicLab.Algorithms.DataAnalysis.SymRegGrammarEnumeration/Hashing/Hasher.cs
r15835 r15849 44 44 } 45 45 46 // var or nonterminal symbol46 // var, const or nonterminal symbol 47 47 return new[] { AggregateHashes(currentSymbol, new THashType[0]) }; 48 48 }
Note: See TracChangeset
for help on using the changeset viewer.