public void Run(IPersonWrapper person, int sampleSize) { if (person == null) { throw new ArgumentNullException("person"); } person.ResetRandom(1); if (Global.Configuration.IsInEstimationMode) { if (Global.Configuration.EstimationModel != CHOICE_MODEL_NAME) { return; } } ChoiceProbabilityCalculator choiceProbabilityCalculator = _helpers[ParallelUtility.threadLocalAssignedIndex.Value].GetChoiceProbabilityCalculator(person.Id); if (_helpers[ParallelUtility.threadLocalAssignedIndex.Value].ModelIsInEstimationMode) { if (person.UsualSchoolParcel == null) { return; } bool choseHome = person.UsualSchoolParcelId == person.Household.ResidenceParcelId; // JLB 20120403 added these two lines IParcelWrapper chosenParcel = choseHome ? null : person.UsualSchoolParcel; //RunModel(choiceProbabilityCalculator, person, sampleSize, person.UsualSchoolParcel); RunModel(choiceProbabilityCalculator, person, sampleSize, chosenParcel, choseHome); // JLB 20120403 replaced above line // when chosenParcel is null: // DestinationSampler doesn't try to assign one of the sampled destinations as chosen // choseHome is NOT null, and RunModel sets the oddball location as chosen choiceProbabilityCalculator.WriteObservation(); } else { RunModel(choiceProbabilityCalculator, person, sampleSize); ChoiceProbabilityCalculator.Alternative chosenAlternative = choiceProbabilityCalculator.SimulateChoice(person.Household.RandomUtility); ParcelWrapper choice = (ParcelWrapper)chosenAlternative.Choice; person.SchoolLocationLogsum = chosenAlternative.ComputeLogsum(); person.UsualSchoolParcelId = choice.Id; person.UsualSchoolParcel = choice; person.UsualSchoolZoneKey = ChoiceModelFactory.ZoneKeys[choice.ZoneId]; SkimValue skimValue = ImpedanceRoster.GetValue("ivtime", Global.Settings.Modes.Sov, Global.Settings.PathTypes.FullNetwork, Global.Settings.ValueOfTimes.DefaultVot, 1, person.Household.ResidenceParcel, choice); person.AutoTimeToUsualSchool = skimValue.Variable; person.AutoDistanceToUsualSchool = skimValue.BlendVariable; person.SetSchoolParcelPredictions(); } }
public void SiblingModel(IPersonWrapper person, IRandomUtility random) { string ageGroup1 = "0"; string ageGroup2 = "0"; double thisPr = 0.0; if (person.Age < 6) { ageGroup1 = "15"; } else if (person.Age < 12) { ageGroup1 = "611"; } else if (person.Age < 14) { ageGroup1 = "1214"; } else if (person.Age <= 18) { ageGroup1 = "1518"; } foreach (PersonWrapper otherStu in person.Household.Persons) { if (otherStu.UsualSchoolParcelId > 0) { if (otherStu.Age < 6) { ageGroup2 = "15"; } else if (otherStu.Age < 12) { ageGroup2 = "611"; } if (otherStu.Age < 14) { ageGroup2 = "1214"; } else if (otherStu.Age <= 18) { ageGroup2 = "1518"; } if (prMatch.ContainsKey(ageGroup1 + ageGroup2)) { thisPr = prMatch[ageGroup1 + ageGroup2]; } if (random.Uniform01() < thisPr) { person.UsualSchoolParcelId = otherStu.UsualSchoolParcelId; person.UsualSchoolParcel = otherStu.UsualSchoolParcel; person.UsualSchoolZoneKey = ChoiceModelFactory.ZoneKeys[person.UsualSchoolParcel.ZoneId]; var skimValue = ImpedanceRoster.GetValue("ivtime", Global.Settings.Modes.Sov, Global.Settings.PathTypes.FullNetwork, Global.Settings.ValueOfTimes.DefaultVot, 1, person.Household.ResidenceParcel, person.UsualSchoolParcel); person.AutoTimeToUsualSchool = skimValue.Variable; person.AutoDistanceToUsualSchool = skimValue.BlendVariable; person.SetSchoolParcelPredictions(); break; } } } }