Ejemplo 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();
        }
Ejemplo 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();
        }