Changeset 16656


Ignore:
Timestamp:
03/07/19 13:30:07 (4 months ago)
Author:
gkronber
Message:

#2866: merged r16375, r16531, r16655 from branch to trunk (using "Merge two different trees" because I was not able to automatically merge changesets)

Location:
trunk/HeuristicLab.Problems.DataAnalysis.Symbolic
Files:
12 edited
1 copied

Legend:

Unmodified
Added
Removed
  • trunk/HeuristicLab.Problems.DataAnalysis.Symbolic

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

    r16565 r16656  
    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) &&
  • trunk/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Grammars/FullFunctionalExpressionGrammar.cs

    r16565 r16656  
    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      };
  • trunk/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Grammars/TypeCoherentExpressionGrammar.cs

    r16565 r16656  
    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;
  • trunk/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/HeuristicLab.Problems.DataAnalysis.Symbolic-3.4.csproj

    r16625 r16656  
    231231    <Compile Include="Symbols\Absolute.cs" />
    232232    <Compile Include="Symbols\CubeRoot.cs" />
     233    <Compile Include="Symbols\HyperbolicTangent.cs" />
    233234    <Compile Include="Symbols\VariableBase.cs" />
    234235    <Compile Include="Symbols\VariableTreeNodeBase.cs" />
  • trunk/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Importer/InfixExpressionParser.cs

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

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

    r16356 r16656  
    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) {
  • trunk/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Interpreter/OpCodes.cs

    r16565 r16656  
    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 },
  • trunk/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Interpreter/SymbolicDataAnalysisExpressionTreeBatchInterpreter.cs

    r16565 r16656  
    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);
  • trunk/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Interpreter/SymbolicDataAnalysisExpressionTreeInterpreter.cs

    r16565 r16656  
    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));
  • trunk/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Interpreter/SymbolicDataAnalysisExpressionTreeLinearInterpreter.cs

    r16565 r16656  
    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.