Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
12/15/21 11:50:57 (3 years ago)
Author:
gkronber
Message:

#3140: merged r18091:18131 from branch to trunk

Location:
trunk
Files:
13 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/HeuristicLab.Problems.DataAnalysis.Symbolic

  • trunk/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Interpreter/BatchInstruction.cs

    r16285 r18132  
    55    public int childIndex;
    66
    7     public double value; // for constants
     7    public double value; // for numbers and constants
    88    public double weight; // for variables
    99    public double[] buf;
  • trunk/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Interpreter/IntervalArithBoundsEstimator.cs

    r17964 r18132  
    126126            break;
    127127          }
    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);
    131132            break;
    132133          }
     
    324325        where
    325326          !(n.Symbol is Variable) &&
     327          !(n.Symbol is Number) &&
    326328          !(n.Symbol is Constant) &&
    327329          !(n.Symbol is StartSymbol) &&
  • trunk/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Interpreter/IntervalArithCompiledExpressionBoundsEstimator.cs

    r17909 r18132  
    116116        where
    117117          !(n.Symbol is Variable) &&
     118          !(n.Symbol is Number) &&
    118119          !(n.Symbol is Constant) &&
    119120          !(n.Symbol is StartSymbol) &&
     
    153154            );
    154155          }
    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)
    158160            return Expression.Constant(new Interval(v, v), typeof(Interval));
    159161          }
  • trunk/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Interpreter/IntervalInterpreter.cs

    r17993 r18132  
    186186            break;
    187187          }
     188        case OpCodes.Number: // fall through
    188189        case OpCodes.Constant: {
    189             var constTreeNode = (ConstantTreeNode)currentInstr.dynamicNode;
    190             result = new Interval(constTreeNode.Value, constTreeNode.Value);
    191             break;
     190          var numericTreeNode = (INumericTreeNode)currentInstr.dynamicNode;
     191          result = new Interval(numericTreeNode.Value, numericTreeNode.Value);
     192          break;
    192193          }
    193194        case OpCodes.Add: {
     
    324325        if (
    325326          !(n.Symbol is Variable) &&
     327          !(n.Symbol is Number) &&
    326328          !(n.Symbol is Constant) &&
    327329          !(n.Symbol is StartSymbol) &&
     
    346348        else if (n.Symbol is Power) {
    347349          // 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;
    350352        }
    351353      }
  • trunk/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Interpreter/OpCodes.cs

    r17963 r18132  
    4646    Variable = 18,
    4747    LagVariable = 19,
    48     Constant = 20,
     48    Number = 20,
    4949    Arg = 21,
    5050    Power = 22,
     
    7979    CubeRoot = 51,
    8080    Tanh = 52,
     81    Constant = 53
    8182  };
    8283  public static class OpCodes {
     
    101102    public const byte Variable = (byte)OpCode.Variable;
    102103    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;
    104106    public const byte Arg = (byte)OpCode.Arg;
    105107    public const byte Power = (byte)OpCode.Power;
     
    159161      { typeof(LaggedVariable), OpCodes.LagVariable },
    160162      { typeof(AutoregressiveTargetVariable),OpCodes.LagVariable},
     163      { typeof(Number), OpCodes.Number },
    161164      { typeof(Constant), OpCodes.Constant },
    162165      { typeof(Argument), OpCodes.Arg },
  • trunk/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Interpreter/SymbolicDataAnalysisExpressionCompiledTreeInterpreter.cs

    r17351 r18132  
    157157      #region switch opcode
    158158      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);
    162163          }
    163164        case OpCodes.Variable: {
  • trunk/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Interpreter/SymbolicDataAnalysisExpressionTreeBatchInterpreter.cs

    r17801 r18132  
    8484              break;
    8585            }
    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.
    8789          case OpCodes.Add: {
    8890              Load(instr.buf, code[c].buf);
     
    279281            cachedData[variable.VariableName] = code[i].data;
    280282          }
    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;
    283285          for (int j = 0; j < BATCHSIZE; ++j)
    284286            code[i].buf[j] = code[i].value;
  • trunk/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Interpreter/SymbolicDataAnalysisExpressionTreeILEmittingInterpreter.cs

    r17180 r18132  
    711711            return;
    712712          }
     713        case OpCodes.Number: // fall through
    713714        case OpCodes.Constant: {
    714             ConstantTreeNode constNode = (ConstantTreeNode)currentInstr.dynamicNode;
    715             il.Emit(System.Reflection.Emit.OpCodes.Ldc_R8, constNode.Value);
    716             return;
    717           }
     715          var constNode = (INumericTreeNode) currentInstr.dynamicNode;
     716          il.Emit(System.Reflection.Emit.OpCodes.Ldc_R8, constNode.Value);
     717          return;
     718        }
    718719
    719720        //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  
    496496            return ((IList<double>)currentInstr.data)[actualRow] * laggedVariableTreeNode.Weight;
    497497          }
    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        }
    502503
    503504        //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  
    416416        #region opcode switch
    417417        switch (instr.opCode) {
     418          case OpCodes.Number: // fall through
    418419          case OpCodes.Constant: {
    419               var constTreeNode = (ConstantTreeNode)instr.dynamicNode;
    420               instr.value = constTreeNode.Value;
    421               instr.skip = true; // the value is already set so this instruction should be skipped in the evaluation phase
     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
    422423            }
    423424            break;
  • trunk/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Interpreter/SymbolicDataAnalysisExpressionTreeNativeInterpreter.cs

    r17801 r18132  
    8282          code[i].weight = variable.Weight;
    8383          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;
    8686        }
    8787
Note: See TracChangeset for help on using the changeset viewer.