Changeset 16654 for branches/2866_SymRegHyperbolicFunctions/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Interpreter/SymbolicDataAnalysisExpressionTreeNativeInterpreter.cs
- Timestamp:
- 03/07/19 12:29:27 (5 years ago)
- Location:
- branches/2866_SymRegHyperbolicFunctions/HeuristicLab.Problems.DataAnalysis.Symbolic
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2866_SymRegHyperbolicFunctions/HeuristicLab.Problems.DataAnalysis.Symbolic
- Property svn:mergeinfo changed
-
branches/2866_SymRegHyperbolicFunctions/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Interpreter/SymbolicDataAnalysisExpressionTreeNativeInterpreter.cs
r16277 r16654 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 8Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2019 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. … … 29 29 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding; 30 30 using HeuristicLab.Parameters; 31 using H euristicLab.Persistence.Default.CompositeSerializers.Storable;31 using HEAL.Attic; 32 32 33 33 namespace HeuristicLab.Problems.DataAnalysis.Symbolic { 34 [Storable Class]34 [StorableType("91723319-8F15-4D33-B277-40AC7C7CF9AE")] 35 35 [Item("SymbolicDataAnalysisExpressionTreeNativeInterpreter", "An interpreter that wraps a native dll")] 36 36 public class SymbolicDataAnalysisExpressionTreeNativeInterpreter : ParameterizedNamedItem, ISymbolicDataAnalysisExpressionTreeInterpreter { … … 57 57 58 58 [StorableConstructor] 59 protected SymbolicDataAnalysisExpressionTreeNativeInterpreter(bool deserializing) : base(deserializing) { } 60 59 protected SymbolicDataAnalysisExpressionTreeNativeInterpreter(StorableConstructorFlag _) : base(_) { } 61 60 62 61 protected SymbolicDataAnalysisExpressionTreeNativeInterpreter(SymbolicDataAnalysisExpressionTreeNativeInterpreter original, Cloner cloner) : base(original, cloner) { … … 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.