private void SaveWorkerCategoryData(IZone[] zones, Occupation occupation, TTSEmploymentStatus empStat, float[][] workers) { using (StreamWriter writer = new StreamWriter(BuildFileName(occupation, empStat, WorkerCategoryDirectory))) { writer.WriteLine("Zone,WorkerCategory,Persons"); for (int i = 0; i < workers.Length; i++) { var factor = 1.0f / workers[i].Sum(); if (float.IsNaN(factor)) { continue; } for (int cat = 0; cat < workers[i].Length; cat++) { workers[i][cat] *= factor; } for (int cat = 0; cat < workers[i].Length; cat++) { if (workers[i][cat] > 0) { writer.Write(zones[i].ZoneNumber); writer.Write(','); writer.Write(cat + 1); writer.Write(','); writer.WriteLine(workers[i][cat]); } } } } }
private int GetDataOffset(int ageCategory, Occupation occupation, TTSEmploymentStatus employmentStatus) { var ageCat = ageCategory >= 0 ? ageCategory : 0; var occCat = Array.IndexOf(Root.Occupations, occupation); var empCat = Array.IndexOf(Root.EmploymentStatuses, employmentStatus); return(((ageCat * Root.Occupations.Length + occCat) * Root.EmploymentStatuses.Length + empCat) * NumberOfModes); }
/// <summary> /// Creates a new person /// </summary> /// <param name="household">The household that this person belongs to, may not be null!</param> /// <param name="id">The identifyer for this person</param> /// <param name="age">The age of this person</param> /// <param name="employmentStatus">How this person is employed, if at all</param> /// <param name="studentStatus">If this person is a student, and if so what type of student</param> /// <param name="female">Is this person female</param> /// <param name="licence">Does this person have a driver's licence</param> public Person(ITashaHousehold household, int id, int age, Occupation occupation, TTSEmploymentStatus employmentStatus, StudentStatus studentStatus, bool license, bool female) : this() { Household = household; Id = id; Age = age; Occupation = occupation; EmploymentStatus = employmentStatus; StudentStatus = studentStatus; Licence = license; Female = female; }
/// <summary> /// Creates a new person /// </summary> /// <param name="household">The household that this person belongs to, may not be null!</param> /// <param name="id">The identifier for this person</param> /// <param name="age">The age of this person</param> /// <param name="occupation"></param> /// <param name="employmentStatus">How this person is employed, if at all</param> /// <param name="studentStatus">If this person is a student, and if so what type of student</param> /// <param name="license"></param> /// <param name="female">Is this person female</param> public Person(ITashaHousehold household, int id, int age, Occupation occupation, TTSEmploymentStatus employmentStatus, StudentStatus studentStatus, bool license, bool female) : this() { Household = household; Id = id; Age = age; Occupation = occupation; EmploymentStatus = employmentStatus; StudentStatus = studentStatus; Licence = license; Female = female; }
/// <summary> /// Creates a new person /// </summary> /// <param name="household">The household that this person belongs to, may not be null!</param> /// <param name="id">The identifyer for this person</param> /// <param name="age">The age of this person</param> /// <param name="employmentStatus">How this person is employed, if at all</param> /// <param name="studentStatus">If this person is a student, and if so what type of student</param> /// <param name="female">Is this person female</param> /// <param name="licence">Does this person have a driver's licence</param> public Person(ITashaHousehold household, int id, int age, Occupation occupation, TTSEmploymentStatus employmentStatus, StudentStatus studentStatus, bool license, bool female) : this() { this.Household = household; this.Id = id; this.Age = age; this.Occupation = occupation; this.EmploymentStatus = employmentStatus; this.StudentStatus = studentStatus; this.Licence = license; this.Female = female; }
private void SaveWorkerData(IZone[] zones, Occupation occupation, TTSEmploymentStatus empStat, float[] workers) { using (StreamWriter writer = new StreamWriter(BuildFileName(occupation, empStat, WorkerForceDirectory))) { writer.WriteLine("Zone,Persons"); for (int i = 0; i < workers.Length; i++) { if (workers[i] > 0) { writer.Write(zones[i].ZoneNumber); writer.Write(','); writer.WriteLine(workers[i]); } } } }
internal bool AddIfEquals(int ageCat, Occupation occ, TTSEmploymentStatus empStat, bool dlic, bool female, float expFac) { if ( this.AgeCat == ageCat & this.Female == female & this.Occupation == occ & this.EmploymentStatus == empStat & this.DriversLicense == dlic ) { lock (this) { this.ExpansionFactor += expFac; } return(true); } return(false); }
private static char GetEmploymentChar(TTSEmploymentStatus employmentStatus) { switch (employmentStatus) { case TTSEmploymentStatus.FullTime: return('F'); case TTSEmploymentStatus.PartTime: return('P'); case TTSEmploymentStatus.WorkAtHome_FullTime: return('H'); case TTSEmploymentStatus.WorkAtHome_PartTime: return('J'); default: return('O'); } }
private string BuildFileName(Occupation occ, TTSEmploymentStatus empStat, FileLocation fileLocation) { var dirPath = fileLocation.GetFilePath(); var info = new DirectoryInfo(dirPath); if (!info.Exists) { info.Create(); } StringBuilder buildFileName = new StringBuilder(); switch (occ) { case Occupation.Professional: buildFileName.Append("P"); break; case Occupation.Office: buildFileName.Append("G"); break; case Occupation.Retail: buildFileName.Append("S"); break; case Occupation.Manufacturing: buildFileName.Append("M"); break; } switch (empStat) { case TTSEmploymentStatus.FullTime: buildFileName.Append("F.csv"); break; case TTSEmploymentStatus.PartTime: buildFileName.Append("P.csv"); break; } return(Path.Combine(dirPath, buildFileName.ToString())); }
private void SaveWorkerData(IZone[] zones, Occupation occupation, TTSEmploymentStatus empStat, float[] workers) { using (StreamWriter writer = new StreamWriter(BuildFileName(occupation, empStat, WorkerForceDirectory))) { writer.WriteLine("Zone,Persons"); for(int i = 0; i < workers.Length; i++) { if(workers[i] > 0) { writer.Write(zones[i].ZoneNumber); writer.Write(','); writer.WriteLine(workers[i]); } } } }
private void SaveWorkerCategoryData(IZone[] zones, Occupation occupation, TTSEmploymentStatus empStat, float[][] workers) { using (StreamWriter writer = new StreamWriter(BuildFileName(occupation, empStat, WorkerCategoryDirectory))) { writer.WriteLine("Zone,WorkerCategory,Persons"); for(int i = 0; i < workers.Length; i++) { var factor = 1.0f / workers[i].Sum(); if(float.IsNaN(factor)) { continue; } for(int cat = 0; cat < workers[i].Length; cat++) { workers[i][cat] *= factor; } for(int cat = 0; cat < workers[i].Length; cat++) { if(workers[i][cat] > 0) { writer.Write(zones[i].ZoneNumber); writer.Write(','); writer.Write(cat + 1); writer.Write(','); writer.WriteLine(workers[i][cat]); } } } } }
private string BuildFileName(Occupation occ, TTSEmploymentStatus empStat, FileLocation fileLocation) { var dirPath = fileLocation.GetFilePath(); var info = new DirectoryInfo(dirPath); if(!info.Exists) { info.Create(); } StringBuilder buildFileName = new StringBuilder(); switch(occ) { case Occupation.Professional: buildFileName.Append("P"); break; case Occupation.Office: buildFileName.Append("G"); break; case Occupation.Retail: buildFileName.Append("S"); break; case Occupation.Manufacturing: buildFileName.Append("M"); break; } switch(empStat) { case TTSEmploymentStatus.FullTime: buildFileName.Append("F.csv"); break; case TTSEmploymentStatus.PartTime: buildFileName.Append("P.csv"); break; } return Path.Combine(dirPath, buildFileName.ToString()); }
internal bool AddIfEquals(int ageCat, Occupation occ, TTSEmploymentStatus empStat, bool dlic, bool female, float expFac) { if ( this.AgeCat == ageCat & this.Female == female & this.Occupation == occ & this.EmploymentStatus == empStat & this.DriversLicense == dlic ) { lock ( this ) { this.ExpansionFactor += expFac; } return true; } return false; }
/// <summary> /// Creates a new person /// </summary> /// <param name="household">The household that this person belongs to, may not be null!</param> /// <param name="id">The identifyer for this person</param> /// <param name="age">The age of this person</param> /// <param name="employmentStatus">How this person is employed, if at all</param> /// <param name="studentStatus">If this person is a student, and if so what type of student</param> /// <param name="female">Is this person female</param> /// <param name="licence">Does this person have a driver's licence</param> public Person(ITashaHousehold household, int id, int age, Occupation occupation, TTSEmploymentStatus employmentStatus, StudentStatus studentStatus, bool license, bool female) : this() { this.Household = household; this.Id = id; this.Age = age; this.Occupation = occupation; this.EmploymentStatus = employmentStatus; this.StudentStatus = studentStatus; this.Licence = license; this.Female = female; }