Beispiel #1
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 #2
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 #3
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 #4
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 #5
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");
            }
        }
Beispiel #6
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 #7
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 #8
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" );
            }
        }