Changeset 17687 for branches/1837_Sliding Window GP/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Interpreter/OpCodes.cs
- Timestamp:
- 07/19/20 19:07:40 (4 years ago)
- Location:
- branches/1837_Sliding Window GP/HeuristicLab.Problems.DataAnalysis.Symbolic
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/1837_Sliding Window GP/HeuristicLab.Problems.DataAnalysis.Symbolic
- Property svn:mergeinfo changed
-
branches/1837_Sliding Window GP/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Interpreter/OpCodes.cs
r9708 r17687 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-2013Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. … … 22 22 using System; 23 23 using System.Collections.Generic; 24 using System.Linq; 24 25 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding; 25 26 26 27 namespace HeuristicLab.Problems.DataAnalysis.Symbolic { 28 public enum OpCode : byte { 29 Add = 1, 30 Sub = 2, 31 Mul = 3, 32 Div = 4, 33 Sin = 5, 34 Cos = 6, 35 Tan = 7, 36 Log = 8, 37 Exp = 9, 38 IfThenElse = 10, 39 GT = 11, 40 LT = 12, 41 AND = 13, 42 OR = 14, 43 NOT = 15, 44 Average = 16, 45 Call = 17, 46 Variable = 18, 47 LagVariable = 19, 48 Constant = 20, 49 Arg = 21, 50 Power = 22, 51 Root = 23, 52 TimeLag = 24, 53 Integral = 25, 54 Derivative = 26, 55 VariableCondition = 27, 56 Square = 28, 57 SquareRoot = 29, 58 Gamma = 30, 59 Psi = 31, 60 Dawson = 32, 61 ExponentialIntegralEi = 33, 62 CosineIntegral = 34, 63 SineIntegral = 35, 64 HyperbolicCosineIntegral = 36, 65 HyperbolicSineIntegral = 37, 66 FresnelCosineIntegral = 38, 67 FresnelSineIntegral = 39, 68 AiryA = 40, 69 AiryB = 41, 70 Norm = 42, 71 Erf = 43, 72 Bessel = 44, 73 XOR = 45, 74 FactorVariable = 46, 75 BinaryFactorVariable = 47, 76 Absolute = 48, 77 AnalyticQuotient = 49, 78 Cube = 50, 79 CubeRoot = 51, 80 Tanh = 52, 81 }; 27 82 public static class OpCodes { 28 public const byte Add = 1; 29 public const byte Sub = 2; 30 public const byte Mul = 3; 31 public const byte Div = 4; 83 // constants for API compatibility only 84 public const byte Add = (byte)OpCode.Add; 85 public const byte Sub =(byte)OpCode.Sub; 86 public const byte Mul =(byte)OpCode.Mul; 87 public const byte Div =(byte)OpCode.Div; 88 public const byte Sin =(byte)OpCode.Sin; 89 public const byte Cos =(byte)OpCode.Cos; 90 public const byte Tan =(byte)OpCode.Tan; 91 public const byte Log =(byte)OpCode.Log; 92 public const byte Exp = (byte)OpCode.Exp; 93 public const byte IfThenElse = (byte)OpCode.IfThenElse; 94 public const byte GT = (byte)OpCode.GT; 95 public const byte LT = (byte)OpCode.LT; 96 public const byte AND = (byte)OpCode.AND; 97 public const byte OR = (byte)OpCode.OR; 98 public const byte NOT = (byte)OpCode.NOT; 99 public const byte Average = (byte)OpCode.Average; 100 public const byte Call = (byte)OpCode.Call; 101 public const byte Variable = (byte)OpCode.Variable; 102 public const byte LagVariable = (byte)OpCode.LagVariable; 103 public const byte Constant = (byte)OpCode.Constant; 104 public const byte Arg = (byte)OpCode.Arg; 105 public const byte Power = (byte)OpCode.Power; 106 public const byte Root = (byte)OpCode.Root; 107 public const byte TimeLag = (byte)OpCode.TimeLag; 108 public const byte Integral = (byte)OpCode.Integral; 109 public const byte Derivative = (byte)OpCode.Derivative; 110 public const byte VariableCondition = (byte)OpCode.VariableCondition; 111 public const byte Square = (byte)OpCode.Square; 112 public const byte SquareRoot = (byte)OpCode.SquareRoot; 113 public const byte Gamma = (byte)OpCode.Gamma; 114 public const byte Psi = (byte)OpCode.Psi; 115 public const byte Dawson = (byte)OpCode.Dawson; 116 public const byte ExponentialIntegralEi = (byte)OpCode.ExponentialIntegralEi; 117 public const byte CosineIntegral = (byte)OpCode.CosineIntegral; 118 public const byte SineIntegral = (byte)OpCode.SineIntegral; 119 public const byte HyperbolicCosineIntegral = (byte)OpCode.HyperbolicCosineIntegral; 120 public const byte HyperbolicSineIntegral = (byte)OpCode.HyperbolicSineIntegral; 121 public const byte FresnelCosineIntegral = (byte)OpCode.FresnelCosineIntegral; 122 public const byte FresnelSineIntegral = (byte)OpCode.FresnelSineIntegral; 123 public const byte AiryA = (byte)OpCode.AiryA; 124 public const byte AiryB = (byte)OpCode.AiryB; 125 public const byte Norm = (byte)OpCode.Norm; 126 public const byte Erf = (byte)OpCode.Erf; 127 public const byte Bessel = (byte)OpCode.Bessel; 128 public const byte XOR = (byte)OpCode.XOR; 129 public const byte FactorVariable = (byte)OpCode.FactorVariable; 130 public const byte BinaryFactorVariable = (byte)OpCode.BinaryFactorVariable; 131 public const byte Absolute = (byte)OpCode.Absolute; 132 public const byte AnalyticQuotient = (byte)OpCode.AnalyticQuotient; 133 public const byte Cube = (byte)OpCode.Cube; 134 public const byte CubeRoot = (byte)OpCode.CubeRoot; 135 public const byte Tanh = (byte)OpCode.Tanh; 32 136 33 public const byte Sin = 5;34 public const byte Cos = 6;35 public const byte Tan = 7;36 37 public const byte Log = 8;38 public const byte Exp = 9;39 40 public const byte IfThenElse = 10;41 42 public const byte GT = 11;43 public const byte LT = 12;44 45 public const byte AND = 13;46 public const byte OR = 14;47 public const byte NOT = 15;48 49 50 public const byte Average = 16;51 52 public const byte Call = 17;53 54 public const byte Variable = 18;55 public const byte LagVariable = 19;56 public const byte Constant = 20;57 public const byte Arg = 21;58 59 public const byte Power = 22;60 public const byte Root = 23;61 public const byte TimeLag = 24;62 public const byte Integral = 25;63 public const byte Derivative = 26;64 65 public const byte VariableCondition = 27;66 67 public const byte Square = 28;68 public const byte SquareRoot = 29;69 public const byte Gamma = 30;70 public const byte Psi = 31;71 public const byte Dawson = 32;72 public const byte ExponentialIntegralEi = 33;73 public const byte CosineIntegral = 34;74 public const byte SineIntegral = 35;75 public const byte HyperbolicCosineIntegral = 36;76 public const byte HyperbolicSineIntegral = 37;77 public const byte FresnelCosineIntegral = 38;78 public const byte FresnelSineIntegral = 39;79 public const byte AiryA = 40;80 public const byte AiryB = 41;81 public const byte Norm = 42;82 public const byte Erf = 43;83 public const byte Bessel = 44;84 137 85 138 private static Dictionary<Type, byte> symbolToOpcode = new Dictionary<Type, byte>() { … … 91 144 { typeof(Cosine), OpCodes.Cos }, 92 145 { typeof(Tangent), OpCodes.Tan }, 146 { typeof (HyperbolicTangent), OpCodes.Tanh}, 93 147 { typeof(Logarithm), OpCodes.Log }, 94 148 { typeof(Exponential), OpCodes.Exp }, … … 99 153 { typeof(Or), OpCodes.OR }, 100 154 { typeof(Not), OpCodes.NOT}, 155 { typeof(Xor),OpCodes.XOR}, 101 156 { typeof(Average), OpCodes.Average}, 102 157 { typeof(InvokeFunction), OpCodes.Call }, … … 108 163 { typeof(Power),OpCodes.Power}, 109 164 { typeof(Root),OpCodes.Root}, 110 { typeof(TimeLag), OpCodes.TimeLag}, 165 { typeof(TimeLag), OpCodes.TimeLag}, 111 166 { typeof(Integral), OpCodes.Integral}, 112 167 { typeof(Derivative), OpCodes.Derivative}, … … 128 183 { typeof(Norm), OpCodes.Norm}, 129 184 { typeof(Erf), OpCodes.Erf}, 130 { typeof(Bessel), OpCodes.Bessel} 185 { typeof(Bessel), OpCodes.Bessel}, 186 { typeof(FactorVariable), OpCodes.FactorVariable }, 187 { typeof(BinaryFactorVariable), OpCodes.BinaryFactorVariable }, 188 { typeof(Absolute), OpCodes.Absolute }, 189 { typeof(AnalyticQuotient), OpCodes.AnalyticQuotient }, 190 { typeof(Cube), OpCodes.Cube }, 191 { typeof(CubeRoot), OpCodes.CubeRoot } 131 192 }; 132 193 133 194 public static byte MapSymbolToOpCode(ISymbolicExpressionTreeNode treeNode) { 134 byte opCode; 135 if (symbolToOpcode.TryGetValue(treeNode.Symbol.GetType(), out opCode)) return opCode; 195 if (symbolToOpcode.TryGetValue(treeNode.Symbol.GetType(), out byte opCode)) return opCode; 136 196 else throw new NotSupportedException("Symbol: " + treeNode.Symbol); 137 197 }
Note: See TracChangeset
for help on using the changeset viewer.