Beispiel #1
0
 private Person(Person original)
 {
     Type = AgentType.Person;
     //copy the values
     ZoneID = original.ZoneID;
     Age = original.Age;
     Sex = original.Sex;
     HouseholdSize = original.HouseholdSize;
     EducationLevel = original.EducationLevel;
 }
Beispiel #2
0
 private Person(Person original)
 {
     Type = AgentType.Person;
     //copy the values
     ZoneID = original.ZoneID;
     Age = original.Age;
     Sex = original.Sex;
     EducationLevel = original.EducationLevel;
     Occupation = original.Occupation;
     PublicTransitPass = original.PublicTransitPass;
     EmploymentStatus = original.EmploymentStatus;
     DrivingLicense = original.DrivingLicense;
     household = original.household;
     myID = idCounter++;
 }
Beispiel #3
0
 public override SimulationObject CreateNewCopy(string baseDim,
     int baseDimVal)
 {
     Person copy = new Person(this);
     // apply the new change
     switch(baseDim)
     {
         case "Age":
             copy.Age = (Age)baseDimVal;
             break;
         case "Sex":
             copy.Sex = (Sex)baseDimVal;
             break;
         case "HouseholdSize2":
             copy.HouseholdSize = (HouseholdSize2)baseDimVal;
             break;
         case "EducationLevel":
             copy.EducationLevel = (EducationLevel)baseDimVal;
             break;
         default:
             return null;
     }
     return copy;
 }
Beispiel #4
0
 private double ComputeDriverLisenceProbablities(string category,
                          Person person)
 {
     var valList = GetUtilityValuesForDriverLicense(person);
     double logsum = ((double)valList[0]
                              + (double)valList[1]
                              + (double)valList[2]);
     if (int.Parse(category) ==
         (int)DrivingLicense.Yes)
     {
         return ((double)valList[0] / logsum);
     }
     else if (int.Parse(category) ==
         (int)DrivingLicense.No)
     {
         return ((double)valList[1] / logsum);
     }
     else if (int.Parse(category) ==
         (int)DrivingLicense.Unkown)
     {
         return ((double)valList[2] / logsum);
     }
     return 0.00;
 }
Beispiel #5
0
        private List<KeyValPair> ComputeDriverLisenceCommulative(Person person)
        {
            double comVal = 0.00;
            var comList = new List<KeyValPair>();
            var valList = GetUtilityValuesForDriverLicense(person);
            KeyValPair currPair = new KeyValPair();
            double utilSum = (double)valList[0] + (double)valList[1];
            currPair.Category = "0";//IncomeLevel.yes.ToString();
            currPair.Value = (double)valList[0] / utilSum;
            comVal = currPair.Value;
            comList.Add(currPair);

            currPair = new KeyValPair();
            currPair.Category = "1";//IncomeLevel.no.ToString();
            currPair.Value = comVal + (double)valList[1] / utilSum;
            comVal = currPair.Value;
            comList.Add(currPair);

            return comList;
        }
Beispiel #6
0
        private List<double> GetUtilityValuesForSex(Person person)
        {
            var currValues = new List<double>(2);

            currValues.Add(1);

            int twoAdultsChildren = Convert.ToInt32(person.GetHhld().GetHhldSize() == HouseholdSize.TwoAdultsChildren);
            int twoPlusAdults = Convert.ToInt32(person.GetHhld().GetHhldSize() == HouseholdSize.Twoadults
                || person.GetHhld().GetHhldSize() == HouseholdSize.ThreeOrMoreAdults);
            int twoPlusAdultsChildren = Convert.ToInt32(person.GetHhld().GetHhldSize() == HouseholdSize.TwoAdultsChildren
                || person.GetHhld().GetHhldSize() == HouseholdSize.ThreeOrMoreAdultsChildren);
            int threePlusCars = Convert.ToInt32(person.GetHhld().GetNumOfCars() == NumOfCars.ThreeOrMore);
            int lNo = Convert.ToInt32(person.GetDrivingLicense() == DrivingLicense.No);
            int homeFT = Convert.ToInt32(person.GetEmploymentStatus() == EmploymentStatus.FullTimeHome);
            int homePT = Convert.ToInt32(person.GetEmploymentStatus() == EmploymentStatus.PartTimeHome);
            int PT = Convert.ToInt32(person.GetEmploymentStatus() == EmploymentStatus.PartTime);
            int town = Convert.ToInt32(person.GetHhld().GetDwellingType() == DwellingType.Townhouse);
            int manConst = Convert.ToInt32(person.GetOccupation() == Occupation.Construction);
            int profMan = Convert.ToInt32(person.GetOccupation() == Occupation.TradesProfessional);
            int retail = Convert.ToInt32(person.GetOccupation() == Occupation.TechnicalRetailSalesServiceNotEmployedUnknown);
            int oNE = Convert.ToInt32(person.GetEmploymentStatus() == EmploymentStatus.Unemployed);
            int eleven = Convert.ToInt32(person.GetAge() == Age.ElevenToThirteen);
            int sixteen = Convert.ToInt32(person.GetAge() == Age.SixteenToSeventeen);
            int eighteen = Convert.ToInt32(person.GetAge() == Age.EighteenToTwentyFive);
            int twentysix = Convert.ToInt32(person.GetAge() == Age.TwentySixToThirty);
            int fortyone = Convert.ToInt32(person.GetAge() == Age.FortyOneToFifty);
            int fiftyone = Convert.ToInt32(person.GetAge() == Age.FiftyOneToFiftyFour);
            int fiftyfive = Convert.ToInt32(person.GetAge() == Age.FiftyfiveToSixtyFour);
            int sixtyfivePlus = Convert.ToInt32(person.GetAge() == Age.MoreThanSixtyFive);

            currValues.Add(Math.Exp(0.436 * 1.00 + -0.261 * twoAdultsChildren + -0.174 * twoPlusAdults
                + -0.222 * twoPlusAdultsChildren + 0.0472 * threePlusCars + 0.443 * lNo + -0.267 * homeFT
                + 0.530 * homePT + 0.900 * PT + 0.0508 * town + -2.33 * manConst + -0.733 * profMan
                + -0.824 * retail + -0.329 * oNE + -0.451 * eleven + -0.354 * sixteen + -0.154 * eighteen
                + 0.371 * twentysix + 0.428 * fortyone + 0.326 * fiftyone + 0.216 * fiftyfive + -0.0818 * sixtyfivePlus));

            return currValues;
        }
Beispiel #7
0
        private List<double> GetUtilityValuesForOccupation(Person person, SpatialZone curZ)
        {
            var currValues = new List<double>(5);

            currValues.Add(1);

            int twoAdultsChildren = Convert.ToInt32(person.GetHhld().GetHhldSize() == HouseholdSize.TwoAdultsChildren);
            int twoPlusAdultsChildren = Convert.ToInt32(person.GetHhld().GetHhldSize() == HouseholdSize.TwoAdultsChildren
                || person.GetHhld().GetHhldSize() == HouseholdSize.ThreeOrMoreAdultsChildren);
            int homeFT = Convert.ToInt32(person.GetEmploymentStatus() == EmploymentStatus.FullTimeHome);
            int homePT = Convert.ToInt32(person.GetEmploymentStatus() == EmploymentStatus.PartTimeHome);
            int PT = Convert.ToInt32(person.GetEmploymentStatus() == EmploymentStatus.PartTime);
            int apart = Convert.ToInt32(person.GetHhld().GetDwellingType() == DwellingType.Apartment);
            int eighteen = Convert.ToInt32(person.GetAge() == Age.EighteenToTwentyFive);
            int twentysix = Convert.ToInt32(person.GetAge() == Age.TwentySixToThirty);
            int fortyone = Convert.ToInt32(person.GetAge() == Age.FortyOneToFifty);
            int fiftyone = Convert.ToInt32(person.GetAge() == Age.FiftyOneToFiftyFour);
            int fiftyfive = Convert.ToInt32(person.GetAge() == Age.FiftyfiveToSixtyFour);
            int thirtyone = Convert.ToInt32(person.GetAge() == Age.ThirtyOneToForty);
            int threePlusCars = Convert.ToInt32(person.GetHhld().GetNumOfCars() == NumOfCars.ThreeOrMore);

            double z_manConst = curZ.GetPersonOccuMarginal().GetValue("1");

            int oneAdultChildren = Convert.ToInt32(person.GetHhld().GetHhldSize() == HouseholdSize.OneAdultOneChild);
            int twoAdults = Convert.ToInt32(person.GetHhld().GetHhldSize() == HouseholdSize.Twoadults);
            int twoPlusAdults = Convert.ToInt32(person.GetHhld().GetHhldSize() == HouseholdSize.ThreeOrMoreAdults
                || person.GetHhld().GetHhldSize() == HouseholdSize.Twoadults);
            int oneCar = Convert.ToInt32(person.GetHhld().GetNumOfCars() == NumOfCars.OneCar);
            int twoCars = Convert.ToInt32(person.GetHhld().GetNumOfCars() == NumOfCars.TwoCars);

            currValues.Add(Math.Exp(-1.95 * 1.00 + -0.746 * oneAdultChildren + 0.280 * twoAdults + 0.594 * twoAdultsChildren
                + 0.556 * twoPlusAdults + 0.827 * twoPlusAdultsChildren + 0.247 * apart + 0.0751 * oneCar + 0.0867 * threePlusCars
                + 2.13 * homeFT + 0.237 * homePT + 0.841 * PT + -0.106 * eighteen + -0.123 * twentysix + -0.137 * thirtyone
                + 0.145 * fiftyone + 0.140 * fiftyfive + 16.1 * z_manConst));

            int town = Convert.ToInt32(person.GetHhld().GetDwellingType() == DwellingType.Townhouse);
            int fourteen = Convert.ToInt32(person.GetAge() == Age.FourteenToFifteen);
            int sixteen = Convert.ToInt32(person.GetAge() == Age.SixteenToSeventeen);
            int sixtyfivePlus = Convert.ToInt32(person.GetAge() == Age.MoreThanSixtyFive);

            double z_profMan = curZ.GetPersonOccuMarginal().GetValue("2");

            currValues.Add(Math.Exp(-0.648 * 1.00 + -0.0753 * twoAdults + 0.121 * twoAdultsChildren + -0.243 * twoPlusAdults
                + -0.110 * twoPlusAdultsChildren + -0.265 * apart + -0.147 * town + 0.271 * oneCar + 0.337 * twoCars + 0.303 * threePlusCars
                + 2.31 * homeFT + -1.02 * fourteen + -0.866 * sixteen + -0.389 * eighteen + 0.0738 * thirtyone + 0.229 * sixtyfivePlus
                + 7.22 * z_profMan));

            int eleven = Convert.ToInt32(person.GetAge() == Age.ElevenToThirteen);
            double z_retail = curZ.GetPersonOccuMarginal().GetValue("3");

            currValues.Add(Math.Exp(-1.05 * 1.00 + 0.308 * oneAdultChildren + 0.205 * twoAdults + 0.479 * twoAdultsChildren + 0.379 * twoPlusAdults
                + 0.781 * twoPlusAdultsChildren + 0.220 * apart + 0.108 * town + -0.152 * oneCar + -0.245 * twoCars + -0.27 * threePlusCars
                + 2.85 * homeFT + 1.48 * homePT + 2.30 * PT + 3.90 * eleven + 2.20 * fourteen + 2.22 * sixteen + 0.507 * eighteen
                + 0.160 * twentysix + 0.0563 * fiftyone + 0.129 * fiftyfive + 0.398 * sixtyfivePlus + 6.32 * z_retail));

            double z_oNE = curZ.GetPersonOccuMarginal().GetValue("4");

            currValues.Add(Math.Exp(0.743 * 1.00 + 2.37 * oneAdultChildren + 0.298 * twoAdults + 2.47 * twoAdultsChildren + 0.437 * twoPlusAdults
                + 2.12 * twoPlusAdultsChildren + 0.114 * apart + -0.0672 * town + -0.63 * oneCar + -1.08 * twoCars + -1.33 * threePlusCars
                + 8.71 * eleven + 5.34 * fourteen + 3.87 * sixteen + 0.969 * eighteen + -0.842 * twentysix + -1.70 * thirtyone
                + -0.528 * fiftyone + 0.517 * fiftyfive + 3.08 * sixtyfivePlus + 0.854 * z_oNE));

            return currValues;
        }
Beispiel #8
0
        private double ComputeAgeProbablities(string category,
                                 Person person)
        {
            var valList = GetUtilityValuesForAge(person);
            double logsum = ((double)valList[0]
                                     + (double)valList[1]
                                     + (double)valList[2]
                                     + (double)valList[3]
                                     + (double)valList[4]
                                     + (double)valList[5]
                                     + (double)valList[6]
                                     + (double)valList[7]
                                     + (double)valList[8]
                                     + (double)valList[9]
                                     + (double)valList[10]);
            if (int.Parse(category) ==
                (int)Age.LessThanEleven)
            {
                return ((double)valList[0] / logsum);
            }
            else if (int.Parse(category) ==
                (int)Age.ElevenToThirteen)
            {
                return ((double)valList[1] / logsum);
            }
            else if (int.Parse(category) ==
                (int)Age.FourteenToFifteen)
            {
                return ((double)valList[2] / logsum);
            }
            else if (int.Parse(category) ==
                (int)Age.SixteenToSeventeen)
            {
                return ((double)valList[3] / logsum);
            }
            else if (int.Parse(category) ==
                (int)Age.EighteenToTwentyFive)
            {
                return ((double)valList[4] / logsum);
            }
            else if (int.Parse(category) ==
                 (int)Age.TwentySixToThirty)
            {
                return ((double)valList[5] / logsum);
            }
            else if (int.Parse(category) ==
                 (int)Age.ThirtyOneToForty)
            {
                return ((double)valList[6] / logsum);
            }
               else if (int.Parse(category) ==
                 (int)Age.FortyOneToFifty)
            {
                return ((double)valList[7] / logsum);
            }
            else if (int.Parse(category) ==
                 (int)Age.FiftyOneToFiftyFour)
            {
                return ((double)valList[8] / logsum);
            }
             else if (int.Parse(category) ==
                 (int)Age.FiftyfiveToSixtyFour)
            {
                return ((double)valList[9] / logsum);
            }
            else if (int.Parse(category) ==
                 (int)Age.MoreThanSixtyFive)
            {
                return ((double)valList[10] / logsum);
            }

            return 0.00;
        }
        private void updateCounts(Person person)
        {
            {
                switch (person.GetAge())
                {
                    case (Age.LessThanEleven):
                        {
                            count_less11++;
                            break;
                        }
                    case (Age.ElevenToThirteen):
                        {
                            count_11++;
                            break;
                        }
                    case (Age.FourteenToFifteen):
                        {
                            count_14++;
                            break;
                        }
                    case (Age.SixteenToSeventeen):
                        {
                            count_16++;
                            break;
                        }
                    case (Age.EighteenToTwentyFive):
                        {
                            count_18++;
                            break;
                        }
                    case (Age.TwentySixToThirty):
                        {
                            count_26++;
                            break;
                        }
                    case (Age.ThirtyOneToForty):
                        {
                            count_31++;
                            break;
                        }
                    case (Age.FortyOneToFifty):
                        {
                            count_41++;
                            break;
                        }
                    case (Age.FiftyOneToFiftyFour):
                        {
                            count_51++;
                            break;
                        }
                    case (Age.FiftyfiveToSixtyFour):
                        {
                            count_55++;
                            break;
                        }
                    case (Age.MoreThanSixtyFive):
                        {
                            count_65++;
                            break;
                        }
                    default:
                        break;
                }
                switch (person.GetEmploymentStatus())
                {
                    case (EmploymentStatus.PartTime):
                        count_part_time++;
                        break;
                    case (EmploymentStatus.FullTimeHome):
                        count_full_time_home++;
                        break;
                    case (EmploymentStatus.FullTime):
                        count_full_time++;
                        break;
                    case (EmploymentStatus.PartTimeHome):
                        count_part_time_home++;
                        break;
                    case (EmploymentStatus.Unemployed):
                        count_unemployed++;
                        break;
                    default:
                        break;
                }
                switch (person.GetSex())
                {
                    case (Sex.Male):
                        count_male++;
                        break;
                    case (Sex.Female):
                        count_female++;
                        break;
                    default:
                        break;
                }
                switch (person.GetDrivingLicense())
                {
                    case (DrivingLicense.Yes):
                        count_driving_license_yes++;
                        break;
                    case (DrivingLicense.No):
                        count_driving_license_no++;
                        break;
                    default:
                        break;

                }
                switch (person.GetOccupation())
                {
                    case (Occupation.GeneralOffice):
                        {
                            count_general_office++;
                            break;
                        }
                    case (Occupation.ClericalManufacturing):
                        {
                            count_clerical_manufacturing++;
                            break;
                        }
                    case (Occupation.TradesProfessional):
                        {
                            count_professional_man++;
                            break;
                        }
                    case (Occupation.TechnicalRetailSalesServiceNotEmployedUnknown):
                        {
                            count_retail++;
                            break;
                        }
                    case (Occupation.Construction):
                        {
                            count_costruction_man++;
                            break;
                        }
                }
            }
        }
Beispiel #10
0
 public SimulationObject CreateNewCopy()
 {
     Person copy = new Person(this);
     return copy;
 }
Beispiel #11
0
        private List<double> GetUtilityValuesForAge(Person person)
        {
            var currValues = new List<double>(11);

            currValues.Add(1);

            int twoAdultsChildren = Convert.ToInt32(person.GetHhld().GetHhldSize() == HouseholdSize.TwoAdultsChildren);
            int oneCar = Convert.ToInt32(person.GetHhld().GetNumOfCars() == NumOfCars.OneCar);
            int twoCars = Convert.ToInt32(person.GetHhld().GetNumOfCars() == NumOfCars.TwoCars);
            int female = Convert.ToInt32(person.GetSex() == Sex.Female);
            int threePlusCars = Convert.ToInt32(person.GetHhld().GetNumOfCars() == NumOfCars.ThreeOrMore);

            currValues.Add(Math.Exp(-0.591 * 1.00 + -4.20 * twoAdultsChildren + 0.235 * oneCar + 0.271 * twoCars + -0.268 * threePlusCars
                + 0.153 * female));

            int twoAdults = Convert.ToInt32(person.GetHhld().GetHhldSize() == HouseholdSize.Twoadults);
            int manConst = Convert.ToInt32(person.GetOccupation() == Occupation.Construction);

            currValues.Add(Math.Exp(-0.916 * 1.00 + 1.27 * twoAdults + -4.87 * twoAdultsChildren + 0.227 * oneCar + 0.214 * twoCars
                + -0.138 * threePlusCars + 0.945 * manConst + 0.159 * female));

            int eNE = Convert.ToInt32(person.GetEmploymentStatus() == EmploymentStatus.Unemployed);

            currValues.Add(Math.Exp(2.92 * 1.00 + 1.44 * twoAdults + -5.21 * twoAdultsChildren + 0.152 * oneCar
                + 0.0860 * twoCars + -3.99 * eNE + -1.63 * manConst + 0.271 * female));

            int oneAdultChildren = Convert.ToInt32(person.GetHhld().GetHhldSize() == HouseholdSize.OneAdultOneChild);

            currValues.Add(Math.Exp(5.51 * 1.00 + -2.57 * oneAdultChildren + 2.31 * twoAdults + -4.19 * twoAdultsChildren
                + -0.598 * oneCar + -0.934 * twoCars + -0.106 * threePlusCars + -5.60 * eNE + 0.508 * female));

            int homeFT = Convert.ToInt32(person.GetEmploymentStatus() == EmploymentStatus.FullTimeHome);

            currValues.Add(Math.Exp(4.90 * 1.00 + -0.750 * oneAdultChildren + 3.72 * twoAdults + -1.45 * twoAdultsChildren
                + -0.880 * oneCar + -1.28 * twoCars + -0.309 * threePlusCars + 1.33 * homeFT + -6.66 * eNE
                + 0.381 * manConst + 0.950 * female));

            currValues.Add(Math.Exp(5.58 * 1.00 + -0.350 * oneAdultChildren + 3.55 * twoAdults + -0.381 * twoAdultsChildren
                + -0.706 * oneCar + -1.21 * twoCars + -1.10 * threePlusCars + 1.79 * homeFT + -6.91 * eNE
                + 0.476 * manConst + 1.14 * female));

            currValues.Add(Math.Exp(6.40 * 1.00 + -1.48 * oneAdultChildren + 3.13 * twoAdults + -1.98 * twoAdultsChildren
                + -0.639 * oneCar + -1.09 * twoCars + -1.17 * threePlusCars + 1.97 * homeFT + -7.04 * eNE
                + 0.567 * manConst + 0.978 * female));

            currValues.Add(Math.Exp(5.42 * 1.00 + -2.80 * oneAdultChildren + 3.71 * twoAdults + -3.73 * twoAdultsChildren
                + -0.796 * oneCar + -1.20 * twoCars + -0.655 * threePlusCars + 2.05 * homeFT + -6.74 * eNE
                + 0.600 * manConst + 0.891 * female));

            currValues.Add(Math.Exp(5.70 * 1.00 + -4.1 * oneAdultChildren + 4.44 * twoAdults + -4.58 * twoAdultsChildren
                + -0.717 * oneCar + -1.09 * twoCars + -0.424 * threePlusCars + 2.17 * homeFT + -5.83 * eNE
                + 0.496 * manConst + 0.813 * female));

            currValues.Add(Math.Exp(4.85 * 1.00 + -5.75 * oneAdultChildren + 4.80 * twoAdults + -5.69 * twoAdultsChildren
                + -0.902 * oneCar + -1.75 * twoCars + -1.44 * threePlusCars + 2.23 * homeFT + -3.44 * eNE
                + 0.513 * female));

            return currValues;
        }
Beispiel #12
0
        private double ComputeSexProbablities(string category,
                                   Person person)
        {
            var valList = GetUtilityValuesForSex(person);
            double logsum = ((double)valList[0]
                                     + (double)valList[1]);
            if (int.Parse(category) ==
                (int)Sex.Male)
            {
                return ((double)valList[0] / logsum);
            }
            else if (int.Parse(category) ==
                (int)Sex.Female)
            {
                return ((double)valList[1] / logsum);
            }

            return 0.00;
        }
Beispiel #13
0
 private double ComputeOccupationProbablities(string category,
                           Person person, SpatialZone curZ)
 {
     var valList = GetUtilityValuesForOccupation(person, curZ);
     double logsum = ((double)valList[0]
                              + (double)valList[1]
                              + (double)valList[2]
                              + (double)valList[3]
                              + (double)valList[4]
                              + (double)valList[5]);
     if (int.Parse(category) ==
         (int)Occupation.GeneralOffice)
     {
         return ((double)valList[0] / logsum);
     }
     else if (int.Parse(category) ==
         (int)Occupation.ClericalManufacturing)
     {
         return ((double)valList[1] / logsum);
     }
     else if (int.Parse(category) ==
         (int)Occupation.Construction)
     {
         return ((double)valList[2] / logsum);
     }
     else if (int.Parse(category) ==
         (int)Occupation.TradesProfessional)
     {
         return ((double)valList[3] / logsum);
     }
     else if (int.Parse(category) ==
         (int)Occupation.Management)
     {
         return ((double)valList[4] / logsum);
     }
     else if (int.Parse(category) ==
          (int)Occupation.TechnicalRetailSalesServiceNotEmployedUnknown)
     {
         return ((double)valList[5] / logsum);
     }
     return 0.00;
 }
Beispiel #14
0
        private List<KeyValPair> ComputeOccupationCommulative(Person person, SpatialZone curZ)
        {
            double comVal = 0.00;
            var comList = new List<KeyValPair>();
            var valList = GetUtilityValuesForOccupation(person, curZ);
            KeyValPair currPair = new KeyValPair();
            double utilSum = (double)valList[0] + (double)valList[1]
                                     + (double)valList[2]
                                     + (double)valList[3]
                                     + (double)valList[4];
            currPair.Category = "0";//IncomeLevel.GeneralOffice.ToString();
            currPair.Value = (double)valList[0] / utilSum;
            comVal = currPair.Value;
            comList.Add(currPair);

            currPair = new KeyValPair();
            currPair.Category = "1";//IncomeLevel.ClericalManufacturing.ToString();
            currPair.Value = comVal + (double)valList[1] / utilSum;
            comVal = currPair.Value;
            comList.Add(currPair);

            currPair = new KeyValPair();
            currPair.Category = "2";//IncomeLevel.Construction.ToString();
            currPair.Value = comVal + (double)valList[2] / utilSum;
            comVal = currPair.Value;
            comList.Add(currPair);

            currPair = new KeyValPair();
            currPair.Category = "3";//IncomeLevel.TradesProfessional.ToString();
            currPair.Value = comVal + (double)valList[3] / utilSum;
            comVal = currPair.Value;
            comList.Add(currPair);

            currPair = new KeyValPair();
            currPair.Category = "4";//IncomeLevel.Management.ToString();
            currPair.Value = comVal + (double)valList[4] / utilSum;
            comList.Add(currPair);

            return comList;
        }
Beispiel #15
0
        private List<KeyValPair> ComputeAgeCommulative(Person person)
        {
            double comVal = 0.00;
            var comList = new List<KeyValPair>();
            var valList = GetUtilityValuesForAge(person);
            KeyValPair currPair = new KeyValPair();
            double utilSum = (double)valList[0] + (double)valList[1]
                                     + (double)valList[2]
                                     + (double)valList[3]
                                     + (double)valList[4]
                                     + (double)valList[5]
                                     + (double)valList[6]
                                     + (double)valList[7]
                                     + (double)valList[8]
                                     + (double)valList[9]
                                     + (double)valList[10];
            currPair.Category = "0";//IncomeLevel.LessThanEleven.ToString();
            currPair.Value = (double)valList[0] / utilSum;
            comVal = currPair.Value;
            comList.Add(currPair);

            currPair = new KeyValPair();
            currPair.Category = "1";//IncomeLevel.ElevenToThirteen.ToString();
            currPair.Value = comVal + (double)valList[1] / utilSum;
            comVal = currPair.Value;
            comList.Add(currPair);

            currPair = new KeyValPair();
            currPair.Category = "2";//IncomeLevel.FourteenToFifteen.ToString();
            currPair.Value = comVal + (double)valList[2] / utilSum;
            comVal = currPair.Value;
            comList.Add(currPair);

            currPair = new KeyValPair();
            currPair.Category = "3";//IncomeLevel.SixteenToSeventeen.ToString();
            currPair.Value = comVal + (double)valList[3] / utilSum;
            comVal = currPair.Value;
            comList.Add(currPair);

            currPair = new KeyValPair();
            currPair.Category = "4";//IncomeLevel.EighteenToTwentyFive.ToString();
            currPair.Value = comVal + (double)valList[4] / utilSum;
            comList.Add(currPair);

            currPair = new KeyValPair();
            currPair.Category = "5";//IncomeLevel.TwentySixToThirty.ToString();
            currPair.Value = comVal + (double)valList[5] / utilSum;
            comList.Add(currPair);

            currPair = new KeyValPair();
            currPair.Category = "6";//IncomeLevel.ThirtyOneToForty.ToString();
            currPair.Value = comVal + (double)valList[6] / utilSum;
            comList.Add(currPair);

            currPair = new KeyValPair();
            currPair.Category = "7";//IncomeLevel.FortyOneToFifty.ToString();
            currPair.Value = comVal + (double)valList[7] / utilSum;
            comList.Add(currPair);

            currPair = new KeyValPair();
            currPair.Category = "8";//IncomeLevel.FiftyOneToFiftyFour.ToString();
            currPair.Value = comVal + (double)valList[8] / utilSum;
            comList.Add(currPair);

            currPair = new KeyValPair();
            currPair.Category = "9";//IncomeLevel.FiftyfiveToSixtyFour.ToString();
            currPair.Value = comVal + (double)valList[9] / utilSum;
            comList.Add(currPair);

            currPair = new KeyValPair();
            currPair.Category = "10";//IncomeLevel.MoreThanSixtyFive.ToString();
            currPair.Value = comVal + (double)valList[10] / utilSum;
            comList.Add(currPair);

            return comList;
        }
        public Person GetNextAgentPerson(DiscreteMarginalDistribution f_x,
            ConditionalDistribution g_x, string dimension,
                Person prvAgent, SpatialZone currZone)
        {
            KeyValPair currDimVal;
            double currProb = 0.00;
            double currRatio = 0.00;
            int cnt = 0;
            do
            {
                currDimVal = GenerateNextFromG_X(g_x, prvAgent, currZone,0);
                currProb = f_x.GetValue(currDimVal.Category);
                currRatio = currProb / currDimVal.Value;
                if (currRatio > 1.00)
                {
                    currRatio = 1.00;
                }
                if (cnt > 10000)
                {
                    currRatio = 1;
                }
                cnt++;
            } while (myRand.NextDouble() > currRatio);

            // Create the household object based on the currDimVal.category
            return (Person)prvAgent.CreateNewCopy(
                g_x.GetDimensionName(), Int16.Parse(currDimVal.Category),0);
        }
Beispiel #17
0
        private List<KeyValPair> ComputeEmploymentStatusCommulative(Person person)
        {
            double comVal = 0.00;
            var comList = new List<KeyValPair>();
            var valList = GetUtilityValuesForEmploymentStatus(person);
            KeyValPair currPair = new KeyValPair();
            double utilSum = (double)valList[0] + (double)valList[1]
                                     + (double)valList[2]
                                     + (double)valList[3]
                                     + (double)valList[4];
            currPair.Category = "0";//IncomeLevel.Unemployed.ToString();
            currPair.Value = (double)valList[0] / utilSum;
            comVal = currPair.Value;
            comList.Add(currPair);

            currPair = new KeyValPair();
            currPair.Category = "1";//IncomeLevel.FullTime.ToString();
            currPair.Value = comVal + (double)valList[1] / utilSum;
            comVal = currPair.Value;
            comList.Add(currPair);

            currPair = new KeyValPair();
            currPair.Category = "2";//IncomeLevel.FullTimeHome.ToString();
            currPair.Value = comVal + (double)valList[2] / utilSum;
            comVal = currPair.Value;
            comList.Add(currPair);

            currPair = new KeyValPair();
            currPair.Category = "3";//IncomeLevel.PartTime.ToString();
            currPair.Value = comVal + (double)valList[3] / utilSum;
            comVal = currPair.Value;
            comList.Add(currPair);

            currPair = new KeyValPair();
            currPair.Category = "4";//IncomeLevel.PartTimeHome.ToString();
            currPair.Value = comVal + (double)valList[4] / utilSum;
            comList.Add(currPair);

            return comList;
        }
Beispiel #18
0
 private double ComputeEmploymentStatusProbablities(string category,
                           Person person)
 {
     var valList = GetUtilityValuesForEmploymentStatus(person);
     double logsum = ((double)valList[0]
                              + (double)valList[1]
                              + (double)valList[2]
                              + (double)valList[3]
                              + (double)valList[4]
                              + (double)valList[5]);
     if (int.Parse(category) ==
         (int)EmploymentStatus.Unemployed)
     {
         return ((double)valList[0] / logsum);
     }
     else if (int.Parse(category) ==
         (int)EmploymentStatus.FullTime)
     {
         return ((double)valList[1] / logsum);
     }
     else if (int.Parse(category) ==
         (int)EmploymentStatus.FullTimeHome)
     {
         return ((double)valList[2] / logsum);
     }
     else if (int.Parse(category) ==
         (int)EmploymentStatus.PartTime)
     {
         return ((double)valList[3] / logsum);
     }
     else if (int.Parse(category) ==
         (int)EmploymentStatus.PartTimeHome)
     {
         return ((double)valList[4] / logsum);
     }
     return 0.00;
 }
Beispiel #19
0
        public override SimulationObject CreateNewCopy(string baseDim,
            int baseDimVal, int personId)
        {
            Person copy = new Person(this);
            // apply the new change
            switch(baseDim)
            {
                case "Age":
                    copy.Age = (Age)baseDimVal;
                    break;
                case "Sex":
                    copy.Sex = (Sex)baseDimVal;
                    break;
                case "Occupation":
                    copy.Occupation = (Occupation)baseDimVal;
                    break;
                case "PublicTransitPass":
                    copy.PublicTransitPass = (PublicTransitPass)baseDimVal;
                    break;

                case "EducationLevel":
                    copy.EducationLevel = (EducationLevel)baseDimVal;
                    break;
                 case "EmploymentStatus":
                    copy.EmploymentStatus = (EmploymentStatus)baseDimVal;
                    break;
                 case "DrivingLicense":
                    copy.DrivingLicense = (DrivingLicense)baseDimVal;
                    break;
                default:
                    return null;
            }
            return copy;
        }
Beispiel #20
0
        private List<double> GetUtilityValuesForDriverLicense(Person person)
        {
            var currValues = new List<double>(2);

            currValues.Add(1);

            int twoAdultsChildren = Convert.ToInt32(person.GetHhld().GetHhldSize() == HouseholdSize.TwoAdultsChildren);
            int twoPlusAdultsChildren = Convert.ToInt32(person.GetHhld().GetHhldSize() == HouseholdSize.TwoAdultsChildren
                || person.GetHhld().GetHhldSize() == HouseholdSize.ThreeOrMoreAdultsChildren);
            int homeFT = Convert.ToInt32(person.GetEmploymentStatus() == EmploymentStatus.FullTimeHome);
            int homePT = Convert.ToInt32(person.GetEmploymentStatus() == EmploymentStatus.PartTimeHome);
            int PT = Convert.ToInt32(person.GetEmploymentStatus() == EmploymentStatus.PartTime);
            int apart = Convert.ToInt32(person.GetHhld().GetDwellingType() == DwellingType.Apartment);
            int manConst = Convert.ToInt32(person.GetOccupation() == Occupation.Construction);
            int retail = Convert.ToInt32(person.GetOccupation() == Occupation.TechnicalRetailSalesServiceNotEmployedUnknown);
            int sixteen = Convert.ToInt32(person.GetAge() == Age.SixteenToSeventeen);
            int eighteen = Convert.ToInt32(person.GetAge() == Age.EighteenToTwentyFive);
            int twentysix = Convert.ToInt32(person.GetAge() == Age.TwentySixToThirty);
            int fortyone = Convert.ToInt32(person.GetAge() == Age.FortyOneToFifty);

            int oneAdultChildren = Convert.ToInt32(person.GetHhld().GetHhldSize() == HouseholdSize.OneAdultOneChild);
            int twoAdults = Convert.ToInt32(person.GetHhld().GetHhldSize() == HouseholdSize.Twoadults);
            int twoPlusAdults = Convert.ToInt32(person.GetHhld().GetHhldSize() == HouseholdSize.ThreeOrMoreAdults
                || person.GetHhld().GetHhldSize() == HouseholdSize.Twoadults);
            int oneCar = Convert.ToInt32(person.GetHhld().GetNumOfCars() == NumOfCars.OneCar);
            int twoCars = Convert.ToInt32(person.GetHhld().GetNumOfCars() == NumOfCars.TwoCars);

            currValues.Add(Math.Exp(-0.833 * 1.00 + 2.17 * oneAdultChildren + -0.103 * twoAdults + 1.85 * twoAdultsChildren
                + 1.02 * twoPlusAdults + 2.17 * twoPlusAdultsChildren + 0.693 * apart + -0.392 * oneCar + -0.743 * twoCars
                + -1.35 * homeFT + -1.26 * homePT + -0.220 * PT + -1.95 * manConst + -1.22 * retail + 0.811 * sixteen
                + -0.621 * eighteen + -1.52 * twentysix + -1.80 * fortyone));

            return currValues;
        }
 public void addPerson(Person p)
 {
     persons.Add(p);
     p.SetHhld(household);
 }
        private List<SimulationObject> GeneratePersons(SpatialZone currZone, int numPerson,
                            Person initAgent, bool warmUpStatus,
                            OutputFileWriter currWriter)
        {
            int seltdDim = 0;
            List<ConditionalDistribution> condList = currZone.GetPersonDataCollectionsList();
            var generatedAgents = new List<SimulationObject>();
            Person prevAgent = initAgent;
            ImportanceSampler currImpSampler = new ImportanceSampler();

            int iter = 0;
            if(warmUpStatus == true)
            {
                iter = Constants.WARMUP_ITERATIONS;
            }
            else
            {
                iter = Constants.SKIP_ITERATIONS * numPerson;
            }
            Person newAgent = new Person();
            StringBuilder builder = new StringBuilder();
            for(int i = 0; i < iter; i++)
            {
                seltdDim = randGen.NextInRange(0, condList.Count - 1);

                DiscreteCondDistribution currDist =
                    (DiscreteCondDistribution)condList[seltdDim];

                /*if (currDist.GetDimensionName() == "HouseholdSize2")
                {
                    newAgent = (Person) currImpSampler.GetNextAgent(
                                currZone.myHhldSize2Marginal,
                                currDist, currDist.GetDimensionName(),
                                (SimulationObject) prevAgent, currZone);
                }
                else if (currDist.GetDimensionName() == "Age")
                {
                    newAgent = (Person)currImpSampler.GetNextAgent(
                                currZone.myAgeMarginal,
                                currDist, currDist.GetDimensionName(),
                                (SimulationObject)prevAgent, currZone);
                }
                else*/
                if(currDist.GetDimensionName() == "Sex")
                {
                    newAgent = (Person)currImpSampler.GetNextAgent(
                                currZone.mySexMarginal,
                                currDist, currDist.GetDimensionName(),
                                (SimulationObject)prevAgent, currZone);
                }
                /*else if (currDist.GetDimensionName() == "EducationLevel")
                {
                    newAgent = (Person)currImpSampler.GetNextAgent(
                                currZone.myEducationMarginal,
                                currDist, currDist.GetDimensionName(),
                                (SimulationObject)prevAgent, currZone);
                }*/
                else
                {
                    List<KeyValPair> currComm = currDist.GetCommulativeValue(
                         prevAgent.GetNewJointKey(currDist.GetDimensionName())
                            , currZone);
                    newAgent = (Person)GenerateNextAgent(currComm,
                            (SimulationObject)prevAgent,
                            currDist.GetDimensionName());
                }

                prevAgent = newAgent;
                if(warmUpStatus == false && (i % Constants.SKIP_ITERATIONS == 0))
                {
                    //generatedAgents.Add(newAgent);
                    builder.Append((int)newAgent.GetAge()); builder.Append(',');
                    builder.Append(newAgent.GetZoneID()); builder.Append(',');
                    builder.Append((int)newAgent.GetSex()); builder.Append(',');
                    builder.Append((int)newAgent.GetHhldSize()); builder.Append(',');
                    builder.Append((int)newAgent.GetEducationLevel());
                    currWriter.WriteToFile(builder.ToString());
                    builder.Clear();
                }
            }
            return generatedAgents;
        }
Beispiel #23
0
        private List<double> GetUtilityValuesForEmploymentStatus(Person person)
        {
            var currValues = new List<double>(5);

            currValues.Add(1);

            int twoAdultsChildren = Convert.ToInt32(person.GetHhld().GetHhldSize() == HouseholdSize.TwoAdultsChildren);
            int twoPlusAdults = Convert.ToInt32(person.GetHhld().GetHhldSize() == HouseholdSize.Twoadults
                || person.GetHhld().GetHhldSize() == HouseholdSize.ThreeOrMoreAdults);
            int threePlusCars = Convert.ToInt32(person.GetHhld().GetNumOfCars() == NumOfCars.ThreeOrMore);
            int lNo = Convert.ToInt32(person.GetDrivingLicense() == DrivingLicense.No);
            int apart = Convert.ToInt32(person.GetHhld().GetDwellingType() == DwellingType.Apartment);
            int town = Convert.ToInt32(person.GetHhld().GetDwellingType() == DwellingType.Townhouse);
            int profMan = Convert.ToInt32(person.GetOccupation() == Occupation.TradesProfessional);
            int retail = Convert.ToInt32(person.GetOccupation() == Occupation.TechnicalRetailSalesServiceNotEmployedUnknown);

            int eighteen = Convert.ToInt32(person.GetAge() == Age.EighteenToTwentyFive);
            int twentysix = Convert.ToInt32(person.GetAge() == Age.TwentySixToThirty);
            int thirtyone = Convert.ToInt32(person.GetAge() == Age.ThirtyOneToForty);
            int female = Convert.ToInt32(person.GetSex() == Sex.Female);
            int twoAdults = Convert.ToInt32(person.GetHhld().GetHhldSize() == HouseholdSize.Twoadults);
            int oneCar = Convert.ToInt32(person.GetHhld().GetNumOfCars() == NumOfCars.OneCar);
            int twoPlusAdultsChildren = Convert.ToInt32(person.GetHhld().GetHhldSize() == HouseholdSize.TwoAdultsChildren
                || person.GetHhld().GetHhldSize() == HouseholdSize.ThreeOrMoreAdultsChildren);

            currValues.Add(Math.Exp(-2.34 * 1.00 - 0.122 * twoAdults + -0.335 * twoAdultsChildren + -0.453 * twoPlusAdults + -0.248 * twoPlusAdultsChildren
                + -0.236 * apart + -0.323 * town + 0.104 * oneCar + 0.126 * threePlusCars + 0.522 * profMan + 0.802 * retail
                + -1.32 * eighteen + -0.711 * twentysix + -0.325 * thirtyone + -0.252 * female + 0.247 * lNo));

            int manConst = Convert.ToInt32(person.GetOccupation() == Occupation.Construction);
            int eleven = Convert.ToInt32(person.GetAge() == Age.ElevenToThirteen);
            int fiftyone = Convert.ToInt32(person.GetAge() == Age.FiftyOneToFiftyFour);
            int sixteen = Convert.ToInt32(person.GetAge() == Age.SixteenToSeventeen);

            currValues.Add(Math.Exp(-3.25 * 1.00 + -0.430 * twoAdultsChildren + -0.573 * twoPlusAdults + -0.456 * twoPlusAdultsChildren
                + -0.249 * town + 0.0881 * oneCar + -0.757 * manConst + 0.204 * profMan + 0.351 * retail + 8.78 * eleven + 3.50 * sixteen
                + -0.367 * eighteen + -1.06 * twentysix + -0.865 * thirtyone + -0.508 * fiftyone + 0.542 * female));

            int fourteen = Convert.ToInt32(person.GetAge() == Age.FourteenToFifteen);

            currValues.Add(Math.Exp(2.01 * 1.00 + -0.689 * twoPlusAdults + -0.0915 * twoPlusAdultsChildren + 0.0922 * apart
                + -0.240 * town + 0.398 * oneCar + -0.126 * threePlusCars + -17.7 * manConst + -17.9 * profMan + 14.6 * eleven
                + 5.15 * fourteen + 6.33 * sixteen + 0.646 * eighteen + -1.15 * twentysix + -1.45 * thirtyone + -1.31 * fiftyone
                + -0.280 * female + 2.15 * lNo + -19.6 * retail));

            currValues.Add(Math.Exp(-2.69 * 1.00 + 0.116 * twoAdults + -0.232 * twoAdultsChildren + 0.0514 * twoPlusAdults + 0.188 * apart
                + -0.103 * town + 0.0953 * oneCar + -0.164 * threePlusCars + -0.194 * manConst + 0.0903 * profMan + 0.914 * retail
                + 3.93 * fourteen + 5.99 * sixteen + 1.74 * eighteen + -0.317 * thirtyone + -0.392 * fiftyone + 0.853 * female
                + 0.462 * lNo + 7.15 * eleven));

            return currValues;
        }