Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
03/08/18 10:54:04 (6 years ago)
Author:
lkammere
Message:

#2886: Fix Equals methods in Symbols.
Move semantical hashing of phrases to separate class.

Location:
branches/2886_SymRegGrammarEnumeration/Test
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/2886_SymRegGrammarEnumeration/Test/GrammarEnumerationTest.cs

    r15821 r15832  
    7272      });
    7373
    74       int targetSolutionHash = alg.Grammar.CalcHashCode(targetSolution);
    75       int actualSolutionHash = alg.Grammar.CalcHashCode(alg.BestTrainingSentence);
     74      int targetSolutionHash = alg.Grammar.Hasher.CalcHashCode(targetSolution);
     75      int actualSolutionHash = alg.Grammar.Hasher.CalcHashCode(alg.BestTrainingSentence);
    7676
    7777      Assert.IsTrue(alg.DistinctSentencesLength.ContainsKey(targetSolutionHash), "Actual solution was not generated!");
     
    127127      });
    128128
    129       int targetSolutionHash = alg.Grammar.CalcHashCode(targetSolution);
    130       int actualSolutionHash = alg.Grammar.CalcHashCode(alg.BestTrainingSentence);
     129      int targetSolutionHash = alg.Grammar.Hasher.CalcHashCode(targetSolution);
     130      int actualSolutionHash = alg.Grammar.Hasher.CalcHashCode(alg.BestTrainingSentence);
    131131
    132132      Assert.IsTrue(alg.DistinctSentencesLength.ContainsKey(targetSolutionHash), "Actual solution was not generated!");
     
    156156      });
    157157
    158       int targetSolutionHash = alg.Grammar.CalcHashCode(targetSolution);
    159       int actualSolutionHash = alg.Grammar.CalcHashCode(alg.BestTrainingSentence);
     158      int targetSolutionHash = alg.Grammar.Hasher.CalcHashCode(targetSolution);
     159      int actualSolutionHash = alg.Grammar.Hasher.CalcHashCode(alg.BestTrainingSentence);
    160160
    161161      Assert.IsTrue(alg.DistinctSentencesLength.ContainsKey(targetSolutionHash), "Actual solution was not generated!");
  • branches/2886_SymRegGrammarEnumeration/Test/TreeHashingTest.cs

    r15824 r15832  
    2828      SymbolString s2 = new SymbolString(new[] { varA, varB, grammar.Addition, varC, grammar.Addition });
    2929
    30       int hash1 = grammar.CalcHashCode(s1);
    31       int hash2 = grammar.CalcHashCode(s2);
     30      int hash1 = grammar.Hasher.CalcHashCode(s1);
     31      int hash2 = grammar.Hasher.CalcHashCode(s2);
    3232
    3333      Assert.AreEqual(hash1, hash2);
     
    4040      SymbolString s2 = new SymbolString(new[] { varB, varB, grammar.Addition, varB, grammar.Addition });
    4141
    42       int hash1 = grammar.CalcHashCode(s1);
    43       int hash2 = grammar.CalcHashCode(s2);
     42      int hash1 = grammar.Hasher.CalcHashCode(s1);
     43      int hash2 = grammar.Hasher.CalcHashCode(s2);
    4444
    4545      Assert.AreNotEqual(hash1, hash2);
     
    5252      SymbolString s2 = new SymbolString(new[] { varB, varA, grammar.Addition });
    5353
    54       int hash1 = grammar.CalcHashCode(s1);
    55       int hash2 = grammar.CalcHashCode(s2);
     54      int hash1 = grammar.Hasher.CalcHashCode(s1);
     55      int hash2 = grammar.Hasher.CalcHashCode(s2);
    5656
    5757      Assert.AreEqual(hash1, hash2);
     
    6464      SymbolString s2 = new SymbolString(new[] { varA, varB, varA, grammar.Addition, grammar.Addition });
    6565
    66       int hash1 = grammar.CalcHashCode(s1);
    67       int hash2 = grammar.CalcHashCode(s2);
     66      int hash1 = grammar.Hasher.CalcHashCode(s1);
     67      int hash2 = grammar.Hasher.CalcHashCode(s2);
    6868
    6969      Assert.AreEqual(hash1, hash2);
     
    7676      SymbolString s2 = new SymbolString(new[] { varA });
    7777
    78       int hash1 = grammar.CalcHashCode(s1);
    79       int hash2 = grammar.CalcHashCode(s2);
     78      int hash1 = grammar.Hasher.CalcHashCode(s1);
     79      int hash2 = grammar.Hasher.CalcHashCode(s2);
    8080
    8181      Assert.AreEqual(hash1, hash2);
     
    8888      SymbolString s2 = new SymbolString(new[] { varA, varA, varA, grammar.Multiplication, grammar.Addition });
    8989
    90       int hash1 = grammar.CalcHashCode(s1);
    91       int hash2 = grammar.CalcHashCode(s2);
     90      int hash1 = grammar.Hasher.CalcHashCode(s1);
     91      int hash2 = grammar.Hasher.CalcHashCode(s2);
    9292
    9393      Assert.AreNotEqual(hash1, hash2);
     
    100100      SymbolString s2 = new SymbolString(new Symbol[] { varA, grammar.Expr, grammar.Addition });
    101101
    102       int hash1 = grammar.CalcHashCode(s1);
    103       int hash2 = grammar.CalcHashCode(s2);
     102      int hash1 = grammar.Hasher.CalcHashCode(s1);
     103      int hash2 = grammar.Hasher.CalcHashCode(s2);
    104104
    105105      Assert.AreEqual(hash1, hash2);
     
    114114      SymbolString s2 = new SymbolString(new Symbol[] { varA, varB, grammar.Multiplication });
    115115
    116       int hash1 = grammar.CalcHashCode(s1);
    117       int hash2 = grammar.CalcHashCode(s2);
     116      int hash1 = grammar.Hasher.CalcHashCode(s1);
     117      int hash2 = grammar.Hasher.CalcHashCode(s2);
    118118
    119119      Assert.AreEqual(hash1, hash2);
     
    126126      SymbolString s2 = new SymbolString(new Symbol[] { varA, varA, varA, grammar.Multiplication, grammar.Addition, grammar.Sin, varA, grammar.Inv, varA, grammar.Sin, varA, grammar.Multiplication, grammar.Multiplication, grammar.Addition });
    127127
    128       int hash1 = grammar.CalcHashCode(s1);
    129       int hash2 = grammar.CalcHashCode(s2);
     128      int hash1 = grammar.Hasher.CalcHashCode(s1);
     129      int hash2 = grammar.Hasher.CalcHashCode(s2);
    130130
    131131      Assert.AreEqual(hash1, hash2);
Note: See TracChangeset for help on using the changeset viewer.