Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
01/25/11 16:51:30 (14 years ago)
Author:
mkommend
Message:

ticket #1256 - Merged new timeseries symbols from branch to trunk.

Location:
trunk/sources/HeuristicLab.Problems.DataAnalysis/3.3
Files:
1 added
3 edited
6 copied

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Problems.DataAnalysis/3.3/HeuristicLab.Problems.DataAnalysis-3.3.csproj

    r5333 r5373  
    108108  </ItemGroup>
    109109  <ItemGroup>
     110    <Compile Include="Symbolic\Symbols\Derivative.cs" />
     111    <Compile Include="Symbolic\Symbols\Integral.cs" />
     112    <Compile Include="Symbolic\Symbols\TimeLag.cs" />
    110113    <Compile Include="Symbolic\TypeCoherentExpressionGrammar.cs" />
    111114    <Compile Include="Symbolic\Symbols\Power.cs" />
     
    133136    <Compile Include="Evaluators\SimpleVarianceAccountedForEvaluator.cs" />
    134137    <Compile Include="HeuristicLabProblemsDataAnalysisPlugin.cs" />
     138    <Compile Include="Interfaces\ILaggedTreeNode.cs" />
    135139    <Compile Include="Interfaces\ISingleObjectiveDataAnalysisProblem.cs" />
    136140    <Compile Include="Interfaces\IDataAnalysisModel.cs" />
     
    151155    <Compile Include="Symbolic\SymbolicSimplifier.cs" />
    152156    <Compile Include="Symbolic\Symbols\Addition.cs" />
     157    <Compile Include="Symbolic\Symbols\LaggedSymbol.cs" />
    153158    <Compile Include="Symbolic\Symbols\Constant.cs" />
    154159    <Compile Include="Symbolic\Symbols\ConstantTreeNode.cs" />
     160    <Compile Include="Symbolic\Symbols\LaggedTreeNode.cs" />
    155161    <Compile Include="Symbolic\Symbols\LaggedVariable.cs" />
    156162    <Compile Include="Symbolic\Symbols\LaggedVariableTreeNode.cs" />
  • trunk/sources/HeuristicLab.Problems.DataAnalysis/3.3/Symbolic/FullFunctionalExpressionGrammar.cs

    r5288 r5373  
    6161      var or = new Or();
    6262      var not = new Not();
     63
     64      var timeLag = new TimeLag();
     65      timeLag.InitialFrequency = 0.0;
     66      var integral = new Integral();
     67      integral.InitialFrequency = 0.0;
     68      var derivative = new Derivative();
     69      derivative.InitialFrequency = 0.0;
     70
    6371      var constant = new Constant();
    6472      constant.MinValue = -20;
     
    6876      laggedVariable.InitialFrequency = 0.0;
    6977
    70       var allSymbols = new List<Symbol>() { add, sub, mul, div, mean, sin, cos, tan, log, pow, exp, @if, gt, lt, and, or, not, constant, variableSymbol, laggedVariable };
    71       var unaryFunctionSymbols = new List<Symbol>() { sin, cos, tan, log, exp, not };
     78      var allSymbols = new List<Symbol>() { add, sub, mul, div, mean, sin, cos, tan, log, pow, exp, @if, gt, lt, and, or, not, timeLag, integral, derivative, constant, variableSymbol, laggedVariable };
     79      var unaryFunctionSymbols = new List<Symbol>() { sin, cos, tan, log, exp, not, timeLag, integral, derivative };
     80
    7281      var binaryFunctionSymbols = new List<Symbol>() { pow, gt, lt };
    7382      var functionSymbols = new List<Symbol>() { add, sub, mul, div, mean, and, or };
  • trunk/sources/HeuristicLab.Problems.DataAnalysis/3.3/Symbolic/SimpleArithmeticExpressionInterpreter.cs

    r5288 r5373  
    6767
    6868      public const byte Power = 22;
     69      public const byte TimeLag = 23;
     70      public const byte Integral = 24;
     71      public const byte Derivative = 25;
    6972    }
    7073
     
    9295      { typeof(Argument), OpCodes.Arg },
    9396      { typeof(Power),OpCodes.Power},
     97      { typeof(TimeLag), OpCodes.TimeLag},
     98      { typeof(Integral), OpCodes.Integral},
     99      {typeof(Derivative), OpCodes.Derivative},
    94100    };
    95101    private const int ARGUMENT_STACK_SIZE = 1024;
     
    244250            else return -1.0;
    245251          }
     252        case OpCodes.TimeLag: {
     253            var timeLagTreeNode = (LaggedTreeNode)currentInstr.dynamicNode;
     254            if (row + timeLagTreeNode.Lag < 0 || row + timeLagTreeNode.Lag >= dataset.Rows)
     255              return double.NaN;
     256
     257            row += timeLagTreeNode.Lag;
     258            double result = Evaluate(dataset, ref row, code, ref pc, argumentStack, ref argStackPointer);
     259            row -= timeLagTreeNode.Lag;
     260            return result;
     261          }
     262        case OpCodes.Integral: {
     263            int nextPc = pc;
     264            var timeLagTreeNode = (LaggedTreeNode)currentInstr.dynamicNode;
     265            if (row + timeLagTreeNode.Lag < 0 || row + timeLagTreeNode.Lag >= dataset.Rows)
     266              return double.NaN;
     267            double sum = 0.0;
     268            for (int i = 0; i < Math.Abs(timeLagTreeNode.Lag); i++) {
     269              row += Math.Sign(timeLagTreeNode.Lag);
     270              sum += Evaluate(dataset, ref row, code, ref pc, argumentStack, ref argStackPointer);
     271              pc = nextPc;
     272            }
     273            row -= timeLagTreeNode.Lag;
     274            sum += Evaluate(dataset, ref row, code, ref pc, argumentStack, ref argStackPointer);
     275            return sum;
     276          }
     277
     278        //mkommend: derivate calculation taken from:
     279        //http://www.holoborodko.com/pavel/numerical-methods/numerical-derivative/smooth-low-noise-differentiators/
     280        //one sided smooth differentiatior, N = 4
     281        // y' = 1/8h (f_i + 2f_i-1, -2 f_i-3 - f_i-4)
     282        case OpCodes.Derivative: {
     283            if (row - 4 < 0) return double.NaN;
     284            int nextPc = pc;
     285            double f_0 = Evaluate(dataset, ref row, code, ref pc, argumentStack, ref argStackPointer); ; row--;
     286            pc = nextPc;
     287            double f_1 = Evaluate(dataset, ref row, code, ref pc, argumentStack, ref argStackPointer); ; row -= 2;
     288            pc = nextPc;
     289            double f_3 = Evaluate(dataset, ref row, code, ref pc, argumentStack, ref argStackPointer); ; row--;
     290            pc = nextPc;
     291            double f_4 = Evaluate(dataset, ref row, code, ref pc, argumentStack, ref argStackPointer); ;
     292            row += 4;
     293
     294            return (f_0 + 2 * f_1 - 2 * f_3 - f_4) / 8; // h = 1
     295          }
    246296        case OpCodes.Call: {
    247297            // evaluate sub-trees
  • trunk/sources/HeuristicLab.Problems.DataAnalysis/3.3/Symbolic/Symbols/Integral.cs

    r5052 r5373  
    2929    [StorableConstructor]
    3030    private Integral(bool deserializing) : base(deserializing) { }
    31     protected Integral(Integral original, Cloner cloner) : base(original, cloner) { }
     31    private Integral(Integral original, Cloner cloner) : base(original, cloner) { }
    3232    public override IDeepCloneable Clone(Cloner cloner) { return new Integral(this, cloner); }
    3333
Note: See TracChangeset for help on using the changeset viewer.