/// <summary> /// Aan de hand van de ingevulde kolommen van ImproveSmoothingFactor de prediction berekenen. /// </summary> /// <param name="data">Lijst van Maand waarbij de forecasting data wordt opgeslagen</param> private void AddOptimizePrediction(Dictionary <int, Forecasting> data) { var preditionValue = new PredictionVariables(); var predictionCalc = new SmoothingFormulas(); var factorValues = new FactorsVariables(); factorValues.alpha = bestAlpha; factorValues.delta = bestBeta; factorValues.gamma = bestGamma; foreach (var item in data) { int timeValue = item.Key; if (timeValue == 36) { preditionValue.tLock = item.Key; preditionValue.tTLock = item.Value.Trend; preditionValue.lTLock = item.Value.Level; } else if (timeValue > 36) { preditionValue.t = timeValue; preditionValue.sT = data[int.Parse(timeValue.ToString()) - 12].SeasonalAdjustment; Console.WriteLine("Month: " + timeValue + ", " + "Predicted Demand Value: " + predictionCalc.Prediction(preditionValue, factorValues)); data[int.Parse(timeValue.ToString())].ActualDemand = predictionCalc.Prediction(preditionValue, factorValues); } } }
/// <summary> /// Vullen kolommen van Forecasting volgens de formules /// </summary> /// <param name="data">Lijst van Maand waarbij de forecasting data wordt opgeslagen</param> private void ImproveSmoothingFactor(Dictionary <int, Forecasting> data) { var formulas = new SmoothingFormulas(); FactorsVariables newFactorsVariables = new FactorsVariables(); newFactorsVariables.alpha = alpha; newFactorsVariables.delta = beta; newFactorsVariables.gamma = gamma; SmoothingVariables newSmoothingVariables = new SmoothingVariables(); int key = -11; foreach (var item in data) { if (item.Key == 1) { //magic sequence item.Value.OneStepForecast = formulas.OneStepErrorCalc(data[0].Level, data[0].Trend, data[key].SeasonalAdjustment); item.Value.ForecastError = formulas.ForecastErrorCalc(item.Value.ActualDemand, item.Value.OneStepForecast); item.Value.SquaredError = formulas.SquardErrorCalc(item.Value.ForecastError);// debug newSmoothingVariables.forecastError = item.Value.ForecastError; newSmoothingVariables.oneStepForecastError = item.Value.OneStepForecast; newSmoothingVariables.xT = data[item.Key - 1].ActualDemand; newSmoothingVariables.lT = data[item.Key - 1].Level; newSmoothingVariables.sT = data[key].SeasonalAdjustment; newSmoothingVariables.tT = data[item.Key - 1].Trend; //TODO make formulas simple newSmoothingVariables.lT = item.Value.Level = formulas.SmoothLevelCalc(newSmoothingVariables, newFactorsVariables); newSmoothingVariables.tT = item.Value.Trend = formulas.SmoothTrendCalc(newSmoothingVariables, newFactorsVariables); newSmoothingVariables.sT = item.Value.SeasonalAdjustment = formulas.SmoothSeasonalCalc(newSmoothingVariables, newFactorsVariables); key++; } else if (item.Key > 1 && item.Key <= 36) { //magic all //Paint item.Value.OneStepForecast = formulas.OneStepErrorCalc(data[item.Key - 1].Level, data[item.Key - 1].Trend, data[key].SeasonalAdjustment); item.Value.ForecastError = formulas.ForecastErrorCalc(item.Value.ActualDemand, item.Value.OneStepForecast); item.Value.SquaredError = formulas.SquardErrorCalc(item.Value.ForecastError); newSmoothingVariables.forecastError = item.Value.ForecastError; newSmoothingVariables.oneStepForecastError = item.Value.OneStepForecast; newSmoothingVariables.xT = data[item.Key - 1].ActualDemand; newSmoothingVariables.lT = data[item.Key - 1].Level; newSmoothingVariables.sT = data[key].SeasonalAdjustment; newSmoothingVariables.tT = data[item.Key - 1].Trend; //TODO make formulas simple newSmoothingVariables.lT = item.Value.Level = formulas.SmoothLevelCalc(newSmoothingVariables, newFactorsVariables); newSmoothingVariables.tT = item.Value.Trend = formulas.SmoothTrendCalc(newSmoothingVariables, newFactorsVariables); newSmoothingVariables.sT = item.Value.SeasonalAdjustment = formulas.SmoothSeasonalCalc(newSmoothingVariables, newFactorsVariables); key++; } } }