Changeset 15993 for branches/2886_SymRegGrammarEnumeration/HeuristicLab.Algorithms.DataAnalysis.SymRegGrammarEnumeration/GrammarEnumeration/SearchDataStructure.cs
- Timestamp:
- 07/11/18 10:34:21 (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2886_SymRegGrammarEnumeration/HeuristicLab.Algorithms.DataAnalysis.SymRegGrammarEnumeration/GrammarEnumeration/SearchDataStructure.cs
r15977 r15993 52 52 class SearchDataStore : DeepCloneable, IEnumerable<SearchNode> { 53 53 [Storable] 54 private LruCache<int, SearchNode> storedValues; 55 //private Dictionary<int, SearchNode> storedValues; // Store hash-references and associated, actual values 54 private Dictionary<int, SearchNode> storedValues; // Store hash-references and associated, actual values 56 55 57 56 [Storable] … … 72 71 [Storable] 73 72 private int searchDataStructureSize; // storage size for search nodes 74 75 [Storable]76 private int cacheSize; // cache for already explored search nodes77 73 78 74 [ExcludeFromObjectGraphTraversal] … … 87 83 protected SearchDataStore(bool deserializing) : this() { } 88 84 89 public SearchDataStore(StorageType storageType, int searchDataStructureSize = (int)1e5 , int cacheSize = (int)1e5) {85 public SearchDataStore(StorageType storageType, int searchDataStructureSize = (int)1e5) { 90 86 this.storageType = storageType; 91 87 92 88 this.searchDataStructureSize = searchDataStructureSize; 93 this.cacheSize = cacheSize; 94 95 storedValues = new LruCache<int, SearchNode>(this.cacheSize); 89 90 storedValues = new Dictionary<int, SearchNode>(); 96 91 InitSearchDataStructure(); 97 92 } … … 142 137 143 138 protected SearchDataStore(SearchDataStore original, Cloner cloner) : base(original, cloner) { 144 storedValues = cloner.Clone(original.storedValues);139 storedValues = original.storedValues.ToDictionary(x => x.Key, x => cloner.Clone(x.Value)); 145 140 storageType = original.storageType; 146 cacheSize = original.cacheSize;147 141 searchDataStructureSize = original.searchDataStructureSize; 148 142 … … 204 198 var max = sortedSet.Max; 205 199 sortedSet.Remove(max); 206 storedValues.Remove(max.Item2); 200 storedValues.Remove(max.Item2); // should always be in sync with the sorted set 207 201 } 208 202 sortedSet.Add(Tuple.Create(prio, hash)); … … 211 205 var elem = sortedSet.FirstOrDefault(); 212 206 if (elem == null) 213 return 0;207 return default(int); 214 208 sortedSet.Remove(elem); 215 209 return elem.Item2; … … 226 220 // size is the 0-based index of the last used element 227 221 if (priorityQueue.Size == capacity - 1) { 228 // if the queue is at capacity we have to replace 229 return; 222 return; // if the queue is at capacity we have to return 230 223 } 231 224 priorityQueue.Insert(prio, hash);
Note: See TracChangeset
for help on using the changeset viewer.