Free cookie consent management tool by TermsFeed Policy Generator

Changeset 15795


Ignore:
Timestamp:
02/21/18 10:44:54 (7 years ago)
Author:
lkammere
Message:

#2886: Remove nested divisions from grammar and hashing.

Location:
branches/2886_SymRegGrammarEnumeration
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/2886_SymRegGrammarEnumeration/HeuristicLab.Algorithms.DataAnalysis.SymRegGrammarEnumeration/GrammarEnumeration/Grammar.cs

    r15794 r15795  
    2727    public NonterminalSymbol SimpleTerm;
    2828
     29    public NonterminalSymbol InvExpr;
     30    public NonterminalSymbol InvTerm;
     31
    2932    public TerminalSymbol Addition;
    3033    public TerminalSymbol Multiplication;
     
    7477      SimpleTerm = new NonterminalSymbol("SimpleTerm");
    7578
     79      InvExpr = new NonterminalSymbol("InvExpr");
     80      InvTerm = new NonterminalSymbol("InvTerm");
     81
    7682      Addition = new TerminalSymbol("+");
    7783      Multiplication = new TerminalSymbol("*");
     
    9399
    94100      Term.AddProduction(Factor, Term, Multiplication);
    95       Term.AddProduction(Expr, Inv, Term, Multiplication);
    96101      Term.AddProduction(Factor);
     102      Term.AddProduction(InvExpr, Inv);
    97103
    98104      Factor.AddProduction(Var);
     
    110116      SimpleTerm.AddProduction(Var, SimpleTerm, Multiplication);
    111117      SimpleTerm.AddProduction(Var);
     118
     119      InvExpr.AddProduction(InvTerm, InvExpr, Addition);
     120      InvExpr.AddProduction(InvTerm);
     121
     122      InvTerm.AddProduction(Factor, InvTerm, Multiplication);
     123      InvTerm.AddProduction(Factor);
    112124      #endregion
    113125
     
    137149
    138150      Stack<Symbol> parseStack = new Stack<Symbol>(sentence);
    139       CancelOutCompoundInverse(parseStack);
    140151
    141152      Symbol peek = parseStack.Peek();
     
    145156
    146157    private string[] GetSubtreeHashes(Stack<Symbol> parseStack) {
    147       CancelOutCompoundInverse(parseStack);
    148158      Symbol currentSymbol = parseStack.Pop();
    149159
     
    237247    }
    238248
     249    /*
    239250    private void CancelOutCompoundInverse(Stack<Symbol> parseStack) {
    240251      // Resolve compound divisions
     
    250261        parseStack.Push(Inv);
    251262      } // else: compound divisions fully cancel out each other.
    252     }
     263    } */
    253264    #endregion
    254265
  • branches/2886_SymRegGrammarEnumeration/Test/TreeHashingTest.cs

    r15791 r15795  
    132132    }
    133133
     134    /* DEPRECATED; SINCE WE DO NOT ALLOW COMPOUND DIVISIONS
    134135    [TestMethod]
    135136    [TestCategory("TreeHashing")]
     
    158159    [TestMethod]
    159160    [TestCategory("TreeHashing")]
    160     public void a_UncancelableCompoundInverse() {
     161    public void UncancelableCompoundInverse() {
    161162      // 1 / ( 1/b + sin(a*c) )
    162163      SymbolString s1 = new SymbolString(new Symbol[] { varB, grammar.Inv, varA, varC, grammar.Multiplication, grammar.Sin, grammar.Addition, grammar.Inv });
     
    168169
    169170      Assert.AreNotEqual(hash1, hash2);
    170     }
     171    }*/
    171172
    172173    #region parser
Note: See TracChangeset for help on using the changeset viewer.