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); }