private void LoadJobTypeDisribution() { this.JobTypeRates = SparseTwinIndex <float> .CreateSimilarArray(this.Root.ZoneSystem.ZoneArray, this.EmploymentStatus); var employmentIndexes = this.EmploymentStatus.ValidIndexies().ToArray(); using (CommentedCsvReader reader = new CommentedCsvReader(this.JobEmploymentRateFile.GetFileName(Root.InputBaseDirectory))) { int pd; float fulltime; float parttime; while (reader.NextLine()) { if (reader.NumberOfCurrentCells >= 3) { reader.Get(out pd, 0); reader.Get(out fulltime, 1); reader.Get(out parttime, 2); foreach (var zone in this.PDZoneMap[pd]) { this.JobTypeRates[zone, employmentIndexes[1]] = fulltime; this.JobTypeRates[zone, employmentIndexes[2]] = parttime; } } } } }
private void LoadAttributes(SparseArray <IZone> zones) { // optional if (string.IsNullOrWhiteSpace(ZoneAttributesFile)) { return; } try { using (CommentedCsvReader reader = new CommentedCsvReader(GetFullPath(ZoneAttributesFile))) { while (reader.NextLine()) { var colRead = reader.NumberOfCurrentCells; if (colRead < 5) { continue; } int zoneNumber; float parkingCost, parkingCap, intraZoneDistance, area; reader.Get(out zoneNumber, 0); reader.Get(out parkingCost, 1); reader.Get(out parkingCap, 2); reader.Get(out intraZoneDistance, 3); reader.Get(out area, 4); var zone = zones[zoneNumber]; if (zone == null) { if (GeneratePDErrors) { throw new XTMFRuntimeException("The planning district file contained a zone " + zoneNumber + " however the zone file did not contain this zone."); } } else { zone.ParkingCost = parkingCost; zone.InternalDistance = intraZoneDistance; zone.InternalArea = area; } } } } catch (IOException) { throw new XTMFRuntimeException("Please make sure that the file " + GetFullPath(ZoneAttributesFile) + " exists and is not being used by any other program."); } }
private void LoadAgeDist() { List <AgeDist> ageDistributions = new List <AgeDist>(); var ageCategories = AgeCategories.Count; using (CommentedCsvReader reader = new CommentedCsvReader(AgeDistributionFile.GetFileName(Root.InputBaseDirectory))) { while (reader.NextLine()) { if (reader.NumberOfCurrentCells >= ageCategories + 1) { float[] ageD = new float[ageCategories]; reader.Get(out int zone, 0); for (int i = 1; i < reader.NumberOfCurrentCells; i++) { reader.Get(out ageD[i - 1], i); } ageDistributions.Add(new AgeDist { Zone = zone, Percentages = ageD }); } } } int numberOfSetZones = 0; foreach (var ageDist in ageDistributions) { if (!PDZoneMap.TryGetValue(ageDist.Zone, out List <int> pd)) { throw new XTMFRuntimeException(this, "In " + Name + " we were unable to find a planning district for the zone number '" + ageDist.Zone + "' while loading the age distribution."); } numberOfSetZones += pd.Count; } var elements = ageDistributions.Count; var first = new int[numberOfSetZones * ageCategories]; var second = new int[numberOfSetZones * ageCategories]; var d = new float[numberOfSetZones * ageCategories]; var validAgeCategory = AgeCategories.ValidIndexies().ToArray(); int soFar = 0; for (int i = 0; i < elements; i++) { var zones = PDZoneMap[ageDistributions[i].Zone]; foreach (var zone in zones) { for (int j = 0; j < ageCategories; j++) { first[soFar] = zone; second[soFar] = validAgeCategory[j]; d[soFar] = ageDistributions[i].Percentages[j]; soFar++; } } } AgeRates = SparseTwinIndex <float> .CreateTwinIndex(first, second, d); }
private void LoadPopulation(SparseArray <IZone> zones) { if (string.IsNullOrWhiteSpace(PopulationFile)) { return; } try { using (CommentedCsvReader reader = new CommentedCsvReader(GetFullPath(PopulationFile))) { while (reader.NextLine()) { var colRead = reader.NumberOfCurrentCells; if (colRead < 2) { continue; } int zoneNumber; int population; reader.Get(out zoneNumber, 0); reader.Get(out population, 1); var zone = zones[zoneNumber]; if (zone == null) { if (GeneratePDErrors) { throw new XTMFRuntimeException("When loading the population we found a distribution for a zone " + zoneNumber + " however that zone does not exist!"); } } else { zone.Population = population; } } } } catch (IOException) { throw new XTMFRuntimeException("Please make sure that the file " + GetFullPath(PopulationFile) + " exists and is not being used by any other program."); } }
private void LoadPDs(SparseArray <IZone> zones) { if (string.IsNullOrWhiteSpace(PlanningDistrictFile)) { return; } try { using (CommentedCsvReader reader = new CommentedCsvReader(GetFullPath(PlanningDistrictFile))) { while (reader.NextLine()) { var colRead = reader.NumberOfCurrentCells; if (colRead < 2) { continue; } int zoneNumber; int pd; reader.Get(out zoneNumber, 0); reader.Get(out pd, 1); var zone = zones[zoneNumber]; if (zone == null) { if (GeneratePDErrors) { throw new XTMFRuntimeException("The planning district file contained a zone " + zoneNumber + " however the zone file did not contain this zone."); } } else { zone.PlanningDistrict = pd; } } } } catch (IOException) { throw new XTMFRuntimeException("Please make sure that the file " + GetFullPath(PlanningDistrictFile) + " exists and is not being used by any other program."); } }
private void LoadWorkerCarDistribution() { this.WorkerVehicleRates = this.Root.ZoneSystem.ZoneArray.CreateSimilarArray <SparseTriIndex <float> >(); SparseArray <float> NumberOfVehicles = new SparseArray <float>(new SparseIndexing() { Indexes = new SparseSet[] { new SparseSet() { Start = 0, Stop = 2 } } }); SparseArray <float> DriversLicense = new SparseArray <float>(new SparseIndexing() { Indexes = new SparseSet[] { new SparseSet() { Start = 0, Stop = 1 } } }); if (!this.WorkerVehicleRateFile.ContainsFileName()) { return; } using (CommentedCsvReader reader = new CommentedCsvReader(this.WorkerVehicleRateFile.GetFileName(Root.InputBaseDirectory))) { int pd; int driversLic; int occ; float chanceZero; float chanceOne; float chanceTwo; while (reader.NextLine()) { if (reader.NumberOfCurrentCells >= 6) //Only read if the number of columns in the row matches. { reader.Get(out pd, 0); reader.Get(out driversLic, 1); reader.Get(out occ, 2); reader.Get(out chanceZero, 3); reader.Get(out chanceOne, 4); reader.Get(out chanceTwo, 5); foreach (var zone in this.PDZoneMap[pd]) { var zoneData = this.WorkerVehicleRates[zone]; if (zoneData == null) { zoneData = SparseTriIndex <float> .CreateSimilarArray(DriversLicense, this.OccupationCategories, NumberOfVehicles); this.WorkerVehicleRates[zone] = zoneData; } zoneData[driversLic, occ, 0] = chanceZero; zoneData[driversLic, occ, 1] = chanceOne; zoneData[driversLic, occ, 2] = chanceTwo; } } } } }
/// <summary> /// Override this method in order to provide the ability to load different formats /// </summary> /// <param name="first">The first dimension sparse address</param> /// <param name="second">The second dimension sparse address</param> /// <param name="third">The third dimension sparse address</param> /// <param name="data">The data to be stored at the address</param> protected virtual void StoreData(List <int> first, List <int> second, List <int> third, List <float> data) { try { using (CommentedCsvReader reader = new CommentedCsvReader(this.GetFileLocation(this.FileName))) { var numberOfDataColumns = DataColumnToSparseSpace.Count; var dataSpace = this.DataColumnToSparseSpace.ToArray(); int max = dataSpace.Max(); while (reader.NextLine()) { // skip blank lines if (reader.NumberOfCurrentCells < max) { continue; } int f, s, t; float d; reader.Get(out f, this.FirstDimensionColumn); reader.Get(out s, this.SecondDimensionColumn); for (int dataCol = 0; dataCol < numberOfDataColumns; dataCol++) { t = dataSpace[dataCol]; reader.Get(out d, dataCol + this.DataStartIndex); first.Add(f); second.Add(s); third.Add(t); data.Add(d); } } } } catch (IOException e) { throw new XTMFRuntimeException(e.Message); } }
private void LoadDriversLicenseDistribution() { this.DriversLicenseRates = this.Root.ZoneSystem.ZoneArray.CreateSimilarArray <SparseTwinIndex <float> >(); var employmentIndexes = this.EmploymentStatus.ValidIndexies().ToArray(); if (!this.DriversLicenseRateFile.ContainsFileName()) { return; } using (CommentedCsvReader reader = new CommentedCsvReader(this.DriversLicenseRateFile.GetFileName(Root.InputBaseDirectory))) { int pd; int ageCat; int empStat; float chance; while (reader.NextLine()) { if (reader.NumberOfCurrentCells >= 4) { reader.Get(out pd, 0); reader.Get(out ageCat, 1); reader.Get(out empStat, 2); reader.Get(out chance, 3); foreach (var zone in this.PDZoneMap[pd]) { var zoneData = this.DriversLicenseRates[zone]; if (zoneData == null) { zoneData = SparseTwinIndex <float> .CreateSimilarArray(this.AgeCategories, this.EmploymentStatus); this.DriversLicenseRates[zone] = zoneData; } zoneData[ageCat, empStat] = chance; } } } } }
/// <summary> /// Override this method in order to provide the ability to load different formats /// </summary> /// <param name="first">The first dimension sparse address</param> /// <param name="second">The second dimension sparse address</param> /// <param name="third">The third dimension sparse address</param> /// <param name="data">The data to be stored at the address</param> protected virtual void StoreData(List <int> first, List <int> second, List <int> third, List <float> data) { using (CommentedCsvReader reader = new CommentedCsvReader(this.FileName.GetFileName(this.Root.InputBaseDirectory))) { while (reader.NextLine()) { // skip blank lines if (reader.NumberOfCurrentCells < 4) { continue; } int f, s, t; float d; reader.Get(out f, 0); reader.Get(out s, 1); reader.Get(out t, 2); reader.Get(out d, 3); first.Add(f); second.Add(s); third.Add(t); data.Add(d); } } }
public void TestLoad() { using ( var reader = new CommentedCsvReader( "CommentedCSVReaderTest.csv" ) ) { /* string[] truth = new string[] {"Zone", "Age", "EmpStat", "OccGroup", "Value"}; for (int i = 0; i < reader.Headers.Length; i++) { Assert.IsTrue(truth[i] == reader.Headers[i]); }*/ int lines = 0; while ( reader.NextLine() ) { if ( reader.NumberOfCurrentCells > 0 ) { Assert.AreEqual<int>( 5, reader.NumberOfCurrentCells ); float val = 0.0f; reader.Get( out val, 5 ); lines++; } } Assert.AreEqual<int>( EXPECTED_NUMBER_OF_LINES, lines ); } using ( var reader = new CommentedCsvReader( "CommentedCSVReaderTestFail.csv" ) ) { for ( int i = 0; i < FAIL_NUMBER_OF_LINES; i++ ) { reader.NextLine(); } bool failed = false; try { reader.NextLine(); } catch ( IOException ) { failed = true; } Assert.IsTrue( failed ); } }
public IEnumerable <float[]> Read() { if (!InputFile.ContainsFileName()) { yield break; } int maxColumn = ColumnNumbers.Max(); var numberOfColumnNumbers = ColumnNumbers.Count; float[] data = new float[numberOfColumnNumbers]; CommentedCsvReader reader; var fileName = InputFile.GetFileName(Root.InputBaseDirectory); try { reader = new CommentedCsvReader(fileName); } catch (IOException e) { throw new XTMFRuntimeException(null, "In module '" + Name + "' we were unable to load the file '" + fileName + "', an error was reported\r\n'" + e.Message + "'"); } using ( reader ) { // process the data while (reader.NextLine()) { // if the line is long enough if (reader.NumberOfCurrentCells >= maxColumn) { for (int i = 0; i < numberOfColumnNumbers; i++) { reader.Get(out data[i], ColumnNumbers[i]); } yield return(data); if (!DataIsCopied) { data = new float[numberOfColumnNumbers]; } } } } }
private void LoadJobOccupationDistribution() { this.JobOccupationRates = SparseTriIndex <float> .CreateSimilarArray(this.Root.ZoneSystem.ZoneArray, this.EmploymentStatus, this.OccupationCategories); var employmentIndexes = this.EmploymentStatus.ValidIndexies().ToArray(); var occupationIndexes = this.OccupationCategories.ValidIndexies().ToArray(); using (CommentedCsvReader reader = new CommentedCsvReader(this.JobOccupationRateFile.GetFileName(Root.InputBaseDirectory))) { int pd; int employmentStatus; float professional; float general; float sales; float manufacturing; while (reader.NextLine()) { if (reader.NumberOfCurrentCells >= 5) { reader.Get(out pd, 0); reader.Get(out employmentStatus, 1); reader.Get(out professional, 2); reader.Get(out general, 3); reader.Get(out sales, 4); reader.Get(out manufacturing, 5); foreach (var zone in this.PDZoneMap[pd]) { this.JobOccupationRates[zone, employmentStatus, occupationIndexes[0]] = 0; this.JobOccupationRates[zone, employmentStatus, occupationIndexes[1]] = professional; this.JobOccupationRates[zone, employmentStatus, occupationIndexes[2]] = general; this.JobOccupationRates[zone, employmentStatus, occupationIndexes[3]] = sales; this.JobOccupationRates[zone, employmentStatus, occupationIndexes[4]] = manufacturing; } } } } }
private void LoadStudentDist() { List <StudentDist> studentData = new List <StudentDist>(); using (CommentedCsvReader reader = new CommentedCsvReader(StudentDistributionFile.GetFileName(Root.InputBaseDirectory))) { float[] data = new float[4]; while (reader.NextLine()) { for (int i = 0; i < data.Length && i < reader.NumberOfCurrentCells; i++) { reader.Get(out data[i], i); } studentData.Add(new StudentDist { Zone = (int)data[0], AgeCat = (int)data[1], EmploymentStatus = (int)data[2], Chance = data[3] }); } } studentData.Sort(delegate(StudentDist first, StudentDist second) { if (first.Zone > second.Zone) { return(1); } if (first.Zone == second.Zone) { if (first.AgeCat > second.AgeCat) { return(1); } if (first.AgeCat == second.AgeCat) { if (first.EmploymentStatus > second.EmploymentStatus) { return(1); } if (first.EmploymentStatus == second.EmploymentStatus) { return(0); } } } return(-1); }); // Employment is now sorted Zone,Age,EmploymentStatus SchoolRates = Root.ZoneSystem.ZoneArray.CreateSimilarArray <SparseTwinIndex <float> >(); var start = 0; var stop = 0; var studentDataLength = studentData.Count; int[] firstIndex; int[] secondIndex; float[] d; int numberOfElements; for (int i = 1; i < studentDataLength; i++) { if (studentData[i].Zone == studentData[i - 1].Zone) { stop = i; } else { numberOfElements = stop - start + 1; firstIndex = new int[numberOfElements]; secondIndex = new int[numberOfElements]; d = new float[numberOfElements]; for (int j = 0; j < numberOfElements; j++) { var data = studentData[start + j]; firstIndex[j] = data.AgeCat; secondIndex[j] = data.EmploymentStatus; d[j] = data.Chance; } foreach (var z in PDZoneMap[studentData[i - 1].Zone]) { SchoolRates[z] = SparseTwinIndex <float> .CreateTwinIndex(firstIndex, secondIndex, d); } start = i; } } numberOfElements = stop - start + 1; firstIndex = new int[numberOfElements]; secondIndex = new int[numberOfElements]; d = new float[numberOfElements]; for (int j = 0; j < numberOfElements; j++) { firstIndex[j] = studentData[start + j].AgeCat; secondIndex[j] = studentData[start + j].EmploymentStatus; d[j] = studentData[start + j].Chance; } foreach (var z in PDZoneMap[studentData[studentDataLength - 1].Zone]) { SchoolRates[z] = SparseTwinIndex <float> .CreateTwinIndex(firstIndex, secondIndex, d); } }
private void LoadOccupationDist() { List <OccupationDist> occupation = new List <OccupationDist>(); if (SaveDataIntoZones) { foreach (var zone in Root.ZoneSystem.ZoneArray.ValidIndexies()) { var z = Root.ZoneSystem.ZoneArray[zone]; z.WorkGeneral = 0; z.WorkManufacturing = 0; z.WorkProfessional = 0; z.WorkRetail = 0; } } using (CommentedCsvReader reader = new CommentedCsvReader(OccupationDistributionFile.GetFileName(Root.InputBaseDirectory))) { float[] data = new float[7]; while (reader.NextLine()) { if (reader.NumberOfCurrentCells < 7) { continue; } for (int i = 0; i < data.Length && i < reader.NumberOfCurrentCells; i++) { reader.Get(out data[i], i); } occupation.Add(new OccupationDist { AgeCat = (int)data[1], Zone = (int)data[0], EmploymentStatus = (int)data[2], Professional = data[3], General = data[4], Sales = data[5], Manufacturing = data[6] }); } } occupation.Sort(delegate(OccupationDist first, OccupationDist second) { if (first.Zone > second.Zone) { return(1); } if (first.Zone == second.Zone) { if (first.AgeCat > second.AgeCat) { return(1); } if (first.AgeCat == second.AgeCat) { if (first.EmploymentStatus > second.EmploymentStatus) { return(1); } if (first.EmploymentStatus == second.EmploymentStatus) { return(0); } } } return(-1); }); OccupationRates = Root.ZoneSystem.ZoneArray.CreateSimilarArray <SparseTriIndex <float> >(); var start = 0; var stop = 0; var employmentLength = occupation.Count; int[] firstIndex; int[] secondIndex; int[] thirdIndex; float[] d; int numberOfElements; for (int i = 1; i < employmentLength; i++) { if (occupation[i].Zone == occupation[i - 1].Zone) { stop = i; } else { numberOfElements = stop - start + 1; firstIndex = new int[numberOfElements * 5]; secondIndex = new int[numberOfElements * 5]; thirdIndex = new int[numberOfElements * 5]; d = new float[numberOfElements * 5]; for (int j = 0; j < numberOfElements; j++) { for (int k = 0; k < 5; k++) { firstIndex[j * 5 + k] = occupation[start + j].AgeCat; secondIndex[j * 5 + k] = occupation[start + j].EmploymentStatus; thirdIndex[j * 5 + k] = k; } d[j * 5 + 1] = occupation[start + j].Professional; d[j * 5 + 2] = occupation[start + j].General; d[j * 5 + 3] = occupation[start + j].Sales; d[j * 5 + 4] = occupation[start + j].Manufacturing; } if (OccupationByPD) { foreach (var z in PDZoneMap[occupation[i - 1].Zone]) { OccupationRates[z] = SparseTriIndex <float> .CreateSparseTriIndex(firstIndex, secondIndex, thirdIndex, d); } } else { OccupationRates[occupation[i - 1].Zone] = SparseTriIndex <float> .CreateSparseTriIndex(firstIndex, secondIndex, thirdIndex, d); } start = i; } } numberOfElements = stop - start + 1; firstIndex = new int[numberOfElements * 5]; secondIndex = new int[numberOfElements * 5]; thirdIndex = new int[numberOfElements * 5]; d = new float[numberOfElements * 5]; for (int j = 0; j < numberOfElements; j++) { for (int k = 0; k < 5; k++) { firstIndex[j * 5 + k] = occupation[start + j].AgeCat; secondIndex[j * 5 + k] = occupation[start + j].EmploymentStatus; thirdIndex[j * 5 + k] = k; } d[j * 5 + 1] = occupation[start + j].Professional; d[j * 5 + 2] = occupation[start + j].General; d[j * 5 + 3] = occupation[start + j].Sales; d[j * 5 + 4] = occupation[start + j].Manufacturing; } if (OccupationByPD) { foreach (var z in PDZoneMap[occupation[employmentLength - 1].Zone]) { OccupationRates[z] = SparseTriIndex <float> .CreateSparseTriIndex(firstIndex, secondIndex, thirdIndex, d); } } else { OccupationRates[occupation[employmentLength - 1].Zone] = SparseTriIndex <float> .CreateSparseTriIndex(firstIndex, secondIndex, thirdIndex, d); } }
private void LoadEmploymentDist() { List <EmploymentDist> employment = new List <EmploymentDist>(); using (CommentedCsvReader reader = new CommentedCsvReader(EmploymentDistributionFile.GetFileName(Root.InputBaseDirectory))) { float[] data = new float[5]; while (reader.NextLine()) { if (reader.NumberOfCurrentCells < 5) { continue; } for (int i = 0; i < data.Length && i < reader.NumberOfCurrentCells; i++) { reader.Get(out data[i], i); } employment.Add(new EmploymentDist { AgeCat = (int)data[1], Zone = (int)data[0], NonWork = data[2], FullTime = data[3], PartTime = data[4] }); } } employment.Sort(delegate(EmploymentDist first, EmploymentDist second) { if (first.Zone > second.Zone) { return(1); } if (first.Zone == second.Zone) { if (first.AgeCat > second.AgeCat) { return(1); } if (first.AgeCat == second.AgeCat) { return(0); } } return(-1); }); EmploymentStatusRates = Root.ZoneSystem.ZoneArray.CreateSimilarArray <SparseTwinIndex <float> >(); int start = 0; int stop = 0; var employmentLength = employment.Count; int[] firstIndex; int[] secondIndex; float[] d; int numberOfElements; for (var i = 1; i < employmentLength; i++) { if (employment[i].Zone == employment[i - 1].Zone) { stop = i; } else { numberOfElements = stop - start + 1; firstIndex = new int[numberOfElements * 3]; secondIndex = new int[numberOfElements * 3]; d = new float[numberOfElements * 3]; for (var j = 0; j < numberOfElements; j++) { var ageCat = employment[start + j].AgeCat; for (int k = 0; k < 3; k++) { firstIndex[j * 3 + k] = ageCat; secondIndex[j * 3 + k] = k; } d[j * 3] = employment[start + j].NonWork; d[j * 3 + 1] = employment[start + j].FullTime; d[j * 3 + 2] = employment[start + j].PartTime; } foreach (var z in PDZoneMap[employment[i - 1].Zone]) { EmploymentStatusRates[z] = SparseTwinIndex <float> .CreateTwinIndex(firstIndex, secondIndex, d); } start = i; } } numberOfElements = stop - start + 1; firstIndex = new int[numberOfElements * 3]; secondIndex = new int[numberOfElements * 3]; d = new float[numberOfElements * 3]; for (var j = 0; j < numberOfElements; j++) { for (var k = 0; k < 3; k++) { firstIndex[j * 3 + k] = employment[start + j].AgeCat; secondIndex[j * 3 + k] = k; } d[j * 3] = employment[start + j].NonWork; d[j * 3 + 1] = employment[start + j].FullTime; d[j * 3 + 2] = employment[start + j].PartTime; } foreach (var z in PDZoneMap[employment[employmentLength - 1].Zone]) { EmploymentStatusRates[z] = SparseTwinIndex <float> .CreateTwinIndex(firstIndex, secondIndex, d); } }
public void Load() { this.Progress = 0; var fileName = this.GetFileName(this.FileName); if (!File.Exists(fileName)) { throw new XTMFRuntimeException(String.Format("The file {0} was not found when trying to load the population!", fileName)); } SparseArray <IPerson[]> pop = this.Root.ZoneSystem.ZoneArray.CreateSimilarArray <IPerson[]>(); SparseArray <Household[]> Households = this.Root.ZoneSystem.ZoneArray.CreateSimilarArray <Household[]>(); var flatHouseholds = Households.GetFlatData(); var flatZones = this.Root.ZoneSystem.ZoneArray.GetFlatData(); Dictionary <int, List <IPerson> > tempPop = new Dictionary <int, List <IPerson> >(flatZones.Length); Parallel.For(0, flatZones.Length, delegate(int i) { IZone zone = flatZones[i]; flatHouseholds[i] = new Household[] { new Household() { Cars = 0, Zone = zone }, new Household() { Cars = 1, Zone = zone }, new Household() { Cars = 2, Zone = zone } }; }); using (CommentedCsvReader reader = new CommentedCsvReader(fileName)) { int i = 0; var baseStream = reader.BaseStream; while (reader.NextLine()) { if (reader.NumberOfCurrentCells > 9) { int zone, age, cars, employmentStatus, studentStatus, occupation, driversLicense; float expansionFactor; reader.Get(out zone, 0); reader.Get(out age, 1); reader.Get(out cars, 2); reader.Get(out employmentStatus, 5); reader.Get(out studentStatus, 6); reader.Get(out occupation, 7); reader.Get(out driversLicense, 8); reader.Get(out expansionFactor, 9); List <IPerson> zoneData; if (!tempPop.TryGetValue(zone, out zoneData)) { zoneData = tempPop[zone] = new List <IPerson>(10); } zoneData.Add(new Person() { Age = age, DriversLicense = driversLicense > 0, EmploymentStatus = employmentStatus, ExpansionFactor = expansionFactor, Household = Households[zone][cars], Occupation = occupation, StudentStatus = studentStatus }); if (i >= 4000) { i = 0; this.Progress = (float)baseStream.Position / baseStream.Length; } i++; } } this.Progress = 1; } SetupPopulation(pop, tempPop, flatZones); }