Пример #1
0
        public void Run()
        {
            Data.LoadData();
            var  watch         = new Stopwatch();
            int  iterations    = 10;
            var  flatZones     = this.Root.ZoneSystem.ZoneArray.GetFlatData();
            var  numberOfZones = flatZones.Length;
            Time time          = new Time()
            {
                Hours = 7
            };
            float denominator = iterations * numberOfZones * numberOfZones;

            watch.Start();
            for (int it = 0; it < iterations; it++)
            {
                for (int i = 0; i < numberOfZones; i++)
                {
                    for (int j = 0; j < numberOfZones; j++)
                    {
                        this.Data.TravelTime(flatZones[i], flatZones[j], time);
                    }
                }
                this.Progress = it / (float)iterations;
            }
            watch.Stop();
            WriteFile(watch.ElapsedMilliseconds);
            Data.UnloadData();
        }
Пример #2
0
 /// <summary>
 /// Load the network AutoData for this mode
 /// </summary>
 public void ReloadNetworkData()
 {
     AutoData.LoadData();
 }
Пример #3
0
 public void LoadData()
 {
     if (Data == null | LastIteration != Root.CurrentIteration)
     {
         LastIteration = Root.CurrentIteration;
         var     zoneArray   = Root.ZoneSystem.ZoneArray;
         var     zones       = zoneArray.GetFlatData();
         int[]   accessZones = null;
         float[] parking     = null, trains = null;
         SparseTwinIndex <Tuple <IZone[], IZone[], float[]> > data = null;
         // these will be flagged to true if we needed to load a network
         bool loadedGo = false, loadedTransit = false, loadedAutoNetwork = false;
         Parallel.Invoke(() =>
         {
             accessZones = GetAccessZones(zoneArray);
             data        = zoneArray.CreateSquareTwinArray <Tuple <IZone[], IZone[], float[]> >();
         },
                         () =>
         {
             LoadStationData(zoneArray, out parking, out trains);
         },
                         () =>
         {
             if (!GoTransitNetwork.Loaded)
             {
                 GoTransitNetwork.LoadData();
                 loadedGo = true;
             }
         },
                         () =>
         {
             if (!TransitNetwork.Loaded)
             {
                 TransitNetwork.LoadData();
                 loadedTransit = true;
             }
         },
                         () =>
         {
             if (!AutoNetwork.Loaded)
             {
                 AutoNetwork.LoadData();
                 loadedAutoNetwork = true;
             }
         });
         var flatData = data.GetFlatData();
         Console.WriteLine("Computing DAG Access station utilities.");
         Stopwatch watch         = Stopwatch.StartNew();
         float[][] egressUtility = new float[accessZones.Length][];
         int[][]   egressZones   = new int[accessZones.Length][];
         float[][] egressTime    = new float[accessZones.Length][];
         for (int i = 0; i < egressUtility.Length; i++)
         {
             egressUtility[i] = new float[zones.Length];
             egressTime[i]    = new float[zones.Length];
             egressZones[i]   = new int[zones.Length];
         }
         // compute the egress data
         Parallel.For(0, accessZones.Length, i =>
         {
             var interchange = accessZones[i];
             for (int j = 0; j < zones.Length; j++)
             {
                 // you also don't need to compute the access station choices for destinations that are access stations
                 if (zones[j].RegionNumber <= 0)
                 {
                     egressTime[i][j]    = float.NaN;
                     egressUtility[i][j] = float.NaN;
                     egressZones[i][j]   = -1;
                 }
                 ComputeEgressStation(interchange, j, accessZones, trains, parking, out egressUtility[i][j], out egressTime[i][j], out egressZones[i][j]);
             }
         });
         // using the egress data compute access stations
         Parallel.For(0, zones.Length, o =>
         {
             // There is no need to compute drive access subway when you are starting at an access station
             int regionO = zones[o].RegionNumber;
             if (regionO == 0 | accessZones.Contains(o))
             {
                 return;
             }
             // for the rest of the zones though, compute it to all destinations
             for (int d = 0; d < zones.Length; d++)
             {
                 // you also don't need to compute the access station choices for destinations that are access stations
                 var regionD = zones[d].RegionNumber;
                 if (regionD == 0 | accessZones.Contains(d))
                 {
                     continue;
                 }
                 if ((regionO == 1) | (regionO != regionD))
                 {
                     ComputeUtility(o, d, zones, accessZones, egressUtility, egressTime, egressZones, flatData);
                 }
             }
         });
         watch.Stop();
         Console.WriteLine("It took " + watch.ElapsedMilliseconds + "ms to compute the DAG access stations.");
         // if we loaded the data make sure to unload it
         if (loadedGo)
         {
             GoTransitNetwork.UnloadData();
         }
         if (loadedTransit)
         {
             TransitNetwork.UnloadData();
         }
         if (loadedAutoNetwork)
         {
             AutoNetwork.UnloadData();
         }
         Data = data;
     }
 }
Пример #4
0
 public void LoadData()
 {
     if (Data == null | LastIteration != Root.CurrentIteration)
     {
         LastIteration = Root.CurrentIteration;
         var     zoneArray   = Root.ZoneSystem.ZoneArray;
         var     zones       = zoneArray.GetFlatData();
         int[]   accessZones = null;
         float[] parking     = null;
         SparseTwinIndex <Tuple <IZone[], IZone[], float[]> > data = null;
         // these will be flagged to true if we needed to load a network
         bool loadedAuto = false, loadedTransit = false;
         Parallel.Invoke(() =>
         {
             accessZones = GetAccessZones(zoneArray);
             data        = zoneArray.CreateSquareTwinArray <Tuple <IZone[], IZone[], float[]> >();
         },
                         () =>
         {
             LoadStationData(zoneArray, out parking, out float[] trains);
         },
                         () =>
         {
             if (!AutoNetwork.Loaded)
             {
                 AutoNetwork.LoadData();
                 loadedAuto = true;
             }
         },
                         () =>
         {
             if (!TransitNetwork.Loaded)
             {
                 TransitNetwork.LoadData();
                 loadedTransit = true;
             }
         });
         var flatData = data.GetFlatData();
         Console.WriteLine("Computing DAS Access station utilities.");
         Stopwatch watch = Stopwatch.StartNew();
         Parallel.For(0, zones.Length, o =>
         {
             // There is no need to compute drive access subway when you are starting at an access station
             if (accessZones.Contains(o))
             {
                 return;
             }
             // for the rest of the zones though, compute it to all destinations
             for (int d = 0; d < zones.Length; d++)
             {
                 // you also don't need to compute the access station choices for destinations that are access stations
                 if (accessZones.Contains(d))
                 {
                     continue;
                 }
                 ComputeUtility(o, d, zones, accessZones, parking, flatData);
             }
         });
         watch.Stop();
         Console.WriteLine("It took " + watch.ElapsedMilliseconds + "ms to compute the DAS access stations.");
         // if we loaded the data make sure to unload it
         if (loadedAuto)
         {
             AutoNetwork.UnloadData();
         }
         if (loadedTransit)
         {
             TransitNetwork.UnloadData();
         }
         Data = data;
     }
 }