Exemplo n.º 1
0
        /**** Constructors ****/
        public frmLinkData(XXE_DataStructures.ProjectData ProjectImport, ref NetworkData NetworkImport, ref List <LinkData> LinkArrImport, ref List <FreewayData> FreewayFacilitiesImportFF)
        {
            InitializeComponent();

            Network           = NetworkImport;
            Links             = LinkArrImport;
            FreewayFacilities = FreewayFacilitiesImportFF;
            Project           = ProjectImport;

            IsOpen = true;
        }
Exemplo n.º 2
0
        public MDImain(XXE_DataStructures.ProjectData ProjImport, NetworkData networkImport, List <LinkData> linksImport, List <FreewayData> freewayFacilitiesImport, List <ODdata> odPairsImport)
        {
            InitializeComponent();

            this.Text = "XXE (Mannering and Washburn)";

            Project           = ProjImport;
            Network           = networkImport;
            Links             = linksImport;
            FreewayFacilities = freewayFacilitiesImport;
            OrigDestPairs     = odPairsImport;

            theMain = this;
        }
Exemplo n.º 3
0
        public static int DriverInfo;     //loop variable for informed and uninformed drivers (uninformed = 1, informed = 2)]


        public static void RunControl(XXE_DataStructures.ProjectData Project, NetworkData network, List <LinkData> links, List <FreewayData> freewayfacilities, List <ODdata> ODpairs, List <UserEquilibriumTimePeriodResult> Results, List <List <List <double> > > RampProportionList)
        {
            network.TotTravTime = 0;
            network.TotVMT      = 0;
            network.TotVC       = 0;
            NonZeroFlowLinks    = 0;
            TotPhysLinks        = 0;
            FLX.Add(newFLX);  //create the '0' index list entry, since loop starts with index '1'

            //FileInputOutput FileIO = new FileInputOutput();

            if (Project.PrintDiagnosticResults == true)
            {
                XXE_Calculations.FileInputOutput.OpenDiagnosticsOutput(Project.Title);
            }

            if (network.TimePeriodType == TimePeriod.Single)
            {
                DriverInfo = 1;
                XXE_Calculations.FileInputOutput.OpenResultsFile(Project.Title);
            }
            else
            {
                DriverInfo = 2;
                XXE_Calculations.FileInputOutput.OpenTimePeriodResultsFile(Project.Title);
            }

            LinkPerformanceCalculations.InitializeBPRparms();
            if (Project.Type == ProjectType.FreewayFacilities)
            {
                GenerateCorrespondingLinks(freewayfacilities, links);
            }
            GetLinkAssignments(network, links, ODpairs);
            DeterminePhysicalLinks(network, links);

            if (Project.Type == ProjectType.FreewayFacilities)
            {
                for (int j = 1; j <= network.NumODrecords; j++)
                {
                    ODpairs[j].NumAdjTrips = Convert.ToInt64(ODpairs[j].NumTrips);
                }
                for (int n = 1; n <= network.TotalLinks; n++)
                {
                    FLX.Add(newFLX);
                    FLX[n] = 1;
                }
                UserEquilibriumMSA(Project, network, links, freewayfacilities, ODpairs, Results, RampProportionList);
            }
            else
            {
                for (int timePer = 1; timePer <= network.NumTimePeriods; timePer++)
                {
                    for (int drvInfo = 1; drvInfo <= DriverInfo; drvInfo++)
                    {
                        if (Project.PrintDiagnosticResults == true)
                        {
                            XXE_Calculations.FileInputOutput.WriteDiagnosticsTimePeriod(timePer, drvInfo);
                        }

                        for (int j = 1; j <= network.NumODrecords; j++)
                        {
                            if (drvInfo == 1)
                            {
                                ODpairs[j].NumAdjTrips = Convert.ToInt64(ODpairs[j].NumTrips * network.IntensityRatio[timePer]);
                            }
                            else
                            {
                                ODpairs[j].NumAdjTrips = Convert.ToInt64(ODpairs[j].NumTrips * (1 - (network.PctUninformed[timePer] / 100)) * network.IntensityRatio[timePer]);
                            }

                            if (Project.PrintDiagnosticResults == true)
                            {
                                XXE_Calculations.FileInputOutput.WriteDiagnosticsODtrips(j, ODpairs[j].NumAdjTrips);
                            }
                        }

                        for (int n = 1; n <= network.TotalLinks; n++)
                        {
                            if (drvInfo == 1)
                            {
                                FLX.Add(newFLX);
                                FLX[n] = 1;
                                links[n].Capacity[timePer] = links[n].Capacity[0];    //uninformed drivers do not know about capacity reductions
                            }
                            else
                            {
                                FLX.Add(newFLX);
                                FLX[n] = FL[n];
                                links[n].Capacity[timePer] = links[n].Capacity[0] * links[n].PropCap[timePer];     //XXEXQ Fortran version sets a lower bound to the link capacity ratio of 0.1
                            }

                            LinkPerformanceCalculations.SelectBPRcoeffsIndex(links[n].FreeFlowSpeed, links[n].Capacity[timePer], n, timePer);

                            if (Project.PrintDiagnosticResults == true)
                            {
                                XXE_Calculations.FileInputOutput.WriteDiagnosticsLinkCapacities(n, links[n].Capacity[timePer]);
                            }
                        }

                        //if 100% of drivers are uninformed, then skip assignment for informed drivers
                        if (!(drvInfo == 2 && network.PctUninformed[timePer] == 100))
                        {
                            UserEquilibrium(timePer, drvInfo, Project, network, links, ODpairs);
                        }

                        if (network.TimePeriodType == TimePeriod.Multiple)
                        {
                            CalcMultiTimePeriodPerformanceMeasures(timePer, drvInfo, network, links);
                        }
                    }
                }
                if (network.TimePeriodType == TimePeriod.Single)
                {
                    CalcSingleTimePeriodPerformanceMeasures(network, links);
                    for (int n = 1; n <= network.TotalLinks; n++)
                    {
                        if (network.PrintCentroidConnectors == true)
                        {
                            XXE_Calculations.FileInputOutput.WriteLinkResults(n, NFL[n], links[n].Capacity[1], links[n].vcRatio[1], links[n].FromNode, links[n].ToNode, links[n].TravTime[1], links[n].Description);
                        }
                        else
                        {
                            if (links[n].PhysLink == true)
                            {
                                XXE_Calculations.FileInputOutput.WriteLinkResults(n, NFL[n], links[n].Capacity[1], links[n].vcRatio[1], links[n].FromNode, links[n].ToNode, links[n].TravTime[1], links[n].Description);
                            }
                        }
                    }
                }
                else //(NetworkData.TimePeriodType == TimePeriod.Multiple)
                {
                    PrintTimePeriodData(network, ref links);
                }

                XXE_Calculations.FileInputOutput.WriteNetworkResults(network, NonZeroFlowLinks);
            }
        }
Exemplo n.º 4
0
        public static void UserEquilibriumMSA(XXE_DataStructures.ProjectData project, NetworkData network, List <LinkData> links, List <FreewayData> freewayfacilities, List <ODdata> OD, List <UserEquilibriumTimePeriodResult> results, List <List <List <double> > > RampProportionList)
        {
            Graph g = new Graph(network.NumNodes - network.FirstNetworkNode + 1);

            ConstructGraph(g, links, network.FirstNetworkNode);


            int numTPs = 1;

            for (int n = 0; n < freewayfacilities.Count; n++)
            {
                if (freewayfacilities[n].PhysicalLinkXXE == true)
                {
                    numTPs = freewayfacilities[n].TotalTimePeriods;
                }
            }
            UserEquilibriumTimePeriodResult timePeriodResult;


            for (int tp = 1; tp <= numTPs; tp++)
            {
                timePeriodResult = new UserEquilibriumTimePeriodResult();
                Iteration iteration;
                double[,] ShortPath  = new double[299, 299];
                double[,] ShortPath1 = new double[299, 299];
                double ObjFcn;  //value of BPR function
                bool   SolutionConverged = false;
                double DeltaFlows;
                double D;
                FL.Clear();
                FL.Add(newFL);                      //create the '0' index list entry, since loop starts with index '1'
                List <List <ODvolume> > ODvolumeLists = new List <List <ODvolume> >();
                //initialize shortest path from each origin to each destination to zero
                for (int i = 1; i <= network.NumZones; i++)
                {
                    for (int j = 1; j <= network.NumZones + 1; j++)
                    {
                        ShortPath[j, i]  = 0;
                        ShortPath1[j, i] = 0;
                    }
                }

                AllOrNothingMSA(tp, network.NumZones, network.NumNodes, FL, network, links, freewayfacilities, OD, RampProportionList, ODvolumeLists, ref ShortPath);
                IterNum = 0;

                ObjFcn = 0;

                for (int i = 1; i <= network.TotalLinks; i++)
                {
                    ObjFcn = ObjFcn + HCM_FF_Method.TravTimeFcnFreewayFacilities(RampProportionList[i - 1], freewayfacilities[i - 1], tp, FL[i]);
                }

                for (int i = 1; i <= network.NumZones; i++)
                {
                    for (int j = 1; j <= network.NumZones; j++)
                    {
                        ShortPath1[i, j] = ShortPath[i, j];
                    }
                }

                ConvValue = 2 * network.ConvCrit;   //initialize convergence value

                do
                {
                    IterNum++;
                    AllOrNothingMSA(tp, network.NumZones, network.NumNodes, NFL, network, links, freewayfacilities, OD, RampProportionList, ODvolumeLists, ref ShortPath);
                    MoveMSA(network, IterNum + 1);
                    ConvValue = 0;
                    ObjFcn    = 0;

                    List <double> TravelTimes = new List <double>();

                    for (int i = 1; i <= network.TotalLinks; i++)
                    {
                        double travelTime = HCM_FF_Method.TravTimeFcnFreewayFacilities(RampProportionList[i - 1], freewayfacilities[i - 1], tp, FL[i]);

                        ObjFcn = ObjFcn + travelTime * FL[i];
                        //TravelTimes.Add(travelTime);

                        DeltaFlows = Math.Abs(NFL[i] - FL[i]);      //difference between previous set of flows and current set of flows
                        if (DeltaFlows != 0)
                        {
                            D = NFL[i];
                            if (D == 0)
                            {
                                D = FL[i];
                            }
                            ConvValue = ConvValue + DeltaFlows / D;
                            FL.Add(newFL);
                            FL[i] = NFL[i];
                        }

                        TravelTimes.Add(HCM_FF_Method.TravTimeFcnFreewayFacilities(RampProportionList[i - 1], freewayfacilities[i - 1], tp, FL[i]));
                    }

                    ConvValue               = ConvValue / network.TotalLinks;
                    iteration               = new Iteration();
                    iteration.ObjFunction   = ObjFcn;
                    iteration.IternationNum = IterNum;
                    iteration.ConvergeValue = ConvValue;
                    IterationLinkVolume linkVolume;
                    for (int n = 1; n <= network.TotalLinks; n++)
                    {
                        if (links[n].PhysLink == true)
                        {
                            linkVolume          = new IterationLinkVolume();
                            linkVolume.ID       = n;
                            linkVolume.FromNode = links[n].FromNode;
                            linkVolume.ToNode   = links[n].ToNode;
                            linkVolume.Volume   = FL[n];
                            linkVolume.PhysLink = links[n].PhysLink;
                            iteration.LinkVolumes.Add(linkVolume);
                        }
                    }
                    timePeriodResult.TimePeriod = tp;
                    timePeriodResult.Iterations.Add(iteration);
                    timePeriodResult.IsConverged = false;

                    if (ConvValue <= network.ConvCrit || IterNum == network.MaxIterations)
                    {
                        if (ConvValue <= network.ConvCrit)
                        {
                            SolutionConverged            = true;
                            timePeriodResult.IsConverged = true;
                        }

                        timePeriodResult.NumIterations    = IterNum;
                        timePeriodResult.ConvergenceValue = ConvValue;
                        timePeriodResult.ObjFunctionValue = ObjFcn;
                        timePeriodResult.LinkResults.Clear();
                        LinkResult result;
                        for (int n = 1; n <= network.TotalLinks; n++)
                        {
                            if (links[n].PhysLink == true)
                            {
                                result                    = new LinkResult();
                                result.ID                 = n;
                                result.FromNode           = links[n].FromNode;
                                result.ToNode             = links[n].ToNode;
                                result.Volume             = FL[n];
                                result.PhysLink           = links[n].PhysLink;
                                result.TravelTime         = TravelTimes[n - 1];
                                result.VehMilesTravVolume = freewayfacilities[n - 1].Results[tp].VehMilesTravVolume;
                                result.VehMilesTravDemand = freewayfacilities[n - 1].Results[tp].VehMilesTravDemand;
                                result.VehHoursTrav       = freewayfacilities[n - 1].Results[tp].VehHoursTrav;
                                result.VehHoursDelay      = freewayfacilities[n - 1].Results[tp].VehHoursDelay;
                                result.DensityVeh         = freewayfacilities[n - 1].Results[tp].DensityVeh;
                                result.AvgSpeed           = freewayfacilities[n - 1].Results[tp].AvgSpeed;
                                result.DensityPC          = freewayfacilities[n - 1].Results[tp].DensityPC;
                                result.SegmentTravelTimes = GetSegmentTravelTimes(freewayfacilities[n - 1].TPsegs[tp]);
                                if (freewayfacilities[n - 1].PhysicalLinkXXE == true)
                                {
                                    result.FreeFlowTravelTime = freewayfacilities[n - 1].Results[tp].TravTimeFreeFlow;
                                    timePeriodResult.LinkResults.Add(result);
                                }
                            }
                        }
                    }
                } while ((SolutionConverged == false) && (IterNum < network.MaxIterations));

                for (int od = 1; od < OD.Count; od++) //the first od item has no values
                {
                    int PathFromNode = ZoneToNode(OD[od].OrigZone, links);
                    int PathToNode   = ZoneToNode(OD[od].DestZone, links);
                    if (PathFromNode > 0 && PathToNode > 0)
                    {
                        g.PathList = new List <List <int> >();
                        GetPathsFromOD(g, PathFromNode, PathToNode, network.FirstNetworkNode);
                        ODResult result = new ODResult();
                        result.Orig                   = OD[od].OrigZone;
                        result.Dest                   = OD[od].DestZone;
                        result.PathLists              = g.PathList;
                        result.TravelTimeList         = GetPathTravelTimes(result.PathLists, timePeriodResult);
                        result.FreeFlowTravelTimeList = GetPathFreeFlowTravelTimes(result.PathLists, timePeriodResult);
                        double minimalPathTravelTime = result.TravelTimeList[0];

                        for (int n = 0; n < result.TravelTimeList.Count; n++)
                        {
                            if (result.TravelTimeList[n] < minimalPathTravelTime)
                            {
                                minimalPathTravelTime = result.TravelTimeList[n];
                            }
                        }
                        result.MinimalPathTravelTime = minimalPathTravelTime;
                        double minimalPathFreeFlowTravelTime = result.FreeFlowTravelTimeList[0];
                        for (int n = 0; n < result.FreeFlowTravelTimeList.Count; n++)
                        {
                            if (result.FreeFlowTravelTimeList[n] < minimalPathFreeFlowTravelTime)
                            {
                                minimalPathFreeFlowTravelTime = result.FreeFlowTravelTimeList[n];
                            }
                        }
                        result.MinimalPathFreeFlowTravelTime = minimalPathFreeFlowTravelTime;
                        for (int n = 0; n < result.TravelTimeList.Count; n++)
                        {
                            double diff = result.TravelTimeList[n] - minimalPathTravelTime;
                            if (diff < 1)
                            {
                                result.UtilizedPathLists.Add(result.PathLists[n]);
                                result.UtilizedList.Add(1);
                            }
                            else
                            {
                                result.UtilizedList.Add(0);
                            }
                        }
                        timePeriodResult.ODResults.Add(result);
                    }
                }

                results.Add(timePeriodResult);
            }
        }
Exemplo n.º 5
0
        public static void UserEquilibrium(int tp, int dInfo, XXE_DataStructures.ProjectData project, NetworkData network, List <LinkData> links, List <ODdata> OD)
        {
            //FileInputOutput FileIO = new FileInputOutput();
            double[,] ShortPath  = new double[299, 299];
            double[,] ShortPath1 = new double[299, 299];
            double ObjFcn;  //value of BPR function
            bool   SolutionConverged = false;
            double DeltaFlows;
            double D;

            FL.Add(newFL);         //create the '0' index list entry, since loop starts with index '1'
            PathFL.Add(newPathFL); //create the '0' index list entry, since loop starts with index '1'

            //initialize shortest path from each origin to each destination to zero
            for (int i = 1; i <= network.NumZones; i++)
            {
                for (int j = 1; j <= network.NumZones + 1; j++)
                {
                    ShortPath[j, i]  = 0;
                    ShortPath1[j, i] = 0;
                }
            }

            AllOrNothing(tp, dInfo, network.NumZones, network.NumNodes, FL, PathFL, network, links, OD, ref ShortPath);
            if (project.PrintDiagnosticResults == true)
            {
                XXE_Calculations.FileInputOutput.WriteDiagnosticsLinkFlows("AllOrNothing--Base", NFL, network.TotalLinks);
            }

            IterNum = 0;
            ObjFcn  = 0;
            for (int i = 1; i <= network.TotalLinks; i++)
            {
                if (tp > 1)
                {
                    ObjFcn = ObjFcn + LinkPerformanceCalculations.IntegratedTravTimeFcn(dInfo, links[i].Length, links[i].Capacity[tp], links[i].FreeFlowSpeed, FL[i], FLX[i], (network.PctUninformed[tp] / 100), links[i].Que[tp], LinkPerformanceCalculations.alphaInt[LinkPerformanceCalculations.CoeffIndex[i, tp]], LinkPerformanceCalculations.beta[LinkPerformanceCalculations.CoeffIndex[i, tp]]);
                }
                else
                {
                    ObjFcn = ObjFcn + LinkPerformanceCalculations.IntegratedTravTimeFcn(dInfo, links[i].Length, links[i].Capacity[tp], links[i].FreeFlowSpeed, FL[i], FLX[i], (network.PctUninformed[tp] / 100), links[i].Que[tp - 1], LinkPerformanceCalculations.alphaInt[LinkPerformanceCalculations.CoeffIndex[i, tp]], LinkPerformanceCalculations.beta[LinkPerformanceCalculations.CoeffIndex[i, tp]]);
                }
            }

            for (int i = 1; i <= network.NumZones; i++)
            {
                for (int j = 1; j <= network.NumZones; j++)
                {
                    ShortPath1[i, j] = ShortPath[i, j];

                    if (project.PrintDiagnosticResults == true)
                    {
                        XXE_Calculations.FileInputOutput.WriteDiagnosticsShortestPaths(i, j, ShortPath1);
                    }
                }
            }

            ConvValue = 2 * network.ConvCrit;   //initialize convergence value

            do
            {
                AllOrNothing(tp, dInfo, network.NumZones, network.NumNodes, NFL, NPathFL, network, links, OD, ref ShortPath);

                if (project.PrintDiagnosticResults == true)
                {
                    XXE_Calculations.FileInputOutput.WriteDiagnosticsLinkFlows("AllOrNothing-Iteration", NFL, network.TotalLinks);
                }

                Bisection(tp, dInfo, 0, 1, network.ConvCrit, network, ref links);

                if (project.PrintDiagnosticResults == true)
                {
                    XXE_Calculations.FileInputOutput.WriteDiagnosticsLinkFlows("Bisection", NFL, network.TotalLinks);
                }

                ConvValue = 0;
                ObjFcn    = 0;
                for (int i = 1; i <= network.TotalLinks; i++)
                {
                    if (tp > 1)
                    {
                        ObjFcn = ObjFcn + LinkPerformanceCalculations.IntegratedTravTimeFcn(dInfo, links[i].Length, links[i].Capacity[tp], links[i].FreeFlowSpeed, NFL[i], FLX[i], (network.PctUninformed[tp] / 100), links[i].Que[tp], LinkPerformanceCalculations.alphaInt[LinkPerformanceCalculations.CoeffIndex[i, tp]], LinkPerformanceCalculations.beta[LinkPerformanceCalculations.CoeffIndex[i, tp]]);
                    }
                    else
                    {
                        ObjFcn = ObjFcn + LinkPerformanceCalculations.IntegratedTravTimeFcn(dInfo, links[i].Length, links[i].Capacity[tp], links[i].FreeFlowSpeed, NFL[i], FLX[i], (network.PctUninformed[tp] / 100), links[i].Que[tp - 1], LinkPerformanceCalculations.alphaInt[LinkPerformanceCalculations.CoeffIndex[i, tp]], LinkPerformanceCalculations.beta[LinkPerformanceCalculations.CoeffIndex[i, tp]]);
                    }

                    DeltaFlows = Math.Abs(NFL[i] - FL[i]);      //difference between previous set of flows and current set of flows
                    if (DeltaFlows != 0)
                    {
                        D = NFL[i];
                        if (D == 0)
                        {
                            D = FL[i];
                        }
                        ConvValue = ConvValue + DeltaFlows / D;
                        FL.Add(newFL);
                        FL[i] = NFL[i];
                    }
                }

                //path flow
                for (int i = 1; i < NPathFL.Count; i++)
                {
                    DeltaFlows = Math.Abs(NPathFL[i].Volume - PathFL[i].Volume);
                    if (DeltaFlows != 0)
                    {
                        PathFL[i] = NPathFL[i];
                    }
                }

                ConvValue = ConvValue / network.TotalLinks;
                if (ConvValue <= network.ConvCrit)
                {
                    SolutionConverged = true;
                }
                IterNum++;
            } while ((SolutionConverged == false) && (IterNum < network.MaxIterations));
        }
Exemplo n.º 6
0
 private void InitializeValues()
 {
     Project = new XXE_DataStructures.ProjectData();
     Network = new NetworkData();
 }