Beispiel #1
0
 public void LoadData()
 {
     if (Data == null)
     {
         var cacheFile = GetFullPath(this.ODC);
         if ((this.AlreadyLoaded & this.RebuildDataOnSuccessiveLoads) || !File.Exists(cacheFile))
         {
             // create the data if it doesn't already exist
             ODMatrixWriter <IZone> creator =
                 new ODMatrixWriter <IZone>(this.Root.ZoneSystem.ZoneArray, 2, 3);
             creator.Year = this.Year;
             creator.AdditionalDescription = "Automatically Generated";
             creator.StartTimesHeader      = "6:00,15:30,Other";
             creator.EndTimesHeader        = "9:00AM,18:30,Other";
             creator.TypeHeader            = "TravelTime,Cost";
             creator.Modes = "Auto";
             LoadTimes(creator, this.AMTravelTimeOriginalData, 0);
             LoadTimes(creator, this.PMTravelTimeOriginalData, 1);
             LoadTimes(creator, this.OffpeakTravelTimeOriginalData, 2);
             LoadCosts(creator, this.AMTravelCostOriginalData, 0);
             LoadCosts(creator, this.PMTravelCostOriginalData, 1);
             LoadCosts(creator, this.OffpeakTravelCostOriginalData, 2);
             creator.Save(cacheFile, false);
         }
         Data            = new ODCache(cacheFile);
         this.StoredData = Data.StoreAll();
     }
     this.AlreadyLoaded = true;
 }
Beispiel #2
0
 public void TestCSVODC()
 {
     try
     {
         int[]             zones          = new int[] { 0, 1, 2, 3, 4, 5, 6 };
         SparseArray <int> referenceArray = new SparseArray <int>(new SparseIndexing()
         {
             Indexes = new SparseSet[]
             {
                 new SparseSet()
                 {
                     Start = 0, Stop = 6
                 }
             }
         });
         float[][][] allData = new float[1][][];
         var         data    = CreateData(zones.Length);
         CreateCSVFile(zones, data, "Test.csv");
         allData[0] = data;
         var writer = new ODMatrixWriter <int>(referenceArray, 1, 1);
         writer.LoadCSVTimes("Test.csv", false, 0, 0);
         writer.Save("Test.odc", false);
         var odcFloatData = ConvertData(allData, zones.Length, 1, 1);
         ValidateData(zones, odcFloatData, "Test.odc");
     }
     finally
     {
         File.Delete("Test.csv");
         File.Delete("Test.odc");
     }
 }
Beispiel #3
0
 public void LoadData()
 {
     if (Data == null)
     {
         var cacheFile = GetFullPath(this.ODC);
         if ((this.AlreadyLoaded & this.RebuildDataOnSuccessiveLoads) || !File.Exists(cacheFile))
         {
             // create the data if it doesn't already exist
             ODMatrixWriter <IZone> creator =
                 new ODMatrixWriter <IZone>(this.Root.ZoneSystem.ZoneArray, 2, 3);
             creator.Year = this.Year;
             creator.AdditionalDescription = "Automatically Generated";
             creator.StartTimesHeader      = "Six,FiveThirty,Other";
             creator.EndTimesHeader        = "Nine,SixThirty,Other";
             creator.TypeHeader            = "TravelTime,Cost";
             creator.Modes = String.IsNullOrWhiteSpace(this.NetworkType) ? "Auto" : this.NetworkType;
             creator.LoadEMME2(FailIfNotExist(this.AMTravelTimeOriginalData), 0, (int)AutoDataTypes.TravelTime);
             creator.LoadEMME2(FailIfNotExist(this.AMTravelCostOriginalData), 0, (int)AutoDataTypes.CarCost);
             creator.LoadEMME2(FailIfNotExist(this.PMTravelTimeOriginalData), 1, (int)AutoDataTypes.TravelTime);
             creator.LoadEMME2(FailIfNotExist(this.PMTravelCostOriginalData), 1, (int)AutoDataTypes.CarCost);
             creator.LoadEMME2(FailIfNotExist(this.OffpeakTravelTimeOriginalData), 2, (int)AutoDataTypes.TravelTime);
             creator.LoadEMME2(FailIfNotExist(this.OffpeakTravelCostOriginalData), 2, (int)AutoDataTypes.CarCost);
             creator.Save(cacheFile, false);
         }
         Data            = new ODCache(cacheFile);
         this.StoredData = Data.StoreAll();
     }
     this.AlreadyLoaded = true;
 }
Beispiel #4
0
 public void Test311ODC()
 {
     try
     {
         int[] zones = new int[] { 0, 1, 2, 3, 4, 5, 6 };
         SparseArray<int> referenceArray = new SparseArray<int>( new SparseIndexing()
         {
             Indexes = new SparseSet[]
         {
             new SparseSet() { Start = 0, Stop = 6 }
         }
         } );
         float[][][] allData = new float[1][][];
         var data = CreateData( zones.Length );
         Create311File( zones, data, "Test.311" );
         allData[0] = data;
         var writer = new ODMatrixWriter<int>( referenceArray, 1, 1 );
         writer.LoadEMME2( "Test.311", 0 );
         writer.Save( "Test.odc", false );
         var odcFloatData = ConvertData( allData, zones.Length, 1, 1 );
         ValidateData( zones, odcFloatData, "Test.odc" );
     }
     finally
     {
         File.Delete( "Test.311" );
         File.Delete( "Test.odc" );
     }
 }
Beispiel #5
0
 private void LoadTimes(ODMatrixWriter <IZone> writer, string FileName, int i)
 {
     if (Path.GetExtension(FileName) == ".311")
     {
         writer.LoadEMME2(FailIfNotExist(FileName), i, (int)AutoDataTypes.TravelTime);
     }
     else
     {
         writer.LoadCSVTimes(FailIfNotExist(FileName), HeaderBoolean, i, (int)AutoDataTypes.TravelTime);
     }
 }
Beispiel #6
0
        public void TestMultiTimeTypes311ODC()
        {
            int times = 3, types = 2;

            float[][][] allData = new float[times * types][][];
            try
            {
                int[]             zones          = new int[] { 0, 1, 2, 3, 4, 5, 6 };
                SparseArray <int> referenceArray = new SparseArray <int>(new SparseIndexing()
                {
                    Indexes = new SparseSet[]
                    {
                        new SparseSet()
                        {
                            Start = 0, Stop = 6
                        }
                    }
                });

                for (int i = 0; i < allData.Length; i++)
                {
                    var data = CreateData(zones.Length);
                    Create311File(zones, data, "Test" + i + ".311");
                    allData[i] = data;
                }
                var writer = new ODMatrixWriter <int>(referenceArray, times, types);
                for (int i = 0; i < types; i++)
                {
                    for (int j = 0; j < times; j++)
                    {
                        writer.LoadEMME2("Test" + (i * times + j) + ".311", i, j);
                    }
                }
                writer.Save("Test.odc", false);
                var odcFloatData = ConvertData(allData, zones.Length, times, types);
                ValidateData(zones, odcFloatData, "Test.odc");
            }
            finally
            {
                for (int i = 0; i < allData.Length; i++)
                {
                    File.Delete("Test" + i + ".311");
                }
                File.Delete("Test.odc");
            }
        }
        private void Generate(string cacheFile)
        {
            // create the data if it doesn't already exist
            ODMatrixWriter <IZone> creator =
                new ODMatrixWriter <IZone>(this.Root.ZoneSystem.ZoneArray, 2, 1);

            creator.Year = this.Year;
            creator.AdditionalDescription = "Automatically Generated";
            creator.StartTimesHeader      = "ALLDAY";
            creator.EndTimesHeader        = "ALLDAY";
            creator.TypeHeader            = "TravelTime,Cost";
            creator.Modes = "Auto";
            LoadTimes(creator, this.AlreadyLoaded ? this.UpdatedTravelTimeData : this.BaseTravelTimeData, 0);
            LoadCosts(creator, this.AlreadyLoaded ? this.UpdatedCostData : this.BaseTravelCostData, 0);
            creator.Save(cacheFile, false);
            creator = null;
            GC.Collect();
        }
Beispiel #8
0
 private void LoadTimes(ODMatrixWriter<IZone> writer, string FileName, int i)
 {
     if ( Path.GetExtension( FileName ) == ".311" )
     {
         writer.LoadEMME2( FailIfNotExist( FileName ), i, (int)AutoDataTypes.TravelTime );
     }
     else
     {
         writer.LoadCSVTimes( FailIfNotExist( FileName ), HeaderBoolean, i, (int)AutoDataTypes.TravelTime );
     }
 }
Beispiel #9
0
 private void Generate(string cacheFile)
 {
     // create the data if it doesn't already exist
     ODMatrixWriter<IZone> creator =
         new ODMatrixWriter<IZone>( this.Root.ZoneSystem.ZoneArray, 2, 3 );
     creator.Year = this.Year;
     creator.AdditionalDescription = "Automatically Generated";
     creator.StartTimesHeader = "6:00,15:30,Other";
     creator.EndTimesHeader = "9:00AM,18:30,Other";
     creator.TypeHeader = "TravelTime,Cost";
     creator.Modes = "Auto";
     LoadTimes( creator, this.AlreadyLoaded ? this.UpdatedAMTravelTimeData : this.BaseAMTravelTimeData, 0 );
     LoadTimes( creator, this.AlreadyLoaded ? this.UpdatedPMTravelTimeData : this.BasePMTravelTimeData, 1 );
     LoadTimes( creator, this.AlreadyLoaded ? this.UpdatedOffpeakTravelTimeData : this.BaseOffpeakTravelTimeData, 2 );
     LoadCosts( creator, this.AlreadyLoaded ? this.UpdatedAMCostData : this.BaseAMTravelCostData, 0 );
     LoadCosts( creator, this.AlreadyLoaded ? this.UpdatedPMCostData : this.BasePMTravelCostData, 1 );
     LoadCosts( creator, this.AlreadyLoaded ? this.UpdatedOffpeakCostData : this.BaseOffpeakTravelCostData, 2 );
     creator.Save( cacheFile, false );
     creator = null;
     GC.Collect();
 }
Beispiel #10
0
 public void LoadData()
 {
     if ( Data == null )
     {
         var cacheFile = GetFullPath( this.ODC );
         if ( ( this.AlreadyLoaded & this.RebuildDataOnSuccessiveLoads ) || !File.Exists( cacheFile ) )
         {
             // create the data if it doesn't already exist
             ODMatrixWriter<IZone> creator =
                 new ODMatrixWriter<IZone>( this.Root.ZoneSystem.ZoneArray, 2, 3 );
             creator.Year = this.Year;
             creator.AdditionalDescription = "Automatically Generated";
             creator.StartTimesHeader = "6:00,15:30,Other";
             creator.EndTimesHeader = "9:00AM,18:30,Other";
             creator.TypeHeader = "TravelTime,Cost";
             creator.Modes = "Auto";
             LoadTimes( creator, this.AMTravelTimeOriginalData, 0 );
             LoadTimes( creator, this.PMTravelTimeOriginalData, 1 );
             LoadTimes( creator, this.OffpeakTravelTimeOriginalData, 2 );
             LoadCosts( creator, this.AMTravelCostOriginalData, 0 );
             LoadCosts( creator, this.PMTravelCostOriginalData, 1 );
             LoadCosts( creator, this.OffpeakTravelCostOriginalData, 2 );
             creator.Save( cacheFile, false );
         }
         Data = new ODCache( cacheFile );
         this.StoredData = Data.StoreAll();
     }
     this.AlreadyLoaded = true;
 }
Beispiel #11
0
 public void LoadData()
 {
     if ( Data == null )
     {
         var cacheFile = GetFullPath( this.ODC );
         if ( ( this.AlreadyLoaded & this.RebuildDataOnSuccessiveLoads ) || !File.Exists( cacheFile ) )
         {
             // create the data if it doesn't already exist
             ODMatrixWriter<IZone> creator =
                 new ODMatrixWriter<IZone>( this.Root.ZoneSystem.ZoneArray, 2, 3 );
             creator.Year = this.Year;
             creator.AdditionalDescription = "Automatically Generated";
             creator.StartTimesHeader = "Six,FiveThirty,Other";
             creator.EndTimesHeader = "Nine,SixThirty,Other";
             creator.TypeHeader = "TravelTime,Cost";
             creator.Modes = String.IsNullOrWhiteSpace( this.NetworkType ) ? "Auto" : this.NetworkType;
             creator.LoadEMME2( FailIfNotExist( this.AMTravelTimeOriginalData ), 0, (int)AutoDataTypes.TravelTime );
             creator.LoadEMME2( FailIfNotExist( this.AMTravelCostOriginalData ), 0, (int)AutoDataTypes.CarCost );
             creator.LoadEMME2( FailIfNotExist( this.PMTravelTimeOriginalData ), 1, (int)AutoDataTypes.TravelTime );
             creator.LoadEMME2( FailIfNotExist( this.PMTravelCostOriginalData ), 1, (int)AutoDataTypes.CarCost );
             creator.LoadEMME2( FailIfNotExist( this.OffpeakTravelTimeOriginalData ), 2, (int)AutoDataTypes.TravelTime );
             creator.LoadEMME2( FailIfNotExist( this.OffpeakTravelCostOriginalData ), 2, (int)AutoDataTypes.CarCost );
             creator.Save( cacheFile, false );
         }
         Data = new ODCache( cacheFile );
         this.StoredData = Data.StoreAll();
     }
     this.AlreadyLoaded = true;
 }
Beispiel #12
0
        public void TestMultiTimeTypes311ODC()
        {
            int times = 3, types = 2;
            float[][][] allData = new float[times * types][][];
            try
            {
                int[] zones = new int[] { 0, 1, 2, 3, 4, 5, 6 };
                SparseArray<int> referenceArray = new SparseArray<int>( new SparseIndexing()
                {
                    Indexes = new SparseSet[]
                {
                    new SparseSet() { Start = 0, Stop = 6 }
                }
                } );

                for ( int i = 0; i < allData.Length; i++ )
                {
                    var data = CreateData( zones.Length );
                    Create311File( zones, data, "Test" + i + ".311" );
                    allData[i] = data;
                }
                var writer = new ODMatrixWriter<int>( referenceArray, times, types );
                for ( int i = 0; i < types; i++ )
                {
                    for ( int j = 0; j < times; j++ )
                    {
                        writer.LoadEMME2( "Test" + ( i * times + j ) + ".311", i, j );
                    }
                }
                writer.Save( "Test.odc", false );
                var odcFloatData = ConvertData( allData, zones.Length, times, types );
                ValidateData( zones, odcFloatData, "Test.odc" );
            }
            finally
            {
                for ( int i = 0; i < allData.Length; i++ )
                {
                    File.Delete( "Test" + i + ".311" );
                }
                File.Delete( "Test.odc" );
            }
        }