Esempio n. 1
0
        public HouseholdPersonComposite GetNextAgentCompositeHhld(DiscreteMarginalDistribution f_x,
            ConditionalDistribution g_x, string dimension,
            HouseholdPersonComposite prvAgent, SpatialZone currZone, int agentID)
        {
            KeyValPair currDimVal;
            double currProb = 0.00;
            double currRatio = 0.00;
            int cnt = 0;
            do
            {
                currDimVal = GenerateNextFromG_X(g_x, prvAgent, currZone, agentID);
                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 (HouseholdPersonComposite)prvAgent.CreateNewCopy(
                g_x.GetDimensionName(), Int16.Parse(currDimVal.Category),agentID);
        }
Esempio n. 2
0
        ///////////////////////////////////
        public SpatialZone()
        {
            ///////////////////////////////////
            // For Household Synthesis

            //censusPersonConditionals = new DiscreteCondDistribution();

            modelIncConditionals = new ModelDistribution();
            modelIncConditionals.SetDimensionName("IncomeLevel");
            modelUnivDegConditionals = new ModelDistribution();
            modelUnivDegConditionals.SetDimensionName("NumWithUnivDeg");
            modelDwellConditionals = new ModelDistribution();
            modelDwellConditionals.SetDimensionName("DwellingType");
            modelCarsConditionals = new ModelDistribution();
            modelCarsConditionals.SetDimensionName("NumOfCars");

            myDwellMarginal = new DiscreteMarginalDistribution();
            myDwellMarginal.SetDimensionName("DwellingType");

            myDwellMarginalCounts = new DiscreteMarginalDistribution();
            myDwellMarginalCounts.SetDimensionName("DwellingType");

            myCarsMarginal = new DiscreteMarginalDistribution();
            myCarsMarginal.SetDimensionName("NumOfCars");

            myPersonMarginal = new DiscreteMarginalDistribution();
            myPersonMarginal.SetDimensionName("HouseholdSize");
            ///////////////////////////////////

            ///////////////////////////////////
            // For Person Synthesis
            myHhldSize2Marginal = new DiscreteMarginalDistribution();
            myHhldSize2Marginal.SetDimensionName("HouseholdSize2");

            mySexMarginal = new DiscreteMarginalDistribution();
            mySexMarginal.SetDimensionName("Sex");

            myAgeMarginal = new DiscreteMarginalDistribution();
            myAgeMarginal.SetDimensionName("MaritalStatus");

            myEducationMarginal = new DiscreteMarginalDistribution();
            myEducationMarginal.SetDimensionName("EducationLevel");

            myAgeConditional = new DiscreteCondDistribution();
            myAgeConditional.SetDimensionName("Age");

            mySexConditional = new DiscreteCondDistribution();
            mySexConditional.SetDimensionName("Sex");

            myHhldSizeConditional = new DiscreteCondDistribution();
            myHhldSizeConditional.SetDimensionName("HouseholdSize2");

            myEduLevelConditional = new DiscreteCondDistribution();
            myEduLevelConditional.SetDimensionName("EducationLevel");
        }
Esempio n. 3
0
 public SimulationObject GetNextAgent(DiscreteMarginalDistribution f_x,
     ConditionalDistribution g_x, string dimension,
     SimulationObject prvAgent, SpatialZone currZone, int agentID)
 {
     switch(prvAgent.GetAgentType())
     {
         case AgentType.Household:
             return GetNextAgentHousehold(
             f_x, g_x, dimension, (Household)prvAgent, currZone);
         case AgentType.Person:
             return GetNextAgentPerson(
             f_x, g_x, dimension, (Person)prvAgent, currZone);
         case AgentType.HouseholdPersonComposite:
         return GetNextAgentCompositeHhld(
             f_x, g_x, dimension, (HouseholdPersonComposite)prvAgent, currZone, agentID);
         default:
             return null;
     }
 }
Esempio n. 4
0
        ///////////////////////////////////
        public SpatialZone()
        {
            ///////////////////////////////////
            // For Household Synthesis

            //censusPersonConditionals = new DiscreteCondDistribution();

            modelIncConditionals = new ModelDistribution();
            modelIncConditionals.SetDimensionName("IncomeLevel");
            modelUnivDegConditionals = new ModelDistribution();
            modelUnivDegConditionals.SetDimensionName("NumWithUnivDeg");
            modelDwellConditionals = new ModelDistribution();
            modelDwellConditionals.SetDimensionName("DwellingType");
            modelCarsConditionals = new ModelDistribution();
            modelCarsConditionals.SetDimensionName("NumOfCars");
            modelNumberOfPeopleConditionals = new ModelDistribution();
            modelNumberOfPeopleConditionals.SetDimensionName("NumOfPeople");
            modelKidsConditionals = new ModelDistribution();
            modelKidsConditionals.SetDimensionName("NumOfKids");
            modelHouseHoldTypeConditionals = new ModelDistribution();
            modelHouseHoldTypeConditionals.SetDimensionName("HouseholdSize");

            myDwellMarginal = new DiscreteMarginalDistribution();
            myDwellMarginal.SetDimensionName("DwellingType");

            myDwellMarginalCounts = new DiscreteMarginalDistribution();
            myDwellMarginalCounts.SetDimensionName("DwellingType");

            myCarsMarginal = new DiscreteMarginalDistribution();
            myCarsMarginal.SetDimensionName("NumOfCars");

            myPersonMarginal = new DiscreteMarginalDistribution();
            myPersonMarginal.SetDimensionName("HouseholdSize");
            ///////////////////////////////////

            ///////////////////////////////////
            // For Person Synthesis
               /* modelPublicTransitConditionals = new ModelDistribution();
            modelPublicTransitConditionals.SetDimensionName("PublicTransitPass");*/

            myHhldSize2Marginal = new DiscreteMarginalDistribution();
            myHhldSize2Marginal.SetDimensionName("HouseholdSize2");

            mySexMarginal = new DiscreteMarginalDistribution();
            mySexMarginal.SetDimensionName("Sex");

            myAgeMarginal = new DiscreteMarginalDistribution();
            myAgeMarginal.SetDimensionName("Age");

            myEducationMarginal = new DiscreteMarginalDistribution();
            myEducationMarginal.SetDimensionName("EducationLevel");

            myOccupationMarginal = new DiscreteMarginalDistribution();
            myOccupationMarginal.SetDimensionName("Occupation");

            myAgeConditional = new DiscreteCondDistribution();
            myAgeConditional.SetDimensionName("Age");

            mySexConditional = new DiscreteCondDistribution();
            mySexConditional.SetDimensionName("Sex");

            myHhldSizeConditional = new DiscreteCondDistribution();
            myHhldSizeConditional.SetDimensionName("HouseholdSize2");

            myEduLevelConditional = new DiscreteCondDistribution();
            myEduLevelConditional.SetDimensionName("EducationLevel");

            modelAgeConditionals = new ModelDistribution();//
            modelAgeConditionals.SetDimensionName("Age");

            modelEmploymentStatus = new ModelDistribution();//
            modelEmploymentStatus.SetDimensionName("EmploymentStatus");

             /*   modelPublicTransitConditionals = new ModelDistribution();//
            modelPublicTransitConditionals.SetDimensionName("PublicTransitPass");*/

            modelOccupationConditionals = new ModelDistribution();//
            modelOccupationConditionals.SetDimensionName("Occupation");

            modelSexConditionals = new ModelDistribution();//
            modelSexConditionals.SetDimensionName("Sex");

            modelDriverLicenseConditionals = new ModelDistribution();//
            modelDriverLicenseConditionals.SetDimensionName("DrivingLicense");
        }
 public void CheckSexConsisteny(DiscreteMarginalDistribution sexMarginal)
 {
     Random myrand = new Random ();
     double r = 0.0;
     double mCnt = sexMarginal.GetValue ("0");
     //Sex
     if (persons.Count () > 1) {
         if (persons [0].GetSex () == persons [1].GetSex ()) {
             r = myrand.NextDouble ();
             if (r < mCnt) {
                 persons [0].SetSex(Sex.Male);
                 persons [1].SetSex(Sex.Female);
             } else {
                 persons [0].SetSex(Sex.Female);
                 persons [1].SetSex(Sex.Male);
             }
         }
     }else if (persons.Count () == 1) {
         r = myrand.NextDouble ();
         if (r < mCnt) {
             persons [0].SetSex(Sex.Male);
         } else {
             persons [0].SetSex(Sex.Female);
         }
     }
 }