Changeset 16428 for branches/2845_EnhancedProgress/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Interpreter/SymbolicDataAnalysisExpressionTreeBatchInterpreter.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/SymbolicDataAnalysisExpressionTreeBatchInterpreter.cs
r16311 r16428 36 36 Parameters.Add(new FixedValueParameter<IntValue>(EvaluatedSolutionsParameterName, "A counter for the total number of solutions the interpreter has evaluated", new IntValue(0))); 37 37 } 38 39 38 40 39 [StorableConstructor] … … 111 110 112 111 case OpCodes.Root: { 113 Root(instr.buf, code[c].buf); 112 Load(instr.buf, code[c].buf); 113 Root(instr.buf, code[c + 1].buf); 114 114 break; 115 115 } … … 120 120 } 121 121 122 case OpCodes.Cube: { 123 Cube(instr.buf, code[c].buf); 124 break; 125 } 126 case OpCodes.CubeRoot: { 127 CubeRoot(instr.buf, code[c].buf); 128 break; 129 } 130 122 131 case OpCodes.Power: { 123 Pow(instr.buf, code[c].buf); 132 Load(instr.buf, code[c].buf); 133 Pow(instr.buf, code[c + 1].buf); 124 134 break; 125 135 } … … 149 159 break; 150 160 } 161 162 case OpCodes.Absolute: { 163 Absolute(instr.buf, code[c].buf); 164 break; 165 } 166 167 case OpCodes.AnalyticQuotient: { 168 Load(instr.buf, code[c].buf); 169 AnalyticQuotient(instr.buf, code[c + 1].buf); 170 break; 171 } 151 172 } 152 173 } 153 174 } 175 176 private readonly object syncRoot = new object(); 154 177 155 178 [ThreadStatic] 156 179 private Dictionary<string, double[]> cachedData; 157 180 181 [ThreadStatic] 182 private IDataset dataset; 183 158 184 private void InitCache(IDataset dataset) { 185 this.dataset = dataset; 159 186 cachedData = new Dictionary<string, double[]>(); 160 187 foreach (var v in dataset.DoubleVariables) { … … 165 192 public void InitializeState() { 166 193 cachedData = null; 194 dataset = null; 167 195 EvaluatedSolutions = 0; 168 196 } 169 197 170 198 private double[] GetValues(ISymbolicExpressionTree tree, IDataset dataset, int[] rows) { 199 if (cachedData == null || this.dataset != dataset) { 200 InitCache(dataset); 201 } 202 171 203 var code = Compile(tree, dataset, OpCodes.MapSymbolToOpCode); 172 204 var remainingRows = rows.Length % BATCHSIZE; … … 185 217 } 186 218 219 // when evaluation took place without any error, we can increment the counter 220 lock (syncRoot) { 221 EvaluatedSolutions++; 222 } 223 187 224 return result; 188 225 } 189 226 190 227 public IEnumerable<double> GetSymbolicExpressionTreeValues(ISymbolicExpressionTree tree, IDataset dataset, int[] rows) { 191 if (cachedData == null) {192 InitCache(dataset);193 }194 228 return GetValues(tree, dataset, rows); 195 229 }
Note: See TracChangeset
for help on using the changeset viewer.