Free cookie consent management tool by TermsFeed Policy Generator

Changeset 5373


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
Files:
3 added
7 edited
7 copied

Legend:

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

    r5163 r5373  
    1212    <AssemblyName>HeuristicLab.Analysis-3.3</AssemblyName>
    1313    <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
    14     <TargetFrameworkProfile></TargetFrameworkProfile>
     14    <TargetFrameworkProfile>
     15    </TargetFrameworkProfile>
    1516    <FileAlignment>512</FileAlignment>
    1617    <SignAssembly>true</SignAssembly>
     
    131132    <Compile Include="QualityAnalysis\BestAverageWorstQualityCalculator.cs" />
    132133    <Compile Include="QualityAnalysis\BestQualityMemorizer.cs" />
     134    <Compile Include="QualityAnalysis\QualityDistributionAnalyzer.cs" />
    133135    <Compile Include="QualityAnalysis\QualityAnalyzer.cs" />
    134136    <Compile Include="QualityAnalysis\QualityDifferenceCalculator.cs" />
  • trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.3/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding-3.3.csproj

    r5163 r5373  
    129129    <Compile Include="Interfaces\ISymbolicExpressionTreeCreator.cs" />
    130130    <Compile Include="Interfaces\ISymbolicExpressionTreeCrossover.cs" />
     131    <Compile Include="Interfaces\ISymbolicExpressionTreeNode.cs" />
    131132    <Compile Include="Manipulators\ChangeNodeTypeManipulation.cs" />
    132133    <Compile Include="Interfaces\ISymbolicExpressionTreeManipulator.cs" />
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Regression/3.3/Symbolic/SymbolicRegressionSolution.cs

    r5287 r5373  
    2626using HeuristicLab.Common;
    2727using HeuristicLab.Core;
     28using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
    2829using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2930using HeuristicLab.Problems.DataAnalysis.Symbolic.Symbols;
     
    7677
    7778    protected override void RecalculateEstimatedValues() {
    78       int minLag = 0;
    79       var laggedTreeNodes = Model.SymbolicExpressionTree.IterateNodesPrefix().OfType<LaggedVariableTreeNode>();
    80       if (laggedTreeNodes.Any())
    81         minLag = laggedTreeNodes.Min(node => node.Lag);
     79      int minLag = GetMinimumLagFromTree(Model.SymbolicExpressionTree.Root);
    8280      IEnumerable<double> calculatedValues =
    8381          from x in Model.GetEstimatedValues(ProblemData, 0 - minLag, ProblemData.Dataset.Rows)
     
    9391        yield return estimatedValues[row];
    9492    }
     93
     94    protected int GetMinimumLagFromTree(SymbolicExpressionTreeNode node) {
     95      if (node == null) return 0;
     96      int lag = 0;
     97
     98      var laggedTreeNode = node as ILaggedTreeNode;
     99      if (laggedTreeNode != null) lag += laggedTreeNode.Lag;
     100      if (node.Symbol is Derivative) lag -= 4;
     101
     102      int subtreeLag = 0;
     103      foreach (var subtree in node.SubTrees) {
     104        subtreeLag = Math.Min(subtreeLag, GetMinimumLagFromTree(subtree));
     105      }
     106      return lag + subtreeLag;
     107    }
    95108  }
    96109}
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Views/3.3/HeuristicLab.Problems.DataAnalysis.Views-3.3.csproj

    r5163 r5373  
    205205      <DependentUpon>LaggedVariableView.cs</DependentUpon>
    206206    </Compile>
     207    <Compile Include="Symbolic\Symbols\TimeLagView.cs">
     208      <SubType>UserControl</SubType>
     209    </Compile>
     210    <Compile Include="Symbolic\Symbols\TimeLagView.Designer.cs">
     211      <DependentUpon>TimeLagView.cs</DependentUpon>
     212    </Compile>
    207213    <Compile Include="Symbolic\Symbols\VariableView.cs">
    208214      <SubType>UserControl</SubType>
  • 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.