Esempio n. 1
0
        private void ComputeSES()
        {
            // add first value
            //SmoothenedData.Add(Demand[0]);

            // mean of first 12
            var sum = 0;

            for (int i = 0; i < 12; i++)
            {
                sum += Demand[i];
                Console.WriteLine(Demand[i]);
            }
            SmoothenedData.Add((double)sum / 12);

            // index 0 - 35
            for (int i = 1; i < Demand.Count; i++)
            {
                double smoothValue = alpha * Demand[i - 1] + (1 - alpha) * SmoothenedData[i - 1];
                SmoothenedData.Add(smoothValue);
            }

            //forecast
            // index 36 - 48
            for (int i = Demand.Count + 1; i <= Time.Count; i++)
            {
                SmoothenedData.Add(SmoothenedData.Last());
            }

            CalculateError();
        }
Esempio n. 2
0
        private void ComputeDES()
        {
            if (alpha == 0.5f && beta == 0.5f)
            {
                Console.WriteLine("test pause");
            }

            //𝒔𝒕 = 𝜢 * 𝒙𝒕 + (𝟏 βˆ’ 𝜢) * (π’”π’•βˆ’πŸ + π’ƒπ’•βˆ’πŸ)
            //𝒃𝒕 = 𝜷 * (𝒔𝒕 βˆ’ π’”π’•βˆ’πŸ) + (𝟏 βˆ’ 𝜷) * π’ƒπ’•βˆ’πŸ

            List <double> s = new List <double>();
            List <double> b = new List <double>();

            //initialisation
            s.Add(Demand[1]);             //smooth index 1
            b.Add(Demand[1] - Demand[0]); // beta index 1

            //SmoothenedData.Add(s[0] + b[0]); // t=3 == index 2

            // index 1 - 35
            for (int i = 1; i < Demand.Count - 1; i++)//begin with (index 3 == t4) compared to (index 0 of DESlist == t3)
            {
                var demand            = Demand[i + 1];
                var previousSmoothing = s[i - 1];
                var previousTrend     = b[i - 1];


                var smooth = alpha * demand + (1 - alpha) * (previousSmoothing + previousTrend);
                s.Add(smooth);

                var trend = beta * (s[i] - previousSmoothing) + (1 - beta) * previousTrend;
                b.Add(trend);

                SmoothenedData.Add(s[i - 1] + b[i - 1]); //
            }


            //forecast
            //𝒇𝒕+𝟏 = 𝒔𝒕 + 𝒃𝒕
            // index 36 - 48
            int forecastCount = 0;

            for (int i = Demand.Count + 1; i <= Time.Count; i++)
            {
                forecastCount++;

                // 𝑓𝑛+π‘š = 𝑠𝑛 + π‘šπ‘n
                //
                SmoothenedData.Add(s.Last() + (i - Demand.Count) * b.Last());
            }


            CalculateError();
        }