Beispiel #1
0
        public static HouseholdWorkSchoolProjectStatus GetWorkSchoolProjectStatus(ITashaHousehold household)
        {
            bool evening_workschool = false;
            bool morning_workschool = false;
            bool any_workschool     = false;

            foreach (var person in household.Persons)
            {
                PersonWorkSchoolProjectStatus workschoolProjectStatus = SchedulerPerson.GetWorkSchoolProjectStatus(person);
                if (workschoolProjectStatus == PersonWorkSchoolProjectStatus.FullTimeEveningWorkOrSchool ||
                    workschoolProjectStatus == PersonWorkSchoolProjectStatus.FullTimeDayAndEveningWorkOrSchool ||
                    workschoolProjectStatus == PersonWorkSchoolProjectStatus.Other)
                {
                    evening_workschool = true;
                }
                if (workschoolProjectStatus == PersonWorkSchoolProjectStatus.FullTimeNoEveningWorkOrSchool ||
                    workschoolProjectStatus == PersonWorkSchoolProjectStatus.FullTimeDayAndEveningWorkOrSchool ||
                    workschoolProjectStatus == PersonWorkSchoolProjectStatus.PartTimeDay ||
                    workschoolProjectStatus == PersonWorkSchoolProjectStatus.PartTimeEvening)
                {
                    morning_workschool = true;
                }
                if (workschoolProjectStatus > 0)
                {
                    any_workschool = true;
                }
            }

            if (!any_workschool)
            {
                return(HouseholdWorkSchoolProjectStatus.NoWorkOrSchool);                  // noone in hhld works or attends school today
            }
            else if (!evening_workschool)
            {
                return(HouseholdWorkSchoolProjectStatus.NoEveningWorkOrSchool);                          //there is work/school, but none after 6:00pm
            }
            else if (!morning_workschool)
            {
                return(HouseholdWorkSchoolProjectStatus.EveningWorkOrSchool);                          //there is evening work/school, but no work/school before 1:00pm
            }
            else
            {
                return(HouseholdWorkSchoolProjectStatus.DayAndEveningWorkOrSchool); // there is work/school before 1pm and after 6pm
            }
        }
Beispiel #2
0
        /// <summary>
        /// Returns the distribution ID that this person belongs to
        /// </summary>
        /// <param name="person"></param>
        /// <returns></returns>
        internal static int GetDistributionID(ITashaPerson person, Activity activity)
        {
            int baseOffset       = 0;
            int ageOffset        = 0;
            int occupationOffset = 0;
            int age = person.Age;

            switch (activity)
            {
            case Activity.School:
                baseOffset       = 84;
                ageOffset        = 0;
                occupationOffset = 0;
                //Now Calculate the occupation offset
                switch (person.StudentStatus)
                {
                case StudentStatus.FullTime:
                    occupationOffset = 0;
                    break;

                case StudentStatus.PartTime:
                    occupationOffset = 1;
                    break;

                default:
                    return(-1);
                }
                if (age < 11)
                {
                    return(-1);
                }
                //Calculate the ageOffset
                if (age <= 15)
                {
                    ageOffset = 0;
                }
                else if (age <= 18)
                {
                    ageOffset = 1;
                }
                else if (age <= 25)
                {
                    ageOffset = 2;
                }
                else if (age <= 30)
                {
                    ageOffset = 3;
                }
                else
                {
                    ageOffset = 4;
                }
                return(baseOffset + (ageOffset * 2) + occupationOffset);

            case Activity.WorkBasedBusiness:
                // We store the values from the person to improve performance
                baseOffset       = 40;
                ageOffset        = 0;
                occupationOffset = 0;
                Tasha.Common.Occupation occupation = person.Occupation;
                if (person.EmploymentStatus != TTSEmploymentStatus.FullTime &&
                    person.EmploymentStatus != TTSEmploymentStatus.PartTime)
                {
                    return(-1);
                }
                //Calculate the ageOffset
                if (age < 11)
                {
                    return(-1);
                }
                else if (age <= 18)
                {
                    ageOffset = 0;
                }
                else if (age <= 25)
                {
                    ageOffset = 1;
                }
                else if (age <= 64)
                {
                    ageOffset = 2;
                }
                else
                {
                    ageOffset = 3;
                }

                //Now Calculate the occupation offset
                if (occupation == Occupation.Office)
                {
                    occupationOffset = 0;
                }
                else if (occupation == Occupation.Manufacturing)
                {
                    occupationOffset = 1;
                }
                else if (occupation == Occupation.Professional)
                {
                    occupationOffset = 2;
                }
                else if (occupation == Occupation.Retail)
                {
                    occupationOffset = 3;
                }
                else
                {
                    return(-1);
                }

                return(baseOffset + (ageOffset * 8) + occupationOffset * 2
                       + (person.EmploymentStatus == TTSEmploymentStatus.FullTime ? 0 : 1));

            case Activity.PrimaryWork:
                // We store the values from the person to improve performance
                if (person.EmploymentZone == null)
                {
                    return(-1);
                }
                ageOffset        = 0;
                occupationOffset = 0;
                occupation       = person.Occupation;
                if (person.EmploymentStatus != TTSEmploymentStatus.FullTime &&
                    person.EmploymentStatus != TTSEmploymentStatus.PartTime)
                {
                    return(-1);
                }
                //Calculate the ageOffset
                if (age < 11)
                {
                    return(-1);
                }
                else if (age <= 18)
                {
                    ageOffset = 0;
                }
                else if (age <= 25)
                {
                    ageOffset = 1;
                }
                else if (age <= 64)
                {
                    ageOffset = 2;
                }
                else
                {
                    ageOffset = 3;
                }
                //Now Calculate the occupation offset
                if (occupation == Occupation.Office)
                {
                    occupationOffset = 0;
                }
                else if (occupation == Occupation.Manufacturing)
                {
                    occupationOffset = 1;
                }
                else if (occupation == Occupation.Professional)
                {
                    occupationOffset = 2;
                }
                else if (occupation == Occupation.Retail)
                {
                    occupationOffset = 3;
                }
                else
                {
                    return(-1);
                }

                return((ageOffset * 8) + occupationOffset * 2
                       + (person.EmploymentStatus == TTSEmploymentStatus.FullTime ? 0 : 1));

            case Activity.SecondaryWork:
                // We store the values from the person to improve performance
                baseOffset       = 32;
                occupationOffset = 0;
                occupation       = person.Occupation;
                if (person.EmploymentZone == null)
                {
                    return(-1);
                }
                if (person.EmploymentStatus != TTSEmploymentStatus.FullTime &&
                    person.EmploymentStatus != TTSEmploymentStatus.PartTime)
                {
                    return(-1);
                }
                if (person.Age < 11)
                {
                    return(-1);
                }
                //Now Calculate the occupation offset
                if (occupation == Occupation.Office)
                {
                    occupationOffset = 0;
                }
                else if (occupation == Occupation.Manufacturing)
                {
                    occupationOffset = 1;
                }
                else if (occupation == Occupation.Professional)
                {
                    occupationOffset = 2;
                }
                else if (occupation == Occupation.Retail)
                {
                    occupationOffset = 3;
                }
                else
                {
                    return(-1);
                }

                // Ok, here we do the math, there are 8 distros per age group [only 1 age group]
                // Each one is broken into 4 occupation types
                // Each of them are broken into first, full-time then part-time
                return
                    (baseOffset + occupationOffset * 2
                     + (person.EmploymentStatus == TTSEmploymentStatus.FullTime ? 0 : 1));

            case Activity.WorkAtHomeBusiness:
                // We store the values from the person to improve performance
                baseOffset       = 72;
                ageOffset        = 0;
                occupationOffset = 0;
                occupation       = person.Occupation;
                age = person.Age;
                if (person.EmploymentStatus != TTSEmploymentStatus.WorkAtHome_FullTime &&
                    person.EmploymentStatus != TTSEmploymentStatus.WorkAtHome_PartTime)
                {
                    return(-1);
                }
                //Calculate the ageOffset
                if (age < 19)
                {
                    return(-1);
                }
                else if (age <= 25)
                {
                    ageOffset = 0;
                }
                else if (age <= 64)
                {
                    ageOffset = 1;
                }
                else
                {
                    ageOffset = 2;
                }

                //Now Calculate the occupation offset
                if (occupation == Occupation.Office)
                {
                    occupationOffset = 0;
                }
                else if (occupation == Occupation.Manufacturing)
                {
                    occupationOffset = 1;
                }
                else if (occupation == Occupation.Professional)
                {
                    occupationOffset = 2;
                }
                else if (occupation == Occupation.Retail)
                {
                    occupationOffset = 3;
                }

                // Ok, here we do the math, there are 8 distros per age group
                // Each one is broken into 4 occupation types
                // Each of them are broken into first, full-time then part-time
                return(baseOffset + (ageOffset * 4) + occupationOffset);

            case Activity.ReturnFromWork:
                // We store the values from the person to improve performance
                baseOffset       = 94;
                occupationOffset = 0;
                occupation       = person.Occupation;
                if (person.EmploymentStatus != TTSEmploymentStatus.FullTime &&
                    person.EmploymentStatus != TTSEmploymentStatus.PartTime)
                {
                    return(-1);
                }
                //Now Calculate the occupation offset
                if (occupation == Occupation.Office)
                {
                    occupationOffset = 0;
                }
                else if (occupation == Occupation.Manufacturing)
                {
                    occupationOffset = 1;
                }
                else if (occupation == Occupation.Professional)
                {
                    occupationOffset = 2;
                }
                else if (occupation == Occupation.Retail)
                {
                    occupationOffset = 3;
                }

                // Ok, here we do the math, there are 8 distros per age group [only 1 age group]
                // Each one is broken into 4 occupation types
                // Each of them are broken into first, full-time then part-time
                return
                    (baseOffset + occupationOffset * 2 + (person.EmploymentStatus == TTSEmploymentStatus.FullTime ? 0 : 1));

            case Activity.IndividualOther:
                baseOffset       = 102;
                ageOffset        = 0;
                occupationOffset = 0;
                //||[0,6] ||==7
                PersonWorkSchoolProjectStatus workProjestStatus = SchedulerPerson.GetWorkSchoolProjectStatus(person);
                age = person.Age;

                //Calculate the ageOffset
                if (age < 11)
                {
                    return(-1);
                }
                else if (age < 16)
                {
                    ageOffset = 0;
                }
                else if (age < 25)
                {
                    ageOffset = 1;
                }
                else if (age < 65)
                {
                    ageOffset = 2;
                }
                else
                {
                    ageOffset = 3;
                }
                //
                return
                    (baseOffset + (ageOffset * 14) + (person.Female ? 7 : 0) + (int)workProjestStatus);

            case Activity.Market:
                baseOffset       = 182;
                ageOffset        = 0;
                occupationOffset = 0;
                //||[0,6] ||==7
                workProjestStatus = SchedulerPerson.GetWorkSchoolProjectStatus(person);
                age = person.Age;

                //Calculate the ageOffset
                if (age < 11)
                {
                    return(-1);
                }
                else if (age < 16)
                {
                    ageOffset = 0;
                }
                else if (age < 25)
                {
                    ageOffset = 1;
                }
                else if (age < 65)
                {
                    ageOffset = 2;
                }
                else
                {
                    ageOffset = 3;
                }
                // Ok, here we do the math, there are 8 distros per age group
                // Each one is broken into 4 occupation types
                // Each of them are broken into first, full-time then part-time
                return
                    (baseOffset + (ageOffset * 14) + (person.Female ? 7 : 0) + (int)workProjestStatus);

            default:
                return(-1);
            }
        }