- Timestamp:
- 12/15/21 11:50:57 (3 years ago)
- Location:
- trunk
- Files:
-
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk
- Property svn:mergeinfo changed
/branches/3140_NumberSymbol (added) merged: 18091,18093,18100,18112-18121,18123-18131
- Property svn:mergeinfo changed
-
trunk/HeuristicLab.Problems.DataAnalysis.Symbolic
- Property svn:mergeinfo changed
/branches/3140_NumberSymbol/HeuristicLab.Problems.DataAnalysis.Symbolic (added) merged: 18093,18100,18112-18116,18118,18121,18123-18124,18129-18130
- Property svn:mergeinfo changed
-
trunk/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Interpreter/BatchInstruction.cs
r16285 r18132 5 5 public int childIndex; 6 6 7 public double value; // for constants7 public double value; // for numbers and constants 8 8 public double weight; // for variables 9 9 public double[] buf; -
trunk/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Interpreter/IntervalArithBoundsEstimator.cs
r17964 r18132 126 126 break; 127 127 } 128 case OpCodes.Constant: { 129 var constTreeNode = (ConstantTreeNode)currentInstr.dynamicNode; 130 result = new Interval(constTreeNode.Value, constTreeNode.Value); 128 case OpCodes.Constant: // fall through 129 case OpCodes.Number: { 130 var numericTreeNode = (INumericTreeNode)currentInstr.dynamicNode; 131 result = new Interval(numericTreeNode.Value, numericTreeNode.Value); 131 132 break; 132 133 } … … 324 325 where 325 326 !(n.Symbol is Variable) && 327 !(n.Symbol is Number) && 326 328 !(n.Symbol is Constant) && 327 329 !(n.Symbol is StartSymbol) && -
trunk/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Interpreter/IntervalArithCompiledExpressionBoundsEstimator.cs
r17909 r18132 116 116 where 117 117 !(n.Symbol is Variable) && 118 !(n.Symbol is Number) && 118 119 !(n.Symbol is Constant) && 119 120 !(n.Symbol is StartSymbol) && … … 153 154 ); 154 155 } 155 case OpCodes.Constant: { 156 var v = (node as ConstantTreeNode).Value; 157 // we have to make an interval out of the constant because this may be the root of the tree (and we are expected to return an Interval) 156 case OpCodes.Constant: // fall through 157 case OpCodes.Number: { 158 var v = (node as INumericTreeNode).Value; 159 // we have to make an interval out of the number because this may be the root of the tree (and we are expected to return an Interval) 158 160 return Expression.Constant(new Interval(v, v), typeof(Interval)); 159 161 } -
trunk/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Interpreter/IntervalInterpreter.cs
r17993 r18132 186 186 break; 187 187 } 188 case OpCodes.Number: // fall through 188 189 case OpCodes.Constant: { 189 var constTreeNode = (ConstantTreeNode)currentInstr.dynamicNode;190 result = new Interval(constTreeNode.Value, constTreeNode.Value);191 190 var numericTreeNode = (INumericTreeNode)currentInstr.dynamicNode; 191 result = new Interval(numericTreeNode.Value, numericTreeNode.Value); 192 break; 192 193 } 193 194 case OpCodes.Add: { … … 324 325 if ( 325 326 !(n.Symbol is Variable) && 327 !(n.Symbol is Number) && 326 328 !(n.Symbol is Constant) && 327 329 !(n.Symbol is StartSymbol) && … … 346 348 else if (n.Symbol is Power) { 347 349 // only integer exponents are supported 348 var exp = n.GetSubtree(1) as ConstantTreeNode;349 if (exp == null || exp.Value != Math.Truncate(exp.Value)) return false;350 var exponent = n.GetSubtree(1) as INumericTreeNode; 351 if (exponent == null || exponent.Value != Math.Truncate(exponent.Value)) return false; 350 352 } 351 353 } -
trunk/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Interpreter/OpCodes.cs
r17963 r18132 46 46 Variable = 18, 47 47 LagVariable = 19, 48 Constant= 20,48 Number = 20, 49 49 Arg = 21, 50 50 Power = 22, … … 79 79 CubeRoot = 51, 80 80 Tanh = 52, 81 Constant = 53 81 82 }; 82 83 public static class OpCodes { … … 101 102 public const byte Variable = (byte)OpCode.Variable; 102 103 public const byte LagVariable = (byte)OpCode.LagVariable; 103 public const byte Constant = (byte)OpCode.Constant; 104 public const byte Number = (byte)OpCode.Number; 105 public const byte Constant = (byte) OpCode.Constant; 104 106 public const byte Arg = (byte)OpCode.Arg; 105 107 public const byte Power = (byte)OpCode.Power; … … 159 161 { typeof(LaggedVariable), OpCodes.LagVariable }, 160 162 { typeof(AutoregressiveTargetVariable),OpCodes.LagVariable}, 163 { typeof(Number), OpCodes.Number }, 161 164 { typeof(Constant), OpCodes.Constant }, 162 165 { typeof(Argument), OpCodes.Arg }, -
trunk/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Interpreter/SymbolicDataAnalysisExpressionCompiledTreeInterpreter.cs
r17351 r18132 157 157 #region switch opcode 158 158 switch (opcode) { 159 case OpCodes.Constant: { 160 var constantTreeNode = (ConstantTreeNode)node; 161 return Expression.Constant(constantTreeNode.Value); 159 case OpCodes.Constant: // fall through 160 case OpCodes.Number: { 161 var numberTreeNode = (INumericTreeNode)node; 162 return Expression.Constant(numberTreeNode.Value); 162 163 } 163 164 case OpCodes.Variable: { -
trunk/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Interpreter/SymbolicDataAnalysisExpressionTreeBatchInterpreter.cs
r17801 r18132 84 84 break; 85 85 } 86 case OpCodes.Constant: break; // nothing to do here, don't remove because we want to prevent falling into the default case here. 86 case OpCodes.Constant: // fall through 87 case OpCodes.Number: 88 break; // nothing to do here, don't remove because we want to prevent falling into the default case here. 87 89 case OpCodes.Add: { 88 90 Load(instr.buf, code[c].buf); … … 279 281 cachedData[variable.VariableName] = code[i].data; 280 282 } 281 } else if (node is ConstantTreeNode constant) {282 code[i].value = constant.Value;283 } else if (node is INumericTreeNode numeric) { 284 code[i].value = numeric.Value; 283 285 for (int j = 0; j < BATCHSIZE; ++j) 284 286 code[i].buf[j] = code[i].value; -
trunk/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Interpreter/SymbolicDataAnalysisExpressionTreeILEmittingInterpreter.cs
r17180 r18132 711 711 return; 712 712 } 713 case OpCodes.Number: // fall through 713 714 case OpCodes.Constant: { 714 ConstantTreeNode constNode = (ConstantTreeNode)currentInstr.dynamicNode;715 716 717 715 var constNode = (INumericTreeNode) currentInstr.dynamicNode; 716 il.Emit(System.Reflection.Emit.OpCodes.Ldc_R8, constNode.Value); 717 return; 718 } 718 719 719 720 //mkommend: this symbol uses the logistic function f(x) = 1 / (1 + e^(-alpha * x) ) -
trunk/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Interpreter/SymbolicDataAnalysisExpressionTreeInterpreter.cs
r17180 r18132 496 496 return ((IList<double>)currentInstr.data)[actualRow] * laggedVariableTreeNode.Weight; 497 497 } 498 case OpCodes.Constant: { 499 var constTreeNode = (ConstantTreeNode)currentInstr.dynamicNode; 500 return constTreeNode.Value; 501 } 498 case OpCodes.Constant: // fall through 499 case OpCodes.Number: { 500 var numericTreeNode = (INumericTreeNode) currentInstr.dynamicNode; 501 return numericTreeNode.Value; 502 } 502 503 503 504 //mkommend: this symbol uses the logistic function f(x) = 1 / (1 + e^(-alpha * x) ) -
trunk/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Interpreter/SymbolicDataAnalysisExpressionTreeLinearInterpreter.cs
r17180 r18132 416 416 #region opcode switch 417 417 switch (instr.opCode) { 418 case OpCodes.Number: // fall through 418 419 case OpCodes.Constant: { 419 var constTreeNode = (ConstantTreeNode)instr.dynamicNode;420 instr.value = constTreeNode.Value;421 420 var numericTreeNode = (INumericTreeNode)instr.dynamicNode; 421 instr.value = numericTreeNode.Value; 422 instr.skip = true; // the value is already set so this instruction should be skipped in the evaluation phase 422 423 } 423 424 break; -
trunk/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Interpreter/SymbolicDataAnalysisExpressionTreeNativeInterpreter.cs
r17801 r18132 82 82 code[i].weight = variable.Weight; 83 83 code[i].data = cachedData[variable.VariableName].AddrOfPinnedObject(); 84 } else if (node is ConstantTreeNode constant) {85 code[i].value = constant.Value;84 } else if (node is INumericTreeNode numeric) { 85 code[i].value = numeric.Value; 86 86 } 87 87
Note: See TracChangeset
for help on using the changeset viewer.