public void Run(HouseholdWrapper household) { if (household == null) { throw new ArgumentNullException("household"); } household.ResetRandom(4); if (Global.Configuration.IsInEstimationMode) { if (Global.Configuration.EstimationModel != CHOICE_MODEL_NAME) { return; } } else if (Global.Configuration.AV_IncludeAutoTypeChoice) { ChoiceProbabilityCalculator AVchoiceProbabilityCalculator = _helpers[ParallelUtility.threadLocalAssignedIndex.Value].GetChoiceProbabilityCalculator(household.Id); RunAVModel(AVchoiceProbabilityCalculator, household); ChoiceProbabilityCalculator.Alternative chosenAlternative = AVchoiceProbabilityCalculator.SimulateChoice(household.RandomUtility); int choice = (int)chosenAlternative.Choice; household.OwnsAutomatedVehicles = choice; } ChoiceProbabilityCalculator choiceProbabilityCalculator = _helpers[ParallelUtility.threadLocalAssignedIndex.Value].GetChoiceProbabilityCalculator(household.Id); int vehicles = household.VehiclesAvailable; if (household.VehiclesAvailable > 2) { vehicles = 2; } if (_helpers[ParallelUtility.threadLocalAssignedIndex.Value].ModelIsInEstimationMode) { RunModel(choiceProbabilityCalculator, household, vehicles); choiceProbabilityCalculator.WriteObservation(); } else { RunModel(choiceProbabilityCalculator, household); ChoiceProbabilityCalculator.Alternative chosenAlternative = choiceProbabilityCalculator.SimulateChoice(household.RandomUtility); int choice = (int)chosenAlternative.Choice; household.VehiclesAvailable = choice; } }
public void Run(HouseholdWrapper household) { if (household == null) { throw new ArgumentNullException("household"); } household.ResetRandom(4); if (Global.Configuration.IsInEstimationMode) { if (Global.Configuration.EstimationModel != CHOICE_MODEL_NAME) { return; } } ChoiceProbabilityCalculator choiceProbabilityCalculator = _helpers[ParallelUtility.threadLocalAssignedIndex.Value].GetChoiceProbabilityCalculator(household.Id); if (household.VehiclesAvailable > 4) { household.VehiclesAvailable = 4; } if (_helpers[ParallelUtility.threadLocalAssignedIndex.Value].ModelIsInEstimationMode) { RunModel(choiceProbabilityCalculator, household, household.VehiclesAvailable); choiceProbabilityCalculator.WriteObservation(); } else if (Global.Configuration.TestEstimationModelInApplicationMode) { Global.Configuration.IsInEstimationMode = false; RunModel(choiceProbabilityCalculator, household); ChoiceProbabilityCalculator.Alternative chosenAlternative = choiceProbabilityCalculator.SimulateChoice(household.RandomUtility, household.Id, household.VehiclesAvailable); Global.Configuration.IsInEstimationMode = true; } else { RunModel(choiceProbabilityCalculator, household); ChoiceProbabilityCalculator.Alternative chosenAlternative = choiceProbabilityCalculator.SimulateChoice(household.RandomUtility); int choice = (int)chosenAlternative.Choice; household.VehiclesAvailable = choice; } }
public void Run(HouseholdWrapper household) { if (household == null) { throw new ArgumentNullException("household"); } household.ResetRandom(4); if (Global.Configuration.IsInEstimationMode) { if (Global.Configuration.EstimationModel != CHOICE_MODEL_NAME) { return; } } var choiceProbabilityCalculator = _helpers[ParallelUtility.GetBatchFromThreadId()].GetChoiceProbabilityCalculator(household.Id); var vehicles = household.VehiclesAvailable; if (household.VehiclesAvailable > 2) { vehicles = 2; } if (_helpers[ParallelUtility.GetBatchFromThreadId()].ModelIsInEstimationMode) { RunModel(choiceProbabilityCalculator, household, vehicles); choiceProbabilityCalculator.WriteObservation(); } else { RunModel(choiceProbabilityCalculator, household); var chosenAlternative = choiceProbabilityCalculator.SimulateChoice(household.RandomUtility); var choice = (int)chosenAlternative.Choice; household.VehiclesAvailable = choice; } }