public Household GetNextAgent(ModelDistribution g_x, string dimension, Household prvAgent, SpatialZone currZone) { StateGenerator currStateGen = new StateGenerator(); currStateGen.SetParameters(currZone.GetAverageIncome(), currZone.GetAverageIncome() * 2); double q_previous; double q_current = 0.00; double expIncome = Math.Log(prvAgent.GetIncome()); KeyValDoublePair currPair = new KeyValDoublePair(); //start with mean value currPair.Category = currStateGen.GetMean(); currPair.Val = currStateGen.GetTransitionProbablity(currPair.Category); for (int i = 0; i < Constants.WARMUP_ITERATIONS; i++) { q_previous = currStateGen.GetTransitionProbablity( Math.Log((double)prvAgent.GetIncome())); q_current = currPair.Val; IncomeLevel prevLvl = IncomeConvertor.ConvertValueToLevel( (uint) Math.Exp(expIncome)); IncomeLevel currLvl = IncomeConvertor.ConvertValueToLevel( (uint) Math.Exp(currPair.Category)); double b_prev = g_x.GetValue(dimension, prevLvl.ToString(), prvAgent.GetNewJointKey(dimension), currZone); double b_curr = g_x.GetValue(dimension, currLvl.ToString(), prvAgent.GetNewJointKey(dimension), currZone); if (b_prev == 0.00) b_prev = 0.0000001; if (b_curr == 0.00) b_curr = 0.0000001; if (q_current == 0.00) q_current = 0.0000001; double comVal = (b_curr * q_previous) / (b_prev * q_current); if (comVal == 0.00) comVal = 0.0000001; if (randGen.NextDouble() < comVal) { expIncome = currPair.Category; } currPair = currStateGen.GetNextState(); } return prvAgent.CreateNewCopy((uint)Math.Exp(expIncome)); }
private List<double> GetUtilityValuesForIncome(HouseholdPersonComposite composite, SpatialZone curZ) { Household hhld = composite.getHousehold().CreateNewCopy(); String key = hhld.GetNewJointKey(GetDimensionName()); string[] curKeys = key.Split(Constants.CONDITIONAL_DELIMITER[0]); var currValues = new List<double>(5); currValues.Add(1.00); currValues.Add(Math.Exp(-0.859 + 0.000783 * curZ.GetAverageIncome() / Constants.BFRANC_TO_EURO + 1.16 * Int16.Parse(curKeys[4]) + 1.15 * Int16.Parse(curKeys[1]))); currValues.Add(Math.Exp(-4.57 + 0.674 * Int16.Parse(curKeys[3]) + 0.0012 * curZ.GetAverageIncome() / Constants.BFRANC_TO_EURO + 1.87 * Int16.Parse(curKeys[4]) + 0.409 * Int16.Parse(curKeys[5]) + 2.2 * Int16.Parse(curKeys[1]))); currValues.Add(Math.Exp(-8.11 + 1.38 * Int16.Parse(curKeys[3]) + 0.00157 * curZ.GetAverageIncome() / Constants.BFRANC_TO_EURO + 2.22 * Int16.Parse(curKeys[4]) + 0.415 * Int16.Parse(curKeys[5]) + 2.33 * Int16.Parse(curKeys[1]))); currValues.Add(Math.Exp(-10.5 + 1.61 * Int16.Parse(curKeys[3]) + 0.0016 * curZ.GetAverageIncome() / Constants.BFRANC_TO_EURO + 3.04 * Int16.Parse(curKeys[4]) + 0.415 * Int16.Parse(curKeys[5]) + 1.64 * Int16.Parse(curKeys[1]))); return currValues; }
private List<double> GetUtilityValuesForCar(HouseholdPersonComposite composite, SpatialZone curZ) { Household hhld = composite.getHousehold().CreateNewCopy(); String key = hhld.GetNewJointKey(GetDimensionName()); string[] curKeys = key.Split(Constants.CONDITIONAL_DELIMITER[0]); var currValues = new List<double>(4); currValues.Add(1.00); double dwellNotApartment = 0.00; if (Int16.Parse(curKeys[5]) != 3) { dwellNotApartment = 0.841; } double incParam = 0.00; if (Int16.Parse(curKeys[3]) == 2) { incParam = 0.858; } else if (Int16.Parse(curKeys[3]) > 2) { incParam = 0.978; } double childParam = 0.00; if (Int16.Parse(curKeys[2]) != 0) { childParam = 0.457; } currValues.Add(Math.Exp(-2.75 + 0.504 * Int16.Parse(curKeys[4]) + 0.00105 * curZ.GetAverageIncome() / Constants.BFRANC_TO_EURO + 0.437 * Int16.Parse(curKeys[1]) + 0.498 * curZ.GetPercentHhldWOneCar() + dwellNotApartment + incParam + childParam)); incParam = 0.00; if (Int16.Parse(curKeys[3]) == 2) { incParam = 1.87; } else if (Int16.Parse(curKeys[3]) > 2) { incParam = 2.43; } childParam = 0.00; if (Int16.Parse(curKeys[2]) != 0) { childParam = 0.800; } dwellNotApartment = 0.00; if (Int16.Parse(curKeys[5]) != 3) { dwellNotApartment = 1.86; } currValues.Add(Math.Exp(-7.02 + 0.933 * Int16.Parse(curKeys[4]) + 0.00126 * curZ.GetAverageIncome() / Constants.BFRANC_TO_EURO + 1.24 * Int16.Parse(curKeys[1]) + 2.13 * curZ.GetPercentHhldWTwoCar() + dwellNotApartment + incParam + childParam)); incParam = 0.00; if (Int16.Parse(curKeys[3]) == 2) { incParam = 1.42; } else if (Int16.Parse(curKeys[3]) > 2) { incParam = 3.24; } dwellNotApartment = 0.00; if (Int16.Parse(curKeys[5]) != 3) { dwellNotApartment = 2.66; } currValues.Add(Math.Exp(-10.1 + 1.07 * Int16.Parse(curKeys[4]) + 0.00126 * curZ.GetAverageIncome() / Constants.BFRANC_TO_EURO + 1.60 * Int16.Parse(curKeys[1]) + 14.1 * curZ.GetPercentHhldWThreeCar() + dwellNotApartment + incParam)); return currValues; }
private List<double> GetUtilityValuesForIncome(string key, SpatialZone curZ) { string[] curKeys = key.Split(Constants.CONDITIONAL_DELIMITER[0]); var currValues = new List<double>(5); currValues.Add(1.00); currValues.Add(Math.Exp(-0.859 + 0.000783 * curZ.GetAverageIncome() / Constants.BFRANC_TO_EURO + 1.16 * Int16.Parse(curKeys[4]) + 1.15 * Int16.Parse(curKeys[1]))); currValues.Add(Math.Exp(-4.57 + 0.674 * Int16.Parse(curKeys[3]) + 0.0012 * curZ.GetAverageIncome() / Constants.BFRANC_TO_EURO + 1.87 * Int16.Parse(curKeys[4]) + 0.409 * Int16.Parse(curKeys[5]) + 2.2 * Int16.Parse(curKeys[1]))); currValues.Add(Math.Exp(-8.11 + 1.38 * Int16.Parse(curKeys[3]) + 0.00157 * curZ.GetAverageIncome() / Constants.BFRANC_TO_EURO + 2.22 * Int16.Parse(curKeys[4]) + 0.415 * Int16.Parse(curKeys[5]) + 2.33 * Int16.Parse(curKeys[1]))); currValues.Add(Math.Exp(-10.5 + 1.61 * Int16.Parse(curKeys[3]) + 0.0016 * curZ.GetAverageIncome() / Constants.BFRANC_TO_EURO + 3.04 * Int16.Parse(curKeys[4]) + 0.415 * Int16.Parse(curKeys[5]) + 1.64 * Int16.Parse(curKeys[1]))); return currValues; }