Changeset 15944


Ignore:
Timestamp:
05/23/18 07:13:05 (23 months ago)
Author:
gkronber
Message:

#2915 added support for Abs() symbol to tree interpreter and linear interpreter as well as to the infix parser

Location:
branches/2915-AbsoluteSymbol/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4
Files:
1 added
7 edited

Legend:

Unmodified
Added
Removed
  • branches/2915-AbsoluteSymbol/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Grammars/FullFunctionalExpressionGrammar.cs

    r15583 r15944  
    5353      var tan = new Tangent();
    5454      var log = new Logarithm();
     55      var abs = new Absolute();
    5556      var pow = new Power();
    5657      pow.InitialFrequency = 0.0;
     
    123124      autoregressiveVariable.Enabled = false;
    124125
    125       var allSymbols = new List<Symbol>() { add, sub, mul, div, mean, sin, cos, tan, log, square, pow, sqrt, root, exp,
     126      var allSymbols = new List<Symbol>() { add, sub, mul, div, mean, abs, sin, cos, tan, log, square, pow, sqrt, root, exp,
    126127        airyA, airyB, bessel, cosineIntegral, dawson, erf, expIntegralEi, fresnelCosineIntegral, fresnelSineIntegral, gamma, hypCosineIntegral, hypSineIntegral, norm, psi, sineIntegral,
    127128        @if, gt, lt, and, or, not,xor, timeLag, integral, derivative, constant, variableSymbol, binFactorVariable, factorVariable, laggedVariable,autoregressiveVariable, variableCondition };
    128       var unaryFunctionSymbols = new List<Symbol>() { square, sqrt, sin, cos, tan, log, exp, not, timeLag, integral, derivative,
     129      var unaryFunctionSymbols = new List<Symbol>() { abs, square, sqrt, sin, cos, tan, log, exp, not, timeLag, integral, derivative,
    129130        airyA, airyB, bessel, cosineIntegral, dawson, erf, expIntegralEi, fresnelCosineIntegral, fresnelSineIntegral, gamma, hypCosineIntegral, hypSineIntegral, norm, psi, sineIntegral
    130131      };
  • branches/2915-AbsoluteSymbol/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Grammars/TypeCoherentExpressionGrammar.cs

    r15583 r15944  
    7070      var sqrt = new SquareRoot();
    7171      var exp = new Exponential();
     72      var abs = new Absolute();
    7273
    7374      var airyA = new AiryA();
     
    111112
    112113      #region group symbol declaration
    113       var arithmeticSymbols = new GroupSymbol(ArithmeticFunctionsName, new List<ISymbol>() { add, sub, mul, div, mean });
     114      var arithmeticSymbols = new GroupSymbol(ArithmeticFunctionsName, new List<ISymbol>() { add, sub, mul, div, mean, abs });
    114115      var trigonometricSymbols = new GroupSymbol(TrigonometricFunctionsName, new List<ISymbol>() { sin, cos, tan });
    115116      var exponentialAndLogarithmicSymbols = new GroupSymbol(ExponentialFunctionsName, new List<ISymbol> { exp, log });
     
    231232    public void ConfigureAsDefaultRegressionGrammar() {
    232233      Symbols.First(s => s is Average).Enabled = false;
     234      Symbols.First(s => s is Absolute).Enabled = false;
    233235      Symbols.First(s => s.Name == TrigonometricFunctionsName).Enabled = false;
    234236      Symbols.First(s => s.Name == PowerFunctionsName).Enabled = false;
     
    242244      Symbols.First(s => s is VariableCondition).Enabled = false;
    243245      Symbols.First(s => s is Xor).Enabled = false;
     246      Symbols.First(s => s is Absolute).Enabled = false;
    244247      Symbols.First(s => s.Name == TrigonometricFunctionsName).Enabled = false;
    245248      Symbols.First(s => s.Name == ExponentialFunctionsName).Enabled = false;
     
    251254    public void ConfigureAsDefaultTimeSeriesPrognosisGrammar() {
    252255      Symbols.First(s => s is Average).Enabled = false;
     256      Symbols.First(s => s is Absolute).Enabled = false;
    253257      Symbols.First(s => s.Name == TrigonometricFunctionsName).Enabled = false;
    254258      Symbols.First(s => s.Name == PowerFunctionsName).Enabled = false;
  • branches/2915-AbsoluteSymbol/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/HeuristicLab.Problems.DataAnalysis.Symbolic-3.4.csproj

    r15902 r15944  
    210210    <Compile Include="Symbols\FactorVariableTreeNode.cs" />
    211211    <Compile Include="Symbols\FactorVariable.cs" />
     212    <Compile Include="Symbols\Absolute.cs" />
    212213    <Compile Include="Symbols\VariableBase.cs" />
    213214    <Compile Include="Symbols\VariableTreeNodeBase.cs" />
  • branches/2915-AbsoluteSymbol/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Importer/InfixExpressionParser.cs

    r15583 r15944  
    9595        { "*", new Multiplication()},
    9696        { "-", new Subtraction()},
     97        { "ABS", new Absolute() },
    9798        { "EXP", new Exponential()},
    9899        { "LOG", new Logarithm()},
  • branches/2915-AbsoluteSymbol/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Interpreter/OpCodes.cs

    r15583 r15944  
    8585    public const byte FactorVariable = 46;
    8686    public const byte BinaryFactorVariable = 47;
     87    public const byte Absolute = 48;
    8788
    8889
     
    113114      { typeof(Power),OpCodes.Power},
    114115      { typeof(Root),OpCodes.Root},
    115       { typeof(TimeLag), OpCodes.TimeLag}, 
     116      { typeof(TimeLag), OpCodes.TimeLag},
    116117      { typeof(Integral), OpCodes.Integral},
    117118      { typeof(Derivative), OpCodes.Derivative},
     
    135136      { typeof(Bessel), OpCodes.Bessel},
    136137      { typeof(FactorVariable), OpCodes.FactorVariable },
    137       { typeof(BinaryFactorVariable), OpCodes.BinaryFactorVariable }
     138      { typeof(BinaryFactorVariable), OpCodes.BinaryFactorVariable },
     139      {typeof(Absolute), OpCodes.Absolute }
    138140    };
    139141
  • branches/2915-AbsoluteSymbol/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Interpreter/SymbolicDataAnalysisExpressionTreeInterpreter.cs

    r15583 r15944  
    203203            return sum / currentInstr.nArguments;
    204204          }
     205        case OpCodes.Absolute: {
     206            return Math.Abs(Evaluate(dataset, ref row, state));
     207          }
    205208        case OpCodes.Cos: {
    206209            return Math.Cos(Evaluate(dataset, ref row, state));
  • branches/2915-AbsoluteSymbol/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Interpreter/SymbolicDataAnalysisExpressionTreeLinearInterpreter.cs

    r15583 r15944  
    221221          }
    222222          instr.value = s / instr.nArguments;
     223        } else if (instr.opCode == OpCodes.Absolute) {
     224          instr.value = Math.Abs(code[instr.childIndex].value);
    223225        } else if (instr.opCode == OpCodes.Cos) {
    224226          instr.value = Math.Cos(code[instr.childIndex].value);
Note: See TracChangeset for help on using the changeset viewer.