Ejemplo n.º 1
0
 /// <summary>
 /// Releases the data held by transit access
 /// </summary>
 public void ReleaseData()
 {
     if (TransitAccessData != null)
     {
         TransitAccessData.UnloadData();
     }
 }
 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[] 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, loadedPremiumTransit = false;
         Parallel.Invoke(() =>
         {
             accessZones = GetAccessZones(zoneArray);
             data        = zoneArray.CreateSquareTwinArray <Tuple <IZone[], IZone[], float[]> >();
         },
                         () =>
         {
             LoadStationData(zoneArray, out float[] parking, out trains);
         },
                         () =>
         {
             if (!GoTransitNetwork.Loaded)
             {
                 GoTransitNetwork.LoadData();
                 loadedGo = true;
             }
         },
                         () =>
         {
             if (!TransitNetwork.Loaded)
             {
                 TransitNetwork.LoadData();
                 loadedTransit = true;
             }
         },
                         () =>
         {
             if (!PremiumTransitNetwork.Loaded)
             {
                 PremiumTransitNetwork.LoadData();
                 loadedPremiumTransit = true;
             }
         });
         var flatData = data.GetFlatData();
         Console.WriteLine("Computing TAG 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, 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 TAG access stations.");
         // if we loaded the data make sure to unload it
         if (loadedGo)
         {
             GoTransitNetwork.UnloadData();
         }
         if (loadedTransit)
         {
             TransitNetwork.UnloadData();
         }
         if (loadedPremiumTransit)
         {
             PremiumTransitNetwork.UnloadData();
         }
         Data = data;
     }
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Release the data in the cache from
 /// being read
 /// </summary>
 public void ReleaseData()
 {
     Data.UnloadData();
 }
Ejemplo n.º 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;
     }
 }
Ejemplo n.º 5
0
 /// <summary>
 /// Nothing to do here, data is released by TransitAccess
 /// </summary>
 public void ReleaseData()
 {
     TransitAccessData.UnloadData();
 }