Esempio n. 1
0
        private void GetUnbiasedLinkPivot(int cycleTime, List <DateTime> dates)
        {
            //set the original values to compare against
            AogTotalBefore    = AogDownstreamBefore + AogUpstreamBefore;
            MaxArrivalOnGreen = AogTotalBefore;
            PaogTotalBefore   = Math.Round(AogTotalBefore / (TotalVolumeDownstream + TotalVolumeUpstream), 2) * 100;
            //add the total to the results grid
            ResultsGraph.Add(0, MaxArrivalOnGreen);
            UpstreamResultsGraph.Add(0, AogUpstreamBefore);
            DownstreamResultsGraph.Add(0, AogDownstreamBefore);

            AogUpstreamPredicted    = AogUpstreamBefore;
            AogDownstreamPredicted  = AogDownstreamBefore;
            PaogDownstreamPredicted = Math.Round(AogDownstreamBefore / TotalVolumeDownstream, 2) * 100;
            PaogUpstreamPredicted   = Math.Round(AogUpstreamBefore / TotalVolumeUpstream, 2) * 100;
            SecondsAdded            = 0;

            for (var i = 1; i <= cycleTime; i++)
            {
                double totalArrivalOnGreen = 0;
                double totalUpstreamAog    = 0;
                double totalDownstreamAog  = 0;

                for (var index = 0; index < dates.Count; index++)
                {
                    UpstreamPcd[index].LinkPivotAddSeconds(-1);
                    DownstreamPcd[index].LinkPivotAddSeconds(1);
                    totalArrivalOnGreen += UpstreamPcd[index].TotalArrivalOnGreen +
                                           DownstreamPcd[index].TotalArrivalOnGreen;
                    totalUpstreamAog   += UpstreamPcd[index].TotalArrivalOnGreen;
                    totalDownstreamAog += DownstreamPcd[index].TotalArrivalOnGreen;
                }
                //Add the total aog to the dictionary
                ResultsGraph.Add(i, totalArrivalOnGreen);
                UpstreamResultsGraph.Add(i, totalUpstreamAog);
                DownstreamResultsGraph.Add(i, totalDownstreamAog);

                if (totalArrivalOnGreen > MaxArrivalOnGreen)
                {
                    MaxArrivalOnGreen       = totalArrivalOnGreen;
                    AogUpstreamPredicted    = totalUpstreamAog;
                    AogDownstreamPredicted  = totalDownstreamAog;
                    PaogDownstreamPredicted = Math.Round(totalDownstreamAog / TotalVolumeDownstream, 2) * 100;
                    PaogUpstreamPredicted   = Math.Round(totalUpstreamAog / TotalVolumeUpstream, 2) * 100;
                    SecondsAdded            = i;
                }
            }
            //Get the link totals
            AogTotalPredicted  = MaxArrivalOnGreen;
            PaogTotalPredicted = Math.Round(AogTotalPredicted / (TotalVolumeUpstream + TotalVolumeDownstream), 2) * 100;
        }
Esempio n. 2
0
        private void GetBiasedLinkPivot(int cycleTime, double bias, string biasDirection, List <DateTime> dates)
        {
            double upstreamBias   = 1;
            double downstreamBias = 1;

            if (biasDirection == "Downstream")
            {
                downstreamBias = 1 + bias / 100;
            }
            else
            {
                upstreamBias = 1 + bias / 100;
            }
            //set the original values to compare against
            AogTotalBefore = AogDownstreamBefore * downstreamBias +
                             AogUpstreamBefore * upstreamBias;
            PaogTotalBefore =
                Math.Round(
                    AogTotalBefore / (TotalVolumeDownstream * downstreamBias + TotalVolumeUpstream * upstreamBias), 2) *
                100;
            var maxBiasArrivalOnGreen = AogTotalBefore;

            MaxArrivalOnGreen = AogDownstreamBefore + AogUpstreamBefore;


            //add the total to the results grid
            ResultsGraph.Add(0, MaxArrivalOnGreen);
            UpstreamResultsGraph.Add(0, AogUpstreamBefore * upstreamBias);
            DownstreamResultsGraph.Add(0, AogDownstreamBefore * downstreamBias);
            AogUpstreamPredicted    = AogUpstreamBefore;
            AogDownstreamPredicted  = AogDownstreamBefore;
            PaogDownstreamPredicted = Math.Round(AogDownstreamBefore / TotalVolumeDownstream, 2) * 100;
            PaogUpstreamPredicted   = Math.Round(AogUpstreamBefore / TotalVolumeUpstream, 2) * 100;
            SecondsAdded            = 0;

            for (var i = 1; i <= cycleTime; i++)
            {
                double totalBiasArrivalOnGreen = 0;
                double totalArrivalOnGreen     = 0;
                double totalUpstreamAog        = 0;
                double totalDownstreamAog      = 0;

                for (var index = 0; index < dates.Count; index++)
                {
                    UpstreamPcd[index].LinkPivotAddSeconds(-1);
                    DownstreamPcd[index].LinkPivotAddSeconds(1);
                    totalBiasArrivalOnGreen += UpstreamPcd[index].TotalArrivalOnGreen * upstreamBias +
                                               DownstreamPcd[index].TotalArrivalOnGreen * downstreamBias;
                    totalArrivalOnGreen += UpstreamPcd[index].TotalArrivalOnGreen +
                                           DownstreamPcd[index].TotalArrivalOnGreen;
                    totalUpstreamAog   += UpstreamPcd[index].TotalArrivalOnGreen;
                    totalDownstreamAog += DownstreamPcd[index].TotalArrivalOnGreen;
                }
                //Add the total aog to the dictionary
                ResultsGraph.Add(i, totalBiasArrivalOnGreen);
                UpstreamResultsGraph.Add(i, totalUpstreamAog);
                DownstreamResultsGraph.Add(i, totalDownstreamAog);

                if (totalBiasArrivalOnGreen > maxBiasArrivalOnGreen)
                {
                    maxBiasArrivalOnGreen   = totalBiasArrivalOnGreen;
                    MaxArrivalOnGreen       = totalArrivalOnGreen;
                    AogUpstreamPredicted    = totalUpstreamAog;
                    AogDownstreamPredicted  = totalDownstreamAog;
                    PaogDownstreamPredicted = Math.Round(totalDownstreamAog / TotalVolumeDownstream, 2) * 100;
                    PaogUpstreamPredicted   = Math.Round(totalUpstreamAog / TotalVolumeUpstream, 2) * 100;
                    MaxPercentAog           =
                        SecondsAdded        = i;
                }
            }
            //Get the link totals
            AogTotalPredicted  = MaxArrivalOnGreen;
            PaogTotalPredicted = Math.Round(AogTotalPredicted / (TotalVolumeUpstream + TotalVolumeDownstream), 2) * 100;
        }
Esempio n. 3
0
        public LinkPivotPair(Approach signalApproach, Approach downSignalApproach, DateTime startDate, DateTime endDate,
                             int cycleTime, double bias, string biasDirection, List <DateTime> dates, int linkNumber)
        {
            SignalApproach     = signalApproach;
            DownSignalApproach = downSignalApproach;
            StartDate          = startDate;
            LinkNumber         = linkNumber;
            SetPcds(endDate, dates, cycleTime);
            //Check to see if both directions have detection if so analyze both
            if (UpstreamPcd.Count > 0 && DownstreamPcd.Count > 0)
            {
                if (bias != 0)
                {
                    GetBiasedLinkPivot(cycleTime, bias, biasDirection, dates);
                }
                //If no bias is provided
                else
                {
                    GetUnbiasedLinkPivot(cycleTime, dates);
                }
            }
            //If only upstream has detection do analysis for upstream only
            else if (DownstreamPcd.Count == 0 && UpstreamPcd.Count > 0)
            {
                if (bias != 0)
                {
                    double upstreamBias   = 1;
                    double downstreamBias = 1;
                    if (biasDirection == "Downstream")
                    {
                        downstreamBias = 1 + bias / 100;
                    }
                    else
                    {
                        upstreamBias = 1 + bias / 100;
                    }
                    //set the original values to compare against
                    var maxBiasArrivalOnGreen = AogDownstreamBefore * downstreamBias +
                                                AogUpstreamBefore * upstreamBias;
                    MaxArrivalOnGreen = AogUpstreamBefore;
                    //Add the total to the results grid
                    ResultsGraph.Add(0, MaxArrivalOnGreen);
                    UpstreamResultsGraph.Add(0, AogUpstreamBefore * upstreamBias);
                    DownstreamResultsGraph.Add(0, AogDownstreamBefore * downstreamBias);
                    AogUpstreamPredicted  = AogUpstreamBefore;
                    PaogUpstreamPredicted = Math.Round(AogUpstreamBefore / TotalVolumeUpstream, 2) * 100;
                    SecondsAdded          = 0;

                    for (var i = 1; i <= cycleTime; i++)
                    {
                        double totalBiasArrivalOnGreen = 0;
                        double totalArrivalOnGreen     = 0;
                        double totalUpstreamAog        = 0;


                        for (var index = 0; index < dates.Count; index++)
                        {
                            UpstreamPcd[index].LinkPivotAddSeconds(-1);

                            totalBiasArrivalOnGreen += UpstreamPcd[index].TotalArrivalOnGreen * upstreamBias;
                            totalArrivalOnGreen     += UpstreamPcd[index].TotalArrivalOnGreen;
                            totalUpstreamAog        += UpstreamPcd[index].TotalArrivalOnGreen;
                        }
                        //Add the total aog to the dictionary
                        ResultsGraph.Add(i, totalBiasArrivalOnGreen);
                        UpstreamResultsGraph.Add(i, totalUpstreamAog);

                        if (totalBiasArrivalOnGreen > maxBiasArrivalOnGreen)
                        {
                            maxBiasArrivalOnGreen = totalBiasArrivalOnGreen;
                            MaxArrivalOnGreen     = totalArrivalOnGreen;
                            AogUpstreamPredicted  = totalUpstreamAog;
                            PaogUpstreamPredicted = Math.Round(totalUpstreamAog / TotalVolumeUpstream, 2) * 100;
                            SecondsAdded          = i;
                        }
                    }
                    //Get the link totals
                    AogTotalPredicted  = MaxArrivalOnGreen;
                    PaogTotalPredicted = PaogUpstreamPredicted;
                }
                //No bias provided
                else
                {
                    //set the original values to compare against
                    AogTotalBefore    = AogDownstreamBefore + AogUpstreamBefore;
                    MaxArrivalOnGreen = AogUpstreamBefore;
                    PaogTotalBefore   = Math.Round(AogTotalBefore / (TotalVolumeDownstream + TotalVolumeUpstream), 2) *
                                        100;


                    //Add the total aog to the dictionary
                    ResultsGraph.Add(0, MaxArrivalOnGreen);
                    UpstreamResultsGraph.Add(0, AogUpstreamBefore);
                    DownstreamResultsGraph.Add(0, AogDownstreamBefore);
                    AogUpstreamPredicted  = AogUpstreamBefore;
                    PaogUpstreamPredicted = Math.Round(AogUpstreamBefore / TotalVolumeUpstream, 2) * 100;
                    SecondsAdded          = 0;
                    for (var i = 1; i <= cycleTime; i++)
                    {
                        double totalArrivalOnGreen = 0;
                        double totalUpstreamAog    = 0;

                        for (var index = 0; index < dates.Count; index++)
                        {
                            UpstreamPcd[index].LinkPivotAddSeconds(-1);
                            totalArrivalOnGreen += UpstreamPcd[index].TotalArrivalOnGreen;
                            totalUpstreamAog    += UpstreamPcd[index].TotalArrivalOnGreen;
                        }
                        //Add the total aog to the dictionary
                        ResultsGraph.Add(i, totalArrivalOnGreen);
                        UpstreamResultsGraph.Add(i, totalUpstreamAog);

                        if (totalArrivalOnGreen > MaxArrivalOnGreen)
                        {
                            MaxArrivalOnGreen     = totalArrivalOnGreen;
                            AogUpstreamPredicted  = totalUpstreamAog;
                            PaogUpstreamPredicted = Math.Round(totalUpstreamAog / TotalVolumeUpstream, 2) * 100;
                            SecondsAdded          = i;
                        }
                        //Get the link totals
                        AogTotalPredicted  = MaxArrivalOnGreen;
                        PaogTotalPredicted = PaogUpstreamPredicted;
                    }
                }
            }
            //If downsteam only has detection
            else if (UpstreamPcd.Count == 0 && DownstreamPcd.Count > 0)
            {
                if (bias != 0)
                {
                    double upstreamBias   = 1;
                    double downstreamBias = 1;
                    if (biasDirection == "Downstream")
                    {
                        downstreamBias = 1 + bias / 100;
                    }
                    else
                    {
                        upstreamBias = 1 + bias / 100;
                    }
                    //set the original values to compare against
                    var maxBiasArrivalOnGreen = AogDownstreamBefore * downstreamBias;
                    MaxArrivalOnGreen = AogDownstreamBefore + AogUpstreamBefore;
                    //Add the total aog to the dictionary
                    ResultsGraph.Add(0, MaxArrivalOnGreen);
                    DownstreamResultsGraph.Add(0, AogDownstreamBefore * downstreamBias);
                    AogDownstreamPredicted  = AogDownstreamBefore;
                    PaogDownstreamPredicted = Math.Round(AogDownstreamBefore / TotalVolumeDownstream, 2) * 100;
                    SecondsAdded            = 0;

                    for (var i = 1; i <= cycleTime; i++)
                    {
                        double totalBiasArrivalOnGreen = 0;
                        double totalArrivalOnGreen     = 0;
                        double totalDownstreamAog      = 0;

                        for (var index = 0; index < dates.Count; index++)
                        {
                            DownstreamPcd[index].LinkPivotAddSeconds(1);
                            totalBiasArrivalOnGreen += DownstreamPcd[index].TotalArrivalOnGreen * downstreamBias;
                            totalArrivalOnGreen     += DownstreamPcd[index].TotalArrivalOnGreen;
                            totalDownstreamAog      += DownstreamPcd[index].TotalArrivalOnGreen;
                        }
                        //Add the total aog to the dictionary
                        ResultsGraph.Add(i, totalBiasArrivalOnGreen);
                        DownstreamResultsGraph.Add(i, totalDownstreamAog);
                        if (totalBiasArrivalOnGreen > maxBiasArrivalOnGreen)
                        {
                            maxBiasArrivalOnGreen   = totalBiasArrivalOnGreen;
                            MaxArrivalOnGreen       = totalArrivalOnGreen;
                            AogDownstreamPredicted  = totalDownstreamAog;
                            PaogDownstreamPredicted = Math.Round(totalDownstreamAog / TotalVolumeDownstream, 2) * 100;
                            SecondsAdded            = i;
                        }
                    }
                    //Get the link totals
                    AogTotalPredicted  = MaxArrivalOnGreen;
                    PaogTotalPredicted = PaogDownstreamPredicted;
                }
                //if no bias was provided
                else
                {
                    //set the original values to compare against
                    MaxArrivalOnGreen = AogDownstreamBefore;
                    //Add the total aog to the dictionary
                    ResultsGraph.Add(0, MaxArrivalOnGreen);
                    DownstreamResultsGraph.Add(0, AogDownstreamBefore);
                    AogDownstreamPredicted  = AogDownstreamBefore;
                    PaogDownstreamPredicted = Math.Round(AogDownstreamBefore / TotalVolumeDownstream, 2) * 100;
                    SecondsAdded            = 0;

                    for (var i = 1; i <= cycleTime; i++)
                    {
                        double totalArrivalOnGreen = 0;
                        double totalDownstreamAog  = 0;

                        for (var index = 0; index < dates.Count; index++)
                        {
                            DownstreamPcd[index].LinkPivotAddSeconds(1);
                            totalArrivalOnGreen += DownstreamPcd[index].TotalArrivalOnGreen;
                            totalDownstreamAog  += DownstreamPcd[index].TotalArrivalOnGreen;
                        }
                        //Add the total aog to the dictionary
                        ResultsGraph.Add(i, totalArrivalOnGreen);
                        DownstreamResultsGraph.Add(i, totalDownstreamAog);
                        if (totalArrivalOnGreen > MaxArrivalOnGreen)
                        {
                            MaxArrivalOnGreen       = totalArrivalOnGreen;
                            AogDownstreamPredicted  = totalDownstreamAog;
                            PaogDownstreamPredicted = Math.Round(totalDownstreamAog / TotalVolumeDownstream, 2) * 100;
                            SecondsAdded            = i;
                        }
                    }
                    //Get the link totals
                    AogTotalPredicted  = MaxArrivalOnGreen;
                    PaogTotalPredicted = PaogDownstreamPredicted;
                }
            }
            GetNewResultsChart();
        }