Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
07/07/19 23:56:22 (5 years ago)
Author:
mkommend
Message:

#2866: Merged 16656, 16668, 16670, 16701, 16702 into stable.

Location:
stable
Files:
21 edited
1 copied

Legend:

Unmodified
Added
Removed
  • stable

  • stable/HeuristicLab.Problems.DataAnalysis.Symbolic

  • stable/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Converters/TreeToAutoDiffTermConverter.cs

    r17097 r17101  
    7676      eval: Math.Tan,
    7777      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));
    7981    private static readonly Func<Term, UnaryFunc> erf = UnaryFunc.Factory(
    8082      eval: alglib.errorfunction,
     
    261263      if (node.Symbol is Tangent) {
    262264        return tan(
     265          ConvertToAutoDiff(node.GetSubtree(0)));
     266      }
     267      if (node.Symbol is HyperbolicTangent) {
     268        return tanh(
    263269          ConvertToAutoDiff(node.GetSubtree(0)));
    264270      }
     
    321327          !(n.Symbol is Cosine) &&
    322328          !(n.Symbol is Tangent) &&
     329          !(n.Symbol is HyperbolicTangent) &&
    323330          !(n.Symbol is Erf) &&
    324331          !(n.Symbol is Norm) &&
  • stable/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Formatters/SymbolicDataAnalysisExpressionCSharpFormatter.cs

    r17097 r17101  
    2626using System.Text;
    2727using System.Text.RegularExpressions;
     28using HEAL.Attic;
    2829using HeuristicLab.Common;
    2930using HeuristicLab.Core;
    3031using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
    31 using HEAL.Attic;
    3232
    3333namespace HeuristicLab.Problems.DataAnalysis.Symbolic {
     
    5656    }
    5757
    58     private string VariableName2Identifier(string name) {     
     58    private string VariableName2Identifier(string name) {
    5959      /*
    6060       * identifier-start-character:
     
    131131        } else if (node.Symbol is Tangent) {
    132132          FormatFunction(node, "Math.Tan", strBuilder);
     133        } else if (node.Symbol is HyperbolicTangent) {
     134          FormatFunction(node, "Math.Tanh", strBuilder);
    133135        } else if (node.Symbol is Square) {
    134136          FormatSquare(node, strBuilder);
  • stable/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Formatters/SymbolicDataAnalysisExpressionExcelFormatter.cs

    r17097 r17101  
    2525using System.Linq;
    2626using System.Text;
     27using HEAL.Attic;
    2728using HeuristicLab.Common;
    2829using HeuristicLab.Core;
    2930using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
    30 using HEAL.Attic;
    3131
    3232namespace HeuristicLab.Problems.DataAnalysis.Symbolic {
     
    193193        stringBuilder.Append(FormatRecursively(node.GetSubtree(0)));
    194194        stringBuilder.Append(")");
    195 
     195      } else if (symbol is HyperbolicTangent) {
     196        stringBuilder.Append("TANH(");
     197        stringBuilder.Append(FormatRecursively(node.GetSubtree(0)));
     198        stringBuilder.Append(")");
    196199      } else if (symbol is Variable) {
    197200        VariableTreeNode variableTreeNode = node as VariableTreeNode;
  • stable/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Formatters/SymbolicDataAnalysisExpressionLatexFormatter.cs

    r17097 r17101  
    2424using System.Linq;
    2525using System.Text;
     26using HEAL.Attic;
    2627using HeuristicLab.Common;
    2728using HeuristicLab.Core;
    2829using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
    29 using HEAL.Attic;
    3030
    3131namespace HeuristicLab.Problems.DataAnalysis.Symbolic {
     
    137137      } else if (node.Symbol is Tangent) {
    138138        strBuilder.Append(@"\tan \left( ");
     139      } else if (node.Symbol is HyperbolicTangent) {
     140        strBuilder.Append(@"\tanh \left( ");
    139141      } else if (node.Symbol is AiryA) {
    140142        strBuilder.Append(@"\operatorname{airy}_a \left( ");
     
    303305      } else if (node.Symbol is Tangent) {
    304306        throw new InvalidOperationException();
     307      } else if (node.Symbol is HyperbolicTangent) {
     308        throw new InvalidOperationException();
    305309      } else if (node.Symbol is AiryA) {
    306310        throw new InvalidOperationException();
     
    399403      } else if (node.Symbol is Tangent) {
    400404        strBuilder.Append(@" \right) ");
     405      } else if (node.Symbol is HyperbolicTangent) {
     406        strBuilder.Append(@" \right) ");
    401407      } else if (node.Symbol is AiryA) {
    402408        strBuilder.Append(@" \right) ");
  • stable/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Formatters/SymbolicDataAnalysisExpressionMATLABFormatter.cs

    r17097 r17101  
    2323using System.Linq;
    2424using System.Text;
     25using HEAL.Attic;
    2526using HeuristicLab.Common;
    2627using HeuristicLab.Core;
    2728using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
    28 using HEAL.Attic;
    2929
    3030namespace HeuristicLab.Problems.DataAnalysis.Symbolic {
     
    252252      } else if (symbol is Tangent) {
    253253        stringBuilder.Append("tan(");
     254        stringBuilder.Append(FormatRecursively(node.GetSubtree(0)));
     255        stringBuilder.Append(")");
     256      } else if (symbol is HyperbolicTangent) {
     257        stringBuilder.Append("tanh(");
    254258        stringBuilder.Append(FormatRecursively(node.GetSubtree(0)));
    255259        stringBuilder.Append(")");
  • stable/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Formatters/SymbolicDataAnalysisExpressionMathematicaFormatter.cs

    r17097 r17101  
    2424using System.Linq;
    2525using System.Text;
     26using HEAL.Attic;
    2627using HeuristicLab.Common;
    2728using HeuristicLab.Core;
    2829using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
    29 using HEAL.Attic;
    3030
    3131namespace HeuristicLab.Problems.DataAnalysis.Symbolic {
     
    7070        } else if (node.Symbol is Tangent) {
    7171          FormatFunction(node, "Tan", strBuilder);
     72        } else if (node.Symbol is HyperbolicTangent) {
     73          FormatFunction(node, "Tanh", strBuilder);
    7274        } else if (node.Symbol is Exponential) {
    7375          FormatFunction(node, "Exp", strBuilder);
  • stable/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Formatters/SymbolicDataAnalysisExpressionSmalltalkFormatter.cs

    r17097 r17101  
    160160        stringBuilder.Append(FormatRecursively(node.GetSubtree(0)));
    161161        stringBuilder.Append(" tan");
     162      } else if (symbol is HyperbolicTangent) {
     163        stringBuilder.Append(FormatRecursively(node.GetSubtree(0)));
     164        stringBuilder.Append(" tanh");
    162165      } else if (symbol is Variable) {
    163166        VariableTreeNode variableTreeNode = node as VariableTreeNode;
  • stable/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Grammars/FullFunctionalExpressionGrammar.cs

    r17097 r17101  
    5555      var log = new Logarithm();
    5656      var abs = new Absolute();
     57      var tanh = new HyperbolicTangent();
    5758      var pow = new Power();
    5859      pow.InitialFrequency = 0.0;
     
    129130      autoregressiveVariable.Enabled = false;
    130131
    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,
    132133        airyA, airyB, bessel, cosineIntegral, dawson, erf, expIntegralEi, fresnelCosineIntegral, fresnelSineIntegral, gamma, hypCosineIntegral, hypSineIntegral, norm, psi, sineIntegral,
    133134        @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,
    135136        airyA, airyB, bessel, cosineIntegral, dawson, erf, expIntegralEi, fresnelCosineIntegral, fresnelSineIntegral, gamma, hypCosineIntegral, hypSineIntegral, norm, psi, sineIntegral
    136137      };
  • stable/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Grammars/TypeCoherentExpressionGrammar.cs

    r17097 r17101  
    8585      var gamma = new Gamma();
    8686      var hypCosineIntegral = new HyperbolicCosineIntegral();
     87      var tanh = new HyperbolicTangent();
    8788      var hypSineIntegral = new HyperbolicSineIntegral();
    8889      var norm = new Norm();
     
    116117      #region group symbol declaration
    117118      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});
    120121      var specialFunctions = new GroupSymbol(SpecialFunctionsName, new List<ISymbol> { abs, airyA, airyB, bessel, cosineIntegral, dawson, erf, expIntegralEi,
    121122        fresnelCosineIntegral,fresnelSineIntegral,gamma,hypCosineIntegral,hypSineIntegral,norm, psi, sineIntegral, analyticalQuotient});
     
    242243      Symbols.First(s => s is Average).Enabled = false;
    243244      Symbols.First(s => s is Absolute).Enabled = false;
     245      Symbols.First(s => s is HyperbolicTangent).Enabled = false;
    244246      Symbols.First(s => s.Name == TrigonometricFunctionsName).Enabled = false;
    245247      Symbols.First(s => s.Name == PowerFunctionsName).Enabled = false;
     
    254256      Symbols.First(s => s is Xor).Enabled = false;
    255257      Symbols.First(s => s is Absolute).Enabled = false;
     258      Symbols.First(s => s is HyperbolicTangent).Enabled = false;
    256259      Symbols.First(s => s.Name == TrigonometricFunctionsName).Enabled = false;
    257260      Symbols.First(s => s.Name == ExponentialFunctionsName).Enabled = false;
     
    264267      Symbols.First(s => s is Average).Enabled = false;
    265268      Symbols.First(s => s is Absolute).Enabled = false;
     269      Symbols.First(s => s is HyperbolicTangent).Enabled = false;
    266270      Symbols.First(s => s.Name == TrigonometricFunctionsName).Enabled = false;
    267271      Symbols.First(s => s.Name == PowerFunctionsName).Enabled = false;
  • stable/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/HeuristicLab.Problems.DataAnalysis.Symbolic-3.4.csproj

    r17099 r17101  
    239239    <Compile Include="Symbols\Absolute.cs" />
    240240    <Compile Include="Symbols\CubeRoot.cs" />
     241    <Compile Include="Symbols\HyperbolicTangent.cs" />
    241242    <Compile Include="Symbols\VariableBase.cs" />
    242243    <Compile Include="Symbols\VariableTreeNodeBase.cs" />
  • stable/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Importer/InfixExpressionParser.cs

    r17097 r17101  
    111111        { "COS", new Cosine()},
    112112        { "TAN", new Tangent()},
     113        { "TANH", new HyperbolicTangent()},
    113114        { "AIRYA", new AiryA()},
    114115        { "AIRYB", new AiryB()},
  • stable/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Importer/SymbolicExpressionImporter.cs

    r17097 r17101  
    5353        {"COS", new Cosine()},
    5454        {"TAN", new Tangent()},
     55        {"TANH", new HyperbolicTangent ()},
    5556        {"AIRYA", new AiryA()},
    5657        {"AIRYB", new AiryB()},
  • stable/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Interpreter/BatchOperations.cs

    r17072 r17101  
    6969        a[i] = Math.Tan(b[i]);
    7070    }
     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    }
    7175
    7276    public static void Pow(double[] a, double[] b) {
  • stable/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Interpreter/OpCodes.cs

    r17097 r17101  
    9090    public const byte CubeRoot = 51;
    9191
     92    public const byte Tanh = 52;
     93
    9294
    9395    private static Dictionary<Type, byte> symbolToOpcode = new Dictionary<Type, byte>() {
     
    99101      { typeof(Cosine), OpCodes.Cos },
    100102      { typeof(Tangent), OpCodes.Tan },
     103      { typeof (HyperbolicTangent), OpCodes.Tanh},
    101104      { typeof(Logarithm), OpCodes.Log },
    102105      { typeof(Exponential), OpCodes.Exp },
  • stable/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Interpreter/SymbolicDataAnalysisExpressionCompiledTreeInterpreter.cs

    r17097 r17101  
    4545    private static readonly MethodInfo Cos = typeof(Math).GetMethod("Cos", new[] { typeof(double) });
    4646    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) });
    4748    private static readonly MethodInfo Sqrt = typeof(Math).GetMethod("Sqrt", new[] { typeof(double) });
    4849    private static readonly MethodInfo Floor = typeof(Math).GetMethod("Floor", new[] { typeof(double) });
     
    223224            return Expression.Call(Tan, arg);
    224225          }
     226        case OpCodes.Tanh: {
     227            var arg = MakeExpr(node.GetSubtree(0), variableIndices, row, columns);
     228            return Expression.Call(Tanh, arg);
     229          }
    225230        case OpCodes.Square: {
    226231            var arg = MakeExpr(node.GetSubtree(0), variableIndices, row, columns);
  • stable/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Interpreter/SymbolicDataAnalysisExpressionTreeBatchInterpreter.cs

    r17097 r17101  
    159159              break;
    160160            }
    161 
     161          case OpCodes.Tanh: {
     162              Tanh(instr.buf, code[c].buf);
     163              break;
     164            }
    162165          case OpCodes.Absolute: {
    163166              Absolute(instr.buf, code[c].buf);
  • stable/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Interpreter/SymbolicDataAnalysisExpressionTreeILEmittingInterpreter.cs

    r17097 r17101  
    4545    private static MethodInfo sin = typeof(Math).GetMethod("Sin", new Type[] { typeof(double) });
    4646    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) });
    4748    private static MethodInfo exp = typeof(Math).GetMethod("Exp", new Type[] { typeof(double) });
    4849    private static MethodInfo log = typeof(Math).GetMethod("Log", new Type[] { typeof(double) });
     
    283284            CompileInstructions(il, state, ds);
    284285            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);
    285291            return;
    286292          }
  • stable/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Interpreter/SymbolicDataAnalysisExpressionTreeInterpreter.cs

    r17097 r17101  
    205205            return Math.Abs(Evaluate(dataset, ref row, state));
    206206          }
     207        case OpCodes.Tanh: {
     208            return Math.Tanh(Evaluate(dataset, ref row, state));
     209          }
    207210        case OpCodes.Cos: {
    208211            return Math.Cos(Evaluate(dataset, ref row, state));
  • stable/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Interpreter/SymbolicDataAnalysisExpressionTreeLinearInterpreter.cs

    r17097 r17101  
    226226        } else if (instr.opCode == OpCodes.Absolute) {
    227227          instr.value = Math.Abs(code[instr.childIndex].value);
     228        } else if (instr.opCode == OpCodes.Tanh) {
     229          instr.value = Math.Tanh(code[instr.childIndex].value);
    228230        } else if (instr.opCode == OpCodes.Cos) {
    229231          instr.value = Math.Cos(code[instr.childIndex].value);
Note: See TracChangeset for help on using the changeset viewer.