- Timestamp:
- 02/22/18 13:46:16 (7 years ago)
- 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 204 204 for (int i = 0; i < isFactorRemaining.Length; i++) { 205 205 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. 207 207 208 208 var currFactor = childHashes[i]; … … 241 241 } 242 242 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 244 244 } 245 245 … … 268 268 Debug.Assert(sentence.All(s => s is TerminalSymbol), "Trying to evaluate symbol sequence with nonterminalsymbols!"); 269 269 270 symbolicExpressionGrammar.ConfigureAsDefaultRegressionGrammar(); 270 symbolicExpressionGrammar.ConfigureAsDefaultRegressionGrammar(); // TODO: not necessary to call this for each sentence 271 271 272 272 var rootNode = rootSy.CreateTreeNode(); -
branches/2886_SymRegGrammarEnumeration/HeuristicLab.Algorithms.DataAnalysis.SymRegGrammarEnumeration/GrammarEnumeration/GrammarEnumerationAlgorithm.cs
r15803 r15806 136 136 foreach (Production productionAlternative in expandedSymbol.Alternatives) { 137 137 SymbolString newPhrase = new SymbolString(currPhrase); 138 newPhrase.RemoveAt(nonterminalSymbolIndex); 138 newPhrase.RemoveAt(nonterminalSymbolIndex); // TODO: removeat and insertRange are both O(n) 139 139 newPhrase.InsertRange(nonterminalSymbolIndex, productionAlternative); 140 140 … … 181 181 AllSentences[hash].Add(sentence); 182 182 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 184 184 } 185 185 -
branches/2886_SymRegGrammarEnumeration/HeuristicLab.Algorithms.DataAnalysis.SymRegGrammarEnumeration/GrammarEnumeration/SearchDataStructure.cs
r15800 r15806 5 5 namespace HeuristicLab.Algorithms.DataAnalysis.SymRegGrammarEnumeration.GrammarEnumeration { 6 6 7 // TODO: struct not useful here because you are boxing the structs with a new call below 7 8 public struct StoredSymbolString { 8 9 public readonly int Hash; … … 66 67 int indexOfHash = rand.Next(list.Count); 67 68 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 69 70 return result; 70 71 }; … … 79 80 SymbolString result = storedValues[hash]; 80 81 storedValues.Remove(hash); 81 return new StoredSymbolString(hash, result); 82 return new StoredSymbolString(hash, result); // TODO: new for structs creates a box anyway 82 83 } 83 84 84 85 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 86 87 storedValues[hash] = s; 87 88 }
Note: See TracChangeset
for help on using the changeset viewer.