Changeset 4556 for branches/DataAnalysis/HeuristicLab.Problems.DataAnalysis.MultiVariate.TimeSeriesPrognosis/3.3/Symbolic
- Timestamp:
- 10/05/10 16:35:16 (14 years ago)
- Location:
- branches/DataAnalysis/HeuristicLab.Problems.DataAnalysis.MultiVariate.TimeSeriesPrognosis/3.3/Symbolic
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/DataAnalysis/HeuristicLab.Problems.DataAnalysis.MultiVariate.TimeSeriesPrognosis/3.3/Symbolic/SymbolicTimeSeriesExpressionInterpreter.cs
r4475 r4556 136 136 137 137 foreach (var row in rows) { 138 ResetVariableValues(dataset, row);138 // ResetVariableValues(dataset, row); 139 139 for (int step = 0; step < predictionHorizon; step++) { 140 140 this.row = row + step; … … 169 169 170 170 foreach (var row in rows) { 171 ResetVariableValues(dataset, row);171 // ResetVariableValues(dataset, row); 172 172 for (int step = 0; step < predictionHorizon; step++) { 173 173 this.row = row + step; … … 190 190 #endregion 191 191 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 //} 201 201 202 202 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 || 204 204 instr.opCode == OpCodes.Integral || instr.opCode == OpCodes.MovingAverage || instr.opCode == OpCodes.Differential) { 205 205 var variableTreeNode = instr.dynamicNode as VariableTreeNode; 206 206 instr.iArg0 = (ushort)dataset.GetVariableIndex(variableTreeNode.VariableName); 207 } 207 } 208 208 return instr; 209 209 } … … 349 349 var lagVariableTreeNode = currentInstr.dynamicNode as LaggedVariableTreeNode; 350 350 int actualRow = row + lagVariableTreeNode.Lag; 351 if (actualRow < 0 || actualRow >= dataset.Rows )351 if (actualRow < 0 || actualRow >= dataset.Rows + currentPredictionHorizon) 352 352 return double.NaN; 353 353 return GetVariableValue(currentInstr.iArg0, lagVariableTreeNode.Lag) * lagVariableTreeNode.Weight; … … 355 355 case OpCodes.MovingAverage: { 356 356 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) 358 358 return double.NaN; 359 359 double sum = 0.0; … … 365 365 case OpCodes.Differential: { 366 366 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) 368 368 return double.NaN; 369 369 double y_0 = GetVariableValue(currentInstr.iArg0, diffTreeNode.Lag); 370 370 double y_1 = GetVariableValue(currentInstr.iArg0, diffTreeNode.Lag - 1); 371 371 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; 373 373 } 374 374 case OpCodes.Integral: { 375 375 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) 377 377 return double.NaN; 378 378 double sum = 0; … … 391 391 392 392 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; 396 402 } else { 397 403 return dataset[row + timeoffset, variableIndex]; -
branches/DataAnalysis/HeuristicLab.Problems.DataAnalysis.MultiVariate.TimeSeriesPrognosis/3.3/Symbolic/SymbolicTimeSeriesPrognosisSolution.cs
r4475 r4556 117 117 118 118 public IEnumerable<double[]> GetPrognosis(int t) { 119 return model.GetEstimatedValues(problemData, t, t + 1 );119 return model.GetEstimatedValues(problemData, t, t + 1, horizon); 120 120 } 121 121
Note: See TracChangeset
for help on using the changeset viewer.