Free cookie consent management tool by TermsFeed Policy Generator

Changeset 4556 for branches/DataAnalysis


Ignore:
Timestamp:
10/05/10 16:35:16 (14 years ago)
Author:
gkronber
Message:

Added classes and views for analysis of symbolic time series prognosis results. #1142

Location:
branches/DataAnalysis
Files:
8 added
7 edited

Legend:

Unmodified
Added
Removed
  • branches/DataAnalysis/HeuristicLab.Problems.DataAnalysis.MultiVariate.TimeSeriesPrognosis.Views/3.3/HeuristicLab.Problems.DataAnalysis.MultiVariate.TimeSeriesPrognosis.Views-3.3.csproj

    r4463 r4556  
    9191  </PropertyGroup>
    9292  <ItemGroup>
     93    <Reference Include="HeuristicLab.Common.Resources-3.3, Version=3.2.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=x86" />
    9394    <Reference Include="System" />
    9495    <Reference Include="System.Core">
     
    108109  </ItemGroup>
    109110  <ItemGroup>
     111    <Compile Include="PrognosisView.cs">
     112      <SubType>UserControl</SubType>
     113    </Compile>
     114    <Compile Include="PrognosisView.Designer.cs">
     115      <DependentUpon>PrognosisView.cs</DependentUpon>
     116    </Compile>
    110117    <Compile Include="HeuristicLabProblemsDataAnalysisMultiVariateTimeSeriesPrognosisViewsPlugin.cs" />
    111118    <Compile Include="InteractiveSymbolicTimeSeriesPrognosisSolutionSimplifierView.cs">
     
    114121    <Compile Include="InteractiveSymbolicTimeSeriesPrognosisSolutionSimplifierView.Designer.cs">
    115122      <DependentUpon>InteractiveSymbolicTimeSeriesPrognosisSolutionSimplifierView.cs</DependentUpon>
     123    </Compile>
     124    <Compile Include="TimeSeriesPrognosisLineChartView.cs">
     125      <SubType>UserControl</SubType>
     126    </Compile>
     127    <Compile Include="TimeSeriesPrognosisLineChartView.Designer.cs">
     128      <DependentUpon>TimeSeriesPrognosisLineChartView.cs</DependentUpon>
    116129    </Compile>
    117130    <Compile Include="ResultsView.cs">
     
    206219      <Project>{23DA7FF4-D5B8-41B6-AA96-F0561D24F3EE}</Project>
    207220      <Name>HeuristicLab.Operators-3.3</Name>
     221    </ProjectReference>
     222    <ProjectReference Include="..\..\HeuristicLab.Optimization.Views\3.3\HeuristicLab.Optimization.Views-3.3.csproj">
     223      <Project>{662B4B15-8F4D-4AE5-B3EB-D91C215F5AF2}</Project>
     224      <Name>HeuristicLab.Optimization.Views-3.3</Name>
    208225    </ProjectReference>
    209226    <ProjectReference Include="..\..\HeuristicLab.Optimization\3.3\HeuristicLab.Optimization-3.3.csproj">
  • branches/DataAnalysis/HeuristicLab.Problems.DataAnalysis.MultiVariate.TimeSeriesPrognosis.Views/3.3/ResultsView.cs

    r4457 r4556  
    155155          List<string> targetVariables = Content.ProblemData.TargetVariables.CheckedItems.Select(x => x.Value.Value).ToList();
    156156
    157           int timestep = 0;
    158           foreach (double[] x in Content.GetPrognosis(row)) {
    159             int targetIndex = 0;
    160             foreach (var targetVariable in targetVariables) {
    161               double originalValue = Content.ProblemData.Dataset[targetVariable, row + timestep];
    162               double estimatedValue = x[targetIndex];
    163               if (IsValidValue(originalValue) && IsValidValue(estimatedValue)) {
    164                 foreach (IOnlineEvaluator evaluator in evaluators[targetVariable]) {
    165                   evaluator.Add(originalValue, estimatedValue);
     157          if (string.IsNullOrEmpty(Content.ConditionalEvaluationVariable) ||
     158            Content.ProblemData.Dataset[Content.ConditionalEvaluationVariable, row] > 0) {
     159            int timestep = 0;
     160            foreach (double[] x in Content.GetPrognosis(row)) {
     161              int targetIndex = 0;
     162              if (row + timestep < Content.ProblemData.Dataset.Rows) {
     163                foreach (var targetVariable in targetVariables) {
     164                  double originalValue = Content.ProblemData.Dataset[targetVariable, row + timestep];
     165                  double estimatedValue = x[targetIndex];
     166                  if (IsValidValue(originalValue) && IsValidValue(estimatedValue)) {
     167                    foreach (IOnlineEvaluator evaluator in evaluators[targetVariable]) {
     168                      evaluator.Add(originalValue, estimatedValue);
     169                    }
     170                  }
     171                  targetIndex++;
    166172                }
    167173              }
    168               targetIndex++;
     174              timestep++;
    169175            }
    170             timestep++;
    171176          }
    172177        }
  • branches/DataAnalysis/HeuristicLab.Problems.DataAnalysis.MultiVariate.TimeSeriesPrognosis/3.3/Symbolic/SymbolicTimeSeriesExpressionInterpreter.cs

    r4475 r4556  
    136136
    137137      foreach (var row in rows) {
    138         ResetVariableValues(dataset, row);
     138        // ResetVariableValues(dataset, row);
    139139        for (int step = 0; step < predictionHorizon; step++) {
    140140          this.row = row + step;
     
    169169
    170170      foreach (var row in rows) {
    171         ResetVariableValues(dataset, row);
     171        // ResetVariableValues(dataset, row);
    172172        for (int step = 0; step < predictionHorizon; step++) {
    173173          this.row = row + step;
     
    190190    #endregion
    191191
    192     private void ResetVariableValues(Dataset dataset, int start) {
    193       foreach (var pair in estimatedTargetVariableValues) {
    194         int targetVariableIndex = pair.Key;
    195         double[] values = pair.Value;
    196         for (int i = 0; i < values.Length; i++) {
    197           values[i] = dataset[start + i, targetVariableIndex];
    198         }
    199       }
    200     }
     192    //private void ResetVariableValues(Dataset dataset, int start) {
     193    //  foreach (var pair in estimatedTargetVariableValues) {
     194    //    int targetVariableIndex = pair.Key;
     195    //    double[] values = pair.Value;
     196    //    for (int i = 0; i < values.Length; i++) {
     197    //      values[i] = dataset[start + i, targetVariableIndex];
     198    //    }
     199    //  }
     200    //}
    201201
    202202    private Instruction PostProcessInstruction(Instruction instr) {
    203       if (instr.opCode == OpCodes.Variable || instr.opCode == OpCodes.LagVariable || 
     203      if (instr.opCode == OpCodes.Variable || instr.opCode == OpCodes.LagVariable ||
    204204        instr.opCode == OpCodes.Integral || instr.opCode == OpCodes.MovingAverage || instr.opCode == OpCodes.Differential) {
    205205        var variableTreeNode = instr.dynamicNode as VariableTreeNode;
    206206        instr.iArg0 = (ushort)dataset.GetVariableIndex(variableTreeNode.VariableName);
    207       } 
     207      }
    208208      return instr;
    209209    }
     
    349349            var lagVariableTreeNode = currentInstr.dynamicNode as LaggedVariableTreeNode;
    350350            int actualRow = row + lagVariableTreeNode.Lag;
    351             if (actualRow < 0 || actualRow >= dataset.Rows)
     351            if (actualRow < 0 || actualRow >= dataset.Rows + currentPredictionHorizon)
    352352              return double.NaN;
    353353            return GetVariableValue(currentInstr.iArg0, lagVariableTreeNode.Lag) * lagVariableTreeNode.Weight;
     
    355355        case OpCodes.MovingAverage: {
    356356            var movingAvgTreeNode = currentInstr.dynamicNode as MovingAverageTreeNode;
    357             if (row + movingAvgTreeNode.MinTimeOffset < 0 || row + movingAvgTreeNode.MaxTimeOffset >= dataset.Rows)
     357            if (row + movingAvgTreeNode.MinTimeOffset < 0 || row + movingAvgTreeNode.MaxTimeOffset >= dataset.Rows + currentPredictionHorizon)
    358358              return double.NaN;
    359359            double sum = 0.0;
     
    365365        case OpCodes.Differential: {
    366366            var diffTreeNode = currentInstr.dynamicNode as DerivativeVariableTreeNode;
    367             if (row + diffTreeNode.Lag - 2 < 0 || row + diffTreeNode.Lag >= dataset.Rows)
     367            if (row + diffTreeNode.Lag - 2 < 0 || row + diffTreeNode.Lag >= dataset.Rows + currentPredictionHorizon)
    368368              return double.NaN;
    369369            double y_0 = GetVariableValue(currentInstr.iArg0, diffTreeNode.Lag);
    370370            double y_1 = GetVariableValue(currentInstr.iArg0, diffTreeNode.Lag - 1);
    371371            double y_2 = GetVariableValue(currentInstr.iArg0, diffTreeNode.Lag - 2);
    372             return diffTreeNode.Weight * (3 * y_0 - 4 * y_1 + 3 * y_2) / 2;
     372            return diffTreeNode.Weight * (y_0 - 4 * y_1 + 3 * y_2) / 2;
    373373          }
    374374        case OpCodes.Integral: {
    375375            var integralVarTreeNode = currentInstr.dynamicNode as IntegratedVariableTreeNode;
    376             if (row + integralVarTreeNode.MinTimeOffset < 0 || row + integralVarTreeNode.MaxTimeOffset >= dataset.Rows)
     376            if (row + integralVarTreeNode.MinTimeOffset < 0 || row + integralVarTreeNode.MaxTimeOffset >= dataset.Rows + currentPredictionHorizon)
    377377              return double.NaN;
    378378            double sum = 0;
     
    391391
    392392    private double GetVariableValue(int variableIndex, int timeoffset) {
    393       if (estimatedTargetVariableValues.ContainsKey(variableIndex) &&
    394                       currentPredictionHorizon + timeoffset >= 0) {
    395         return estimatedTargetVariableValues[variableIndex][currentPredictionHorizon + timeoffset];
     393      if (currentPredictionHorizon + timeoffset >= 0) {
     394        double[] values;
     395        estimatedTargetVariableValues.TryGetValue(variableIndex, out values);
     396        if (values != null) {
     397          return values[currentPredictionHorizon + timeoffset];
     398        }
     399      }
     400      if (row + timeoffset < 0 || row + timeoffset >= dataset.Rows) {
     401        return double.NaN;
    396402      } else {
    397403        return dataset[row + timeoffset, variableIndex];
  • branches/DataAnalysis/HeuristicLab.Problems.DataAnalysis.MultiVariate.TimeSeriesPrognosis/3.3/Symbolic/SymbolicTimeSeriesPrognosisSolution.cs

    r4475 r4556  
    117117
    118118    public IEnumerable<double[]> GetPrognosis(int t) {
    119       return model.GetEstimatedValues(problemData, t, t + 1);
     119      return model.GetEstimatedValues(problemData, t, t + 1, horizon);
    120120    }
    121121
  • branches/DataAnalysis/HeuristicLab.Problems.DataAnalysis.MultiVariate.Views/3.3/HeuristicLab.Problems.DataAnalysis.MultiVariate.Views-3.3.csproj

    r4463 r4556  
    9191  </PropertyGroup>
    9292  <ItemGroup>
     93    <Reference Include="HeuristicLab.Common.Resources-3.3, Version=3.2.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=x86" />
     94    <Reference Include="HeuristicLab.Optimization-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=x86" />
    9395    <Reference Include="System" />
    9496    <Reference Include="System.Core">
     
    170172      <Project>{3BD61258-31DA-4B09-89C0-4F71FEF5F05A}</Project>
    171173      <Name>HeuristicLab.MainForm-3.3</Name>
     174    </ProjectReference>
     175    <ProjectReference Include="..\..\HeuristicLab.Optimization.Views\3.3\HeuristicLab.Optimization.Views-3.3.csproj">
     176      <Project>{662B4B15-8F4D-4AE5-B3EB-D91C215F5AF2}</Project>
     177      <Name>HeuristicLab.Optimization.Views-3.3</Name>
    172178    </ProjectReference>
    173179    <ProjectReference Include="..\..\HeuristicLab.Persistence\3.3\HeuristicLab.Persistence-3.3.csproj">
  • branches/DataAnalysis/HeuristicLab.Problems.DataAnalysis.MultiVariate.Views/3.3/LineChartView.cs

    r4401 r4556  
    5555    private void RedrawChart() {
    5656      this.chart.Series.Clear();
    57       IEnumerable<double[]> values = Content.EstimatedValues;
    5857      if (Content != null) {
     58        IEnumerable<double[]> values = Content.EstimatedValues;
    5959        List<string> targetVariables = Content.ProblemData.TargetVariables.CheckedItems.Select(x => x.Value.Value).ToList();
    6060        for (int col = 0; col < targetVariables.Count; col++) {
  • branches/DataAnalysis/HeuristicLab.Problems.DataAnalysis.Views/3.3/Symbolic/SymbolicExpressionTreeLatexFormatter.cs

    r4327 r4556  
    7979      } else if (node.Symbol is Variable) {
    8080        var varNode = node as VariableTreeNode;
    81         strBuilder.Append(" " + varNode.VariableName + " ");
     81        strBuilder.Append(" " + varNode.ToString()+ " ");
    8282      } else if (node.Symbol is ProgramRootSymbol) {
    8383      } else if (node.Symbol is Defun) {
Note: See TracChangeset for help on using the changeset viewer.