Changeset 17071 for stable/HeuristicLab.Problems.DataAnalysis.Symbolic
- Timestamp:
- 07/04/19 16:03:48 (5 years ago)
- Location:
- stable
- Files:
-
- 4 edited
- 5 copied
Legend:
- Unmodified
- Added
- Removed
-
stable
- Property svn:mergeinfo changed
/trunk merged: 16266,16269,16274,16276-16277,16285-16287,16289,16293,16296-16298,16333-16334
- Property svn:mergeinfo changed
-
stable/HeuristicLab.Problems.DataAnalysis.Symbolic
- Property svn:mergeinfo changed
/trunk/HeuristicLab.Problems.DataAnalysis.Symbolic merged: 16276-16277,16285-16287,16289,16293,16296-16297
- Property svn:mergeinfo changed
-
stable/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/HeuristicLab.Problems.DataAnalysis.Symbolic-3.4.csproj
r17066 r17071 107 107 <Private>False</Private> 108 108 </Reference> 109 <Reference Include="HeuristicLab.Problems.DataAnalysis.Symbolic.NativeInterpreter-0.1, Version=0.0.0.1, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL"> 110 <SpecificVersion>False</SpecificVersion> 111 <HintPath>..\..\bin\HeuristicLab.Problems.DataAnalysis.Symbolic.NativeInterpreter-0.1.dll</HintPath> 112 <Private>False</Private> 113 </Reference> 109 114 <Reference Include="System" /> 110 115 <Reference Include="System.Core"> … … 152 157 <Compile Include="Interfaces\IVariableSymbol.cs" /> 153 158 <Compile Include="Interpreter\IntervalInterpreter.cs" /> 159 <Compile Include="Interpreter\BatchInstruction.cs" /> 160 <Compile Include="Interpreter\BatchOperations.cs" /> 154 161 <Compile Include="Interpreter\SymbolicDataAnalysisExpressionCompiledTreeInterpreter.cs" /> 162 <Compile Include="Interpreter\SymbolicDataAnalysisExpressionTreeBatchInterpreter.cs" /> 163 <Compile Include="Interpreter\SymbolicDataAnalysisExpressionTreeNativeInterpreter.cs" /> 155 164 <Compile Include="SymbolicDataAnalysisExpressionTreeSimplificationOperator.cs" /> 156 165 <Compile Include="SymbolicDataAnalysisModelComplexityCalculator.cs" /> -
stable/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Interpreter/BatchOperations.cs
r16287 r17071 64 64 a[i] = Math.Cos(b[i]); 65 65 } 66 67 public static void Tan(double[] a, double[] b) { 68 for (int i = 0; i < BATCHSIZE; ++i) 69 a[i] = Math.Tan(b[i]); 70 } 71 72 public static void Pow(double[] a, double[] b) { 73 for (int i = 0; i < BATCHSIZE; ++i) 74 a[i] = Math.Pow(a[i], Math.Round(b[i])); 75 } 76 77 public static void Root(double[] a, double[] b) { 78 for (int i = 0; i < BATCHSIZE; ++i) 79 a[i] = Math.Pow(a[i], 1 / Math.Round(b[i])); 80 } 81 82 public static void Square(double[] a, double[] b) { 83 for (int i = 0; i < BATCHSIZE; ++i) 84 a[i] = Math.Pow(b[i], 2d); 85 } 86 87 public static void Sqrt(double[] a, double[] b) { 88 for (int i = 0; i < BATCHSIZE; ++i) 89 a[i] = Math.Sqrt(b[i]); 90 } 66 91 } 67 92 } -
stable/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Interpreter/SymbolicDataAnalysisExpressionTreeBatchInterpreter.cs
r16287 r17071 11 11 12 12 using static HeuristicLab.Problems.DataAnalysis.Symbolic.BatchOperations; 13 //using static HeuristicLab.Problems.DataAnalysis.Symbolic.BatchOperationsVector;14 13 15 14 namespace HeuristicLab.Problems.DataAnalysis.Symbolic { … … 65 64 break; 66 65 } 66 67 67 case OpCodes.Add: { 68 68 Load(instr.buf, code[c].buf); … … 76 76 if (n == 1) { 77 77 Neg(instr.buf, code[c].buf); 78 break;79 78 } else { 80 79 Load(instr.buf, code[c].buf); … … 82 81 Sub(instr.buf, code[c + j].buf); 83 82 } 84 break;85 }83 } 84 break; 86 85 } 87 86 … … 97 96 if (n == 1) { 98 97 Inv(instr.buf, code[c].buf); 99 break;100 98 } else { 101 99 Load(instr.buf, code[c].buf); … … 103 101 Div(instr.buf, code[c + j].buf); 104 102 } 105 break; 106 } 103 } 104 break; 105 } 106 107 case OpCodes.Square: { 108 Square(instr.buf, code[c].buf); 109 break; 110 } 111 112 case OpCodes.Root: { 113 Root(instr.buf, code[c].buf); 114 break; 115 } 116 117 case OpCodes.SquareRoot: { 118 Sqrt(instr.buf, code[c].buf); 119 break; 120 } 121 122 case OpCodes.Power: { 123 Pow(instr.buf, code[c].buf); 124 break; 107 125 } 108 126 … … 116 134 break; 117 135 } 136 137 case OpCodes.Sin: { 138 Sin(instr.buf, code[c].buf); 139 break; 140 } 141 142 case OpCodes.Cos: { 143 Cos(instr.buf, code[c].buf); 144 break; 145 } 146 147 case OpCodes.Tan: { 148 Tan(instr.buf, code[c].buf); 149 break; 150 } 118 151 } 119 152 } 153 } 154 155 [ThreadStatic] 156 private Dictionary<string, double[]> cachedData; 157 158 private void InitCache(IDataset dataset) { 159 cachedData = new Dictionary<string, double[]>(); 160 foreach (var v in dataset.DoubleVariables) { 161 var values = dataset.GetDoubleValues(v).ToArray(); 162 } 163 } 164 165 public void InitializeState() { 166 cachedData = null; 167 EvaluatedSolutions = 0; 120 168 } 121 169 122 170 private double[] GetValues(ISymbolicExpressionTree tree, IDataset dataset, int[] rows) { 123 171 var code = Compile(tree, dataset, OpCodes.MapSymbolToOpCode); 124 125 172 var remainingRows = rows.Length % BATCHSIZE; 126 173 var roundedTotal = rows.Length - remainingRows; … … 141 188 } 142 189 190 public IEnumerable<double> GetSymbolicExpressionTreeValues(ISymbolicExpressionTree tree, IDataset dataset, int[] rows) { 191 if (cachedData == null) { 192 InitCache(dataset); 193 } 194 return GetValues(tree, dataset, rows); 195 } 196 143 197 public IEnumerable<double> GetSymbolicExpressionTreeValues(ISymbolicExpressionTree tree, IDataset dataset, IEnumerable<int> rows) { 144 return GetValues(tree, dataset, rows.ToArray()); 145 } 146 147 public void InitializeState() { 198 return GetSymbolicExpressionTreeValues(tree, dataset, rows.ToArray()); 148 199 } 149 200 … … 152 203 var code = new BatchInstruction[root.GetLength()]; 153 204 if (root.SubtreeCount > ushort.MaxValue) throw new ArgumentException("Number of subtrees is too big (>65.535)"); 154 code[0] = new BatchInstruction { narg = (ushort)root.SubtreeCount, opcode = opCodeMapper(root) };155 205 int c = 1, i = 0; 156 206 foreach (var node in root.IterateNodesBreadth()) { 157 for (int j = 0; j < node.SubtreeCount; ++j) { 158 var s = node.GetSubtree(j); 159 if (s.SubtreeCount > ushort.MaxValue) throw new ArgumentException("Number of subtrees is too big (>65.535)"); 160 code[c + j] = new BatchInstruction { narg = (ushort)s.SubtreeCount, opcode = opCodeMapper(s) }; 161 } 162 163 code[i].buf = new double[BATCHSIZE]; 164 207 if (node.SubtreeCount > ushort.MaxValue) throw new ArgumentException("Number of subtrees is too big (>65.535)"); 208 code[i] = new BatchInstruction { 209 opcode = opCodeMapper(node), 210 narg = (ushort)node.SubtreeCount, 211 buf = new double[BATCHSIZE], 212 childIndex = c 213 }; 165 214 if (node is VariableTreeNode variable) { 166 215 code[i].weight = variable.Weight; 167 code[i].data = dataset.GetReadOnlyDoubleValues(variable.VariableName).ToArray(); 216 if (cachedData.ContainsKey(variable.VariableName)) { 217 code[i].data = cachedData[variable.VariableName]; 218 } else { 219 code[i].data = dataset.GetReadOnlyDoubleValues(variable.VariableName).ToArray(); 220 cachedData[variable.VariableName] = code[i].data; 221 } 168 222 } else if (node is ConstantTreeNode constant) { 169 223 code[i].value = constant.Value; … … 171 225 code[i].buf[j] = code[i].value; 172 226 } 173 174 code[i].childIndex = c;175 227 c += node.SubtreeCount; 176 228 ++i; -
stable/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Plugin.cs.frame
r15587 r17071 37 37 [PluginDependency("HeuristicLab.Data", "3.3")] 38 38 [PluginDependency("HeuristicLab.Encodings.SymbolicExpressionTreeEncoding", "3.4")] 39 [PluginDependency("HeuristicLab.NativeInterpreter", "0.1")] 39 40 [PluginDependency("HeuristicLab.Operators", "3.3")] 40 41 [PluginDependency("HeuristicLab.Optimization", "3.3")]
Note: See TracChangeset
for help on using the changeset viewer.