Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
02/22/18 13:46:16 (7 years ago)
Author:
gkronber
Message:

#2886 made a few comments

Location:
branches/2886_SymRegGrammarEnumeration/HeuristicLab.Algorithms.DataAnalysis.SymRegGrammarEnumeration/GrammarEnumeration
Files:
3 edited

Legend:

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

    r15803 r15806  
    204204        for (int i = 0; i < isFactorRemaining.Length; i++) {
    205205          if (!isFactorRemaining[i]) continue;
    206           if (isFactorRemaining.Count(b => b) <= 2) break; // Until we have constants, we can't cancel out all terms.
     206          if (isFactorRemaining.Count() <= 2) break; // Until we have constants, we can't cancel out all terms.
    207207
    208208          var currFactor = childHashes[i];
     
    241241      }
    242242
    243       return $"[{hashesArray.Aggregate(operatorSym.StringRepresentation, (result, ti) => string.Concat(result, " ° ", ti))}]";
     243      return $"[{hashesArray.Aggregate(operatorSym.StringRepresentation, (result, ti) => string.Concat(result, " ° ", ti))}]";      // TODO: use string join instead of string.Concat
    244244    }
    245245
     
    268268      Debug.Assert(sentence.All(s => s is TerminalSymbol), "Trying to evaluate symbol sequence with nonterminalsymbols!");
    269269
    270       symbolicExpressionGrammar.ConfigureAsDefaultRegressionGrammar();
     270      symbolicExpressionGrammar.ConfigureAsDefaultRegressionGrammar();     // TODO: not necessary to call this for each sentence
    271271
    272272      var rootNode = rootSy.CreateTreeNode();
  • branches/2886_SymRegGrammarEnumeration/HeuristicLab.Algorithms.DataAnalysis.SymRegGrammarEnumeration/GrammarEnumeration/GrammarEnumerationAlgorithm.cs

    r15803 r15806  
    136136          foreach (Production productionAlternative in expandedSymbol.Alternatives) {
    137137            SymbolString newPhrase = new SymbolString(currPhrase);
    138             newPhrase.RemoveAt(nonterminalSymbolIndex);
     138            newPhrase.RemoveAt(nonterminalSymbolIndex);     // TODO: removeat and insertRange are both O(n)
    139139            newPhrase.InsertRange(nonterminalSymbolIndex, productionAlternative);
    140140
     
    181181        AllSentences[hash].Add(sentence);
    182182      else
    183         AllSentences[hash] = new List<SymbolString> { sentence };
     183        AllSentences[hash] = new List<SymbolString> { sentence }; //TODO: here we store all sentences even if they have the same hash value, this is not strictly necessary
    184184    }
    185185
  • branches/2886_SymRegGrammarEnumeration/HeuristicLab.Algorithms.DataAnalysis.SymRegGrammarEnumeration/GrammarEnumeration/SearchDataStructure.cs

    r15800 r15806  
    55namespace HeuristicLab.Algorithms.DataAnalysis.SymRegGrammarEnumeration.GrammarEnumeration {
    66
     7  // TODO: struct not useful here because you are boxing the structs with a new call below
    78  public struct StoredSymbolString {
    89    public readonly int Hash;
     
    6667        int indexOfHash = rand.Next(list.Count);
    6768        int result = list[indexOfHash];
    68         list.RemoveAt(indexOfHash);
     69        list.RemoveAt(indexOfHash);  // TODO: beware this is O(n), at some point in time we should fix this
    6970        return result;
    7071      };
     
    7980      SymbolString result = storedValues[hash];
    8081      storedValues.Remove(hash);
    81       return new StoredSymbolString(hash, result);
     82      return new StoredSymbolString(hash, result);  // TODO: new for structs creates a box anyway
    8283    }
    8384
    8485    public void Store(int hash, SymbolString s) {
    85       storeInternal.Invoke(hash);
     86      storeInternal.Invoke(hash); // TODO: explicit .Invoke() not necessary, just storeInternal(hash) is ok
    8687      storedValues[hash] = s;
    8788    }
Note: See TracChangeset for help on using the changeset viewer.