Free cookie consent management tool by TermsFeed Policy Generator

Changeset 15977


Ignore:
Timestamp:
06/30/18 12:53:57 (6 years ago)
Author:
bburlacu
Message:

#2886: Clear search data structures at the end of the run (huge memory savings)

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

Legend:

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

    r15975 r15977  
    437437      }
    438438
     439      // free memory at the end of the run (this saves a lot of memory)
     440      ArchivedPhrases.Clear();
     441      OpenPhrases.Clear();
     442      DistinctSentencesComplexity.Clear();
     443
    439444      var tree = Grammar.ParseSymbolicExpressionTree(BestTrainingSentence);
    440445      var model = new SymbolicRegressionModel(Problem.ProblemData.TargetVariable, tree, new SymbolicDataAnalysisExpressionTreeLinearInterpreter());
  • branches/2886_SymRegGrammarEnumeration/HeuristicLab.Algorithms.DataAnalysis.SymRegGrammarEnumeration/GrammarEnumeration/SearchDataStructure.cs

    r15974 r15977  
    8282    private Func<int> fetchInternal; // Fetch hash-reference
    8383
    84     public SearchDataStore() : this(StorageType.PriorityQueue) { }
     84    public SearchDataStore() : this(StorageType.SortedSet) { }
    8585
    8686    [StorableConstructor]
     
    9494
    9595      storedValues = new LruCache<int, SearchNode>(this.cacheSize);
    96       InitStorage();
    97     }
    98 
    99     private void InitStorage() {
     96      InitSearchDataStructure();
     97    }
     98
     99    private void InitSearchDataStructure() {
    100100      switch (storageType) {
    101101        case StorageType.PriorityQueue:
     
    113113        case StorageType.SortedSet:
    114114          InitSortedSet();
     115          break;
     116      }
     117    }
     118
     119    private void ClearSearchDataStructure() {
     120      switch (storageType) {
     121        case StorageType.PriorityQueue:
     122          priorityQueue = null;
     123          break;
     124        case StorageType.Stack:
     125          stack.Clear();
     126          break;
     127        case StorageType.Queue:
     128          queue.Clear();
     129          break;
     130        case StorageType.RandomList:
     131          list.Clear();
     132          break;
     133        case StorageType.SortedSet:
     134          sortedSet.Clear();
    115135          break;
    116136      }
     
    127147      searchDataStructureSize = original.searchDataStructureSize;
    128148
    129       InitStorage();
     149      InitSearchDataStructure();
    130150      switch (storageType) {
    131151        case StorageType.PriorityQueue:
     
    289309    }
    290310
     311    public void Clear() {
     312      storedValues.Clear();
     313    }
     314
    291315    #endregion
    292316
Note: See TracChangeset for help on using the changeset viewer.