Changeset 17101 for stable/HeuristicLab.Problems.DataAnalysis.Symbolic
- Timestamp:
- 07/07/19 23:56:22 (5 years ago)
- Location:
- stable
- Files:
-
- 21 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
stable
- Property svn:mergeinfo changed
/trunk merged: 16656,16668,16670,16701-16702
- Property svn:mergeinfo changed
-
stable/HeuristicLab.Problems.DataAnalysis.Symbolic
- Property svn:mergeinfo changed
-
stable/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Converters/TreeToAutoDiffTermConverter.cs
r17097 r17101 76 76 eval: Math.Tan, 77 77 diff: x => 1 + Math.Tan(x) * Math.Tan(x)); 78 78 private static readonly Func<Term, UnaryFunc> tanh = UnaryFunc.Factory( 79 eval: Math.Tanh, 80 diff: x => 1 - Math.Tanh(x) * Math.Tanh(x)); 79 81 private static readonly Func<Term, UnaryFunc> erf = UnaryFunc.Factory( 80 82 eval: alglib.errorfunction, … … 261 263 if (node.Symbol is Tangent) { 262 264 return tan( 265 ConvertToAutoDiff(node.GetSubtree(0))); 266 } 267 if (node.Symbol is HyperbolicTangent) { 268 return tanh( 263 269 ConvertToAutoDiff(node.GetSubtree(0))); 264 270 } … … 321 327 !(n.Symbol is Cosine) && 322 328 !(n.Symbol is Tangent) && 329 !(n.Symbol is HyperbolicTangent) && 323 330 !(n.Symbol is Erf) && 324 331 !(n.Symbol is Norm) && -
stable/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Formatters/SymbolicDataAnalysisExpressionCSharpFormatter.cs
r17097 r17101 26 26 using System.Text; 27 27 using System.Text.RegularExpressions; 28 using HEAL.Attic; 28 29 using HeuristicLab.Common; 29 30 using HeuristicLab.Core; 30 31 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding; 31 using HEAL.Attic;32 32 33 33 namespace HeuristicLab.Problems.DataAnalysis.Symbolic { … … 56 56 } 57 57 58 private string VariableName2Identifier(string name) { 58 private string VariableName2Identifier(string name) { 59 59 /* 60 60 * identifier-start-character: … … 131 131 } else if (node.Symbol is Tangent) { 132 132 FormatFunction(node, "Math.Tan", strBuilder); 133 } else if (node.Symbol is HyperbolicTangent) { 134 FormatFunction(node, "Math.Tanh", strBuilder); 133 135 } else if (node.Symbol is Square) { 134 136 FormatSquare(node, strBuilder); -
stable/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Formatters/SymbolicDataAnalysisExpressionExcelFormatter.cs
r17097 r17101 25 25 using System.Linq; 26 26 using System.Text; 27 using HEAL.Attic; 27 28 using HeuristicLab.Common; 28 29 using HeuristicLab.Core; 29 30 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding; 30 using HEAL.Attic;31 31 32 32 namespace HeuristicLab.Problems.DataAnalysis.Symbolic { … … 193 193 stringBuilder.Append(FormatRecursively(node.GetSubtree(0))); 194 194 stringBuilder.Append(")"); 195 195 } else if (symbol is HyperbolicTangent) { 196 stringBuilder.Append("TANH("); 197 stringBuilder.Append(FormatRecursively(node.GetSubtree(0))); 198 stringBuilder.Append(")"); 196 199 } else if (symbol is Variable) { 197 200 VariableTreeNode variableTreeNode = node as VariableTreeNode; -
stable/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Formatters/SymbolicDataAnalysisExpressionLatexFormatter.cs
r17097 r17101 24 24 using System.Linq; 25 25 using System.Text; 26 using HEAL.Attic; 26 27 using HeuristicLab.Common; 27 28 using HeuristicLab.Core; 28 29 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding; 29 using HEAL.Attic;30 30 31 31 namespace HeuristicLab.Problems.DataAnalysis.Symbolic { … … 137 137 } else if (node.Symbol is Tangent) { 138 138 strBuilder.Append(@"\tan \left( "); 139 } else if (node.Symbol is HyperbolicTangent) { 140 strBuilder.Append(@"\tanh \left( "); 139 141 } else if (node.Symbol is AiryA) { 140 142 strBuilder.Append(@"\operatorname{airy}_a \left( "); … … 303 305 } else if (node.Symbol is Tangent) { 304 306 throw new InvalidOperationException(); 307 } else if (node.Symbol is HyperbolicTangent) { 308 throw new InvalidOperationException(); 305 309 } else if (node.Symbol is AiryA) { 306 310 throw new InvalidOperationException(); … … 399 403 } else if (node.Symbol is Tangent) { 400 404 strBuilder.Append(@" \right) "); 405 } else if (node.Symbol is HyperbolicTangent) { 406 strBuilder.Append(@" \right) "); 401 407 } else if (node.Symbol is AiryA) { 402 408 strBuilder.Append(@" \right) "); -
stable/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Formatters/SymbolicDataAnalysisExpressionMATLABFormatter.cs
r17097 r17101 23 23 using System.Linq; 24 24 using System.Text; 25 using HEAL.Attic; 25 26 using HeuristicLab.Common; 26 27 using HeuristicLab.Core; 27 28 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding; 28 using HEAL.Attic;29 29 30 30 namespace HeuristicLab.Problems.DataAnalysis.Symbolic { … … 252 252 } else if (symbol is Tangent) { 253 253 stringBuilder.Append("tan("); 254 stringBuilder.Append(FormatRecursively(node.GetSubtree(0))); 255 stringBuilder.Append(")"); 256 } else if (symbol is HyperbolicTangent) { 257 stringBuilder.Append("tanh("); 254 258 stringBuilder.Append(FormatRecursively(node.GetSubtree(0))); 255 259 stringBuilder.Append(")"); -
stable/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Formatters/SymbolicDataAnalysisExpressionMathematicaFormatter.cs
r17097 r17101 24 24 using System.Linq; 25 25 using System.Text; 26 using HEAL.Attic; 26 27 using HeuristicLab.Common; 27 28 using HeuristicLab.Core; 28 29 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding; 29 using HEAL.Attic;30 30 31 31 namespace HeuristicLab.Problems.DataAnalysis.Symbolic { … … 70 70 } else if (node.Symbol is Tangent) { 71 71 FormatFunction(node, "Tan", strBuilder); 72 } else if (node.Symbol is HyperbolicTangent) { 73 FormatFunction(node, "Tanh", strBuilder); 72 74 } else if (node.Symbol is Exponential) { 73 75 FormatFunction(node, "Exp", strBuilder); -
stable/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Formatters/SymbolicDataAnalysisExpressionSmalltalkFormatter.cs
r17097 r17101 160 160 stringBuilder.Append(FormatRecursively(node.GetSubtree(0))); 161 161 stringBuilder.Append(" tan"); 162 } else if (symbol is HyperbolicTangent) { 163 stringBuilder.Append(FormatRecursively(node.GetSubtree(0))); 164 stringBuilder.Append(" tanh"); 162 165 } else if (symbol is Variable) { 163 166 VariableTreeNode variableTreeNode = node as VariableTreeNode; -
stable/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Grammars/FullFunctionalExpressionGrammar.cs
r17097 r17101 55 55 var log = new Logarithm(); 56 56 var abs = new Absolute(); 57 var tanh = new HyperbolicTangent(); 57 58 var pow = new Power(); 58 59 pow.InitialFrequency = 0.0; … … 129 130 autoregressiveVariable.Enabled = false; 130 131 131 var allSymbols = new List<Symbol>() { add, sub, mul, div, aq, mean, abs, sin, cos, tan, log, square, cube, pow, sqrt, cubeRoot, root, exp, 132 var allSymbols = new List<Symbol>() { add, sub, mul, div, aq, mean, abs, sin, cos, tan, log, square, cube, pow, sqrt, cubeRoot, root, exp, tanh, 132 133 airyA, airyB, bessel, cosineIntegral, dawson, erf, expIntegralEi, fresnelCosineIntegral, fresnelSineIntegral, gamma, hypCosineIntegral, hypSineIntegral, norm, psi, sineIntegral, 133 134 @if, gt, lt, and, or, not,xor, timeLag, integral, derivative, constant, variableSymbol, binFactorVariable, factorVariable, laggedVariable,autoregressiveVariable, variableCondition }; 134 var unaryFunctionSymbols = new List<Symbol>() { abs, square, sqrt, cube, cubeRoot, sin, cos, tan, log, exp, not, timeLag, integral, derivative,135 var unaryFunctionSymbols = new List<Symbol>() { abs, square, sqrt, cube, cubeRoot, sin, cos, tan, log, exp, tanh, not, timeLag, integral, derivative, 135 136 airyA, airyB, bessel, cosineIntegral, dawson, erf, expIntegralEi, fresnelCosineIntegral, fresnelSineIntegral, gamma, hypCosineIntegral, hypSineIntegral, norm, psi, sineIntegral 136 137 }; -
stable/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Grammars/TypeCoherentExpressionGrammar.cs
r17097 r17101 85 85 var gamma = new Gamma(); 86 86 var hypCosineIntegral = new HyperbolicCosineIntegral(); 87 var tanh = new HyperbolicTangent(); 87 88 var hypSineIntegral = new HyperbolicSineIntegral(); 88 89 var norm = new Norm(); … … 116 117 #region group symbol declaration 117 118 var arithmeticSymbols = new GroupSymbol(ArithmeticFunctionsName, new List<ISymbol>() { add, sub, mul, div, mean }); 118 var trigonometricSymbols = new GroupSymbol(TrigonometricFunctionsName, new List<ISymbol>() { sin, cos, tan 119 var exponentialAndLogarithmicSymbols = new GroupSymbol(ExponentialFunctionsName, new List<ISymbol> { exp, log 119 var trigonometricSymbols = new GroupSymbol(TrigonometricFunctionsName, new List<ISymbol>() { sin, cos, tan, tanh}); 120 var exponentialAndLogarithmicSymbols = new GroupSymbol(ExponentialFunctionsName, new List<ISymbol> { exp, log}); 120 121 var specialFunctions = new GroupSymbol(SpecialFunctionsName, new List<ISymbol> { abs, airyA, airyB, bessel, cosineIntegral, dawson, erf, expIntegralEi, 121 122 fresnelCosineIntegral,fresnelSineIntegral,gamma,hypCosineIntegral,hypSineIntegral,norm, psi, sineIntegral, analyticalQuotient}); … … 242 243 Symbols.First(s => s is Average).Enabled = false; 243 244 Symbols.First(s => s is Absolute).Enabled = false; 245 Symbols.First(s => s is HyperbolicTangent).Enabled = false; 244 246 Symbols.First(s => s.Name == TrigonometricFunctionsName).Enabled = false; 245 247 Symbols.First(s => s.Name == PowerFunctionsName).Enabled = false; … … 254 256 Symbols.First(s => s is Xor).Enabled = false; 255 257 Symbols.First(s => s is Absolute).Enabled = false; 258 Symbols.First(s => s is HyperbolicTangent).Enabled = false; 256 259 Symbols.First(s => s.Name == TrigonometricFunctionsName).Enabled = false; 257 260 Symbols.First(s => s.Name == ExponentialFunctionsName).Enabled = false; … … 264 267 Symbols.First(s => s is Average).Enabled = false; 265 268 Symbols.First(s => s is Absolute).Enabled = false; 269 Symbols.First(s => s is HyperbolicTangent).Enabled = false; 266 270 Symbols.First(s => s.Name == TrigonometricFunctionsName).Enabled = false; 267 271 Symbols.First(s => s.Name == PowerFunctionsName).Enabled = false; -
stable/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/HeuristicLab.Problems.DataAnalysis.Symbolic-3.4.csproj
r17099 r17101 239 239 <Compile Include="Symbols\Absolute.cs" /> 240 240 <Compile Include="Symbols\CubeRoot.cs" /> 241 <Compile Include="Symbols\HyperbolicTangent.cs" /> 241 242 <Compile Include="Symbols\VariableBase.cs" /> 242 243 <Compile Include="Symbols\VariableTreeNodeBase.cs" /> -
stable/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Importer/InfixExpressionParser.cs
r17097 r17101 111 111 { "COS", new Cosine()}, 112 112 { "TAN", new Tangent()}, 113 { "TANH", new HyperbolicTangent()}, 113 114 { "AIRYA", new AiryA()}, 114 115 { "AIRYB", new AiryB()}, -
stable/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Importer/SymbolicExpressionImporter.cs
r17097 r17101 53 53 {"COS", new Cosine()}, 54 54 {"TAN", new Tangent()}, 55 {"TANH", new HyperbolicTangent ()}, 55 56 {"AIRYA", new AiryA()}, 56 57 {"AIRYB", new AiryB()}, -
stable/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Interpreter/BatchOperations.cs
r17072 r17101 69 69 a[i] = Math.Tan(b[i]); 70 70 } 71 public static void Tanh(double[] a, double[] b) { 72 for (int i = 0; i < BATCHSIZE; ++i) 73 a[i] = Math.Tanh(b[i]); 74 } 71 75 72 76 public static void Pow(double[] a, double[] b) { -
stable/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Interpreter/OpCodes.cs
r17097 r17101 90 90 public const byte CubeRoot = 51; 91 91 92 public const byte Tanh = 52; 93 92 94 93 95 private static Dictionary<Type, byte> symbolToOpcode = new Dictionary<Type, byte>() { … … 99 101 { typeof(Cosine), OpCodes.Cos }, 100 102 { typeof(Tangent), OpCodes.Tan }, 103 { typeof (HyperbolicTangent), OpCodes.Tanh}, 101 104 { typeof(Logarithm), OpCodes.Log }, 102 105 { typeof(Exponential), OpCodes.Exp }, -
stable/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Interpreter/SymbolicDataAnalysisExpressionCompiledTreeInterpreter.cs
r17097 r17101 45 45 private static readonly MethodInfo Cos = typeof(Math).GetMethod("Cos", new[] { typeof(double) }); 46 46 private static readonly MethodInfo Tan = typeof(Math).GetMethod("Tan", new[] { typeof(double) }); 47 private static readonly MethodInfo Tanh = typeof(Math).GetMethod("Tanh", new[] { typeof(double) }); 47 48 private static readonly MethodInfo Sqrt = typeof(Math).GetMethod("Sqrt", new[] { typeof(double) }); 48 49 private static readonly MethodInfo Floor = typeof(Math).GetMethod("Floor", new[] { typeof(double) }); … … 223 224 return Expression.Call(Tan, arg); 224 225 } 226 case OpCodes.Tanh: { 227 var arg = MakeExpr(node.GetSubtree(0), variableIndices, row, columns); 228 return Expression.Call(Tanh, arg); 229 } 225 230 case OpCodes.Square: { 226 231 var arg = MakeExpr(node.GetSubtree(0), variableIndices, row, columns); -
stable/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Interpreter/SymbolicDataAnalysisExpressionTreeBatchInterpreter.cs
r17097 r17101 159 159 break; 160 160 } 161 161 case OpCodes.Tanh: { 162 Tanh(instr.buf, code[c].buf); 163 break; 164 } 162 165 case OpCodes.Absolute: { 163 166 Absolute(instr.buf, code[c].buf); -
stable/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Interpreter/SymbolicDataAnalysisExpressionTreeILEmittingInterpreter.cs
r17097 r17101 45 45 private static MethodInfo sin = typeof(Math).GetMethod("Sin", new Type[] { typeof(double) }); 46 46 private static MethodInfo tan = typeof(Math).GetMethod("Tan", new Type[] { typeof(double) }); 47 private static MethodInfo tanh = typeof(Math).GetMethod("Tanh", new Type[] { typeof(double) }); 47 48 private static MethodInfo exp = typeof(Math).GetMethod("Exp", new Type[] { typeof(double) }); 48 49 private static MethodInfo log = typeof(Math).GetMethod("Log", new Type[] { typeof(double) }); … … 283 284 CompileInstructions(il, state, ds); 284 285 il.Emit(System.Reflection.Emit.OpCodes.Call, tan); 286 return; 287 } 288 case OpCodes.Tanh: { 289 CompileInstructions(il, state, ds); 290 il.Emit(System.Reflection.Emit.OpCodes.Call, tanh); 285 291 return; 286 292 } -
stable/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Interpreter/SymbolicDataAnalysisExpressionTreeInterpreter.cs
r17097 r17101 205 205 return Math.Abs(Evaluate(dataset, ref row, state)); 206 206 } 207 case OpCodes.Tanh: { 208 return Math.Tanh(Evaluate(dataset, ref row, state)); 209 } 207 210 case OpCodes.Cos: { 208 211 return Math.Cos(Evaluate(dataset, ref row, state)); -
stable/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Interpreter/SymbolicDataAnalysisExpressionTreeLinearInterpreter.cs
r17097 r17101 226 226 } else if (instr.opCode == OpCodes.Absolute) { 227 227 instr.value = Math.Abs(code[instr.childIndex].value); 228 } else if (instr.opCode == OpCodes.Tanh) { 229 instr.value = Math.Tanh(code[instr.childIndex].value); 228 230 } else if (instr.opCode == OpCodes.Cos) { 229 231 instr.value = Math.Cos(code[instr.childIndex].value);
Note: See TracChangeset
for help on using the changeset viewer.