Changeset 16428 for branches/2845_EnhancedProgress/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Interpreter/SymbolicDataAnalysisExpressionTreeNativeInterpreter.cs
- Timestamp:
- 12/21/18 10:31:49 (5 years ago)
- Location:
- branches/2845_EnhancedProgress
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2845_EnhancedProgress
- Property svn:mergeinfo changed
-
branches/2845_EnhancedProgress/HeuristicLab.Problems.DataAnalysis.Symbolic
- Property svn:mergeinfo changed
-
branches/2845_EnhancedProgress/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Interpreter/SymbolicDataAnalysisExpressionTreeNativeInterpreter.cs
r16311 r16428 59 59 protected SymbolicDataAnalysisExpressionTreeNativeInterpreter(bool deserializing) : base(deserializing) { } 60 60 61 62 61 protected SymbolicDataAnalysisExpressionTreeNativeInterpreter(SymbolicDataAnalysisExpressionTreeNativeInterpreter original, Cloner cloner) : base(original, cloner) { 63 62 } … … 99 98 private static Dictionary<string, GCHandle> cachedData; 100 99 100 [ThreadStatic] 101 private IDataset dataset; 102 101 103 public IEnumerable<double> GetSymbolicExpressionTreeValues(ISymbolicExpressionTree tree, IDataset dataset, IEnumerable<int> rows) { 102 104 if (!rows.Any()) return Enumerable.Empty<double>(); 103 105 104 lock (syncRoot) { 105 EvaluatedSolutions++; // increment the evaluated solutions counter 106 } 107 108 if (cachedData == null) { 106 if (cachedData == null || this.dataset != dataset) { 109 107 InitCache(dataset); 110 108 } … … 116 114 117 115 NativeWrapper.GetValuesVectorized(code, code.Length, rowsArray, rowsArray.Length, result); 116 117 // when evaluation took place without any error, we can increment the counter 118 lock (syncRoot) { 119 EvaluatedSolutions++; 120 } 121 118 122 return result; 119 123 } 120 124 121 125 private void InitCache(IDataset dataset) { 126 this.dataset = dataset; 127 128 // free handles to old data 129 if (cachedData != null) { 130 foreach (var gch in cachedData.Values) { 131 gch.Free(); 132 } 133 cachedData = null; 134 } 135 136 // cache new data 122 137 cachedData = new Dictionary<string, GCHandle>(); 123 138 foreach (var v in dataset.DoubleVariables) { … … 135 150 cachedData = null; 136 151 } 152 dataset = null; 137 153 EvaluatedSolutions = 0; 138 154 }
Note: See TracChangeset
for help on using the changeset viewer.