Beispiel #1
0
        public void Run(IPersonWrapper person, int sampleSize)
        {
            if (person == null)
            {
                throw new ArgumentNullException("person");
            }

            person.ResetRandom(0);

            if (Global.Configuration.IsInEstimationMode)
            {
                //    if (!_helpers[ParallelUtility.threadLocalAssignedIndex.Value].ModelIsInEstimationMode) {
                //        return;
                //    }
                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.UsualWorkParcel == null)
                {
                    return;
                }

                bool           choseHome    = person.UsualWorkParcelId == person.Household.ResidenceParcelId; // JLB 20120329 added these two lines
                IParcelWrapper chosenParcel = choseHome ? null : person.UsualWorkParcel;

                //RunModel(choiceProbabilityCalculator, person, sampleSize, person.UsualWorkParcel);
                RunModel(choiceProbabilityCalculator, person, sampleSize, chosenParcel, choseHome); // JLB 20120329 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.WorkLocationLogsum = chosenAlternative.ComputeLogsum();

                person.UsualWorkParcelId = choice.Id;
                person.UsualWorkParcel   = choice;
                person.UsualWorkZoneKey  = 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.AutoTimeToUsualWork     = skimValue.Variable;
                person.AutoDistanceToUsualWork = skimValue.BlendVariable;

                person.SetWorkParcelPredictions();
            }
        }
        public void Run(IPersonWrapper person)
        {
            if (person == null)
            {
                throw new ArgumentNullException("person");
            }

            person.ResetRandom(3);

            if (Global.Configuration.IsInEstimationMode)
            {
                if (!_helpers[ParallelUtility.threadLocalAssignedIndex.Value].ModelIsInEstimationMode)
                {
                    return;
                }
            }

            ChoiceProbabilityCalculator choiceProbabilityCalculator = _helpers[ParallelUtility.threadLocalAssignedIndex.Value].GetChoiceProbabilityCalculator(person.Id);

            if (_helpers[ParallelUtility.threadLocalAssignedIndex.Value].ModelIsInEstimationMode)
            {
                if (person.TransitPassOwnership > 1)
                {
                    person.TransitPassOwnership = 1;
                }                                                                  //recoding to allow for multiple types of transit passes for codes >0
                if (person.TransitPassOwnership < 0 || person.TransitPassOwnership > 1)
                {
                    return;
                }

                RunModel(choiceProbabilityCalculator, person, person.TransitPassOwnership);

                choiceProbabilityCalculator.WriteObservation();
            }
            else
            {
                RunModel(choiceProbabilityCalculator, person);

                ChoiceProbabilityCalculator.Alternative chosenAlternative = choiceProbabilityCalculator.SimulateChoice(person.Household.RandomUtility);
                int choice = (int)chosenAlternative.Choice;

                person.TransitPassOwnership = choice;
            }
        }
        public void Run(IPersonWrapper person)
        {
            if (person == null)
            {
                throw new ArgumentNullException("person");
            }

            person.ResetRandom(2);

            if (Global.Configuration.IsInEstimationMode)
            {
                if (!_helpers[ParallelUtility.threadLocalAssignedIndex.Value].ModelIsInEstimationMode)
                {
                    return;
                }
            }

            var choiceProbabilityCalculator = _helpers[ParallelUtility.threadLocalAssignedIndex.Value].GetChoiceProbabilityCalculator(person.Id);

            if (_helpers[ParallelUtility.threadLocalAssignedIndex.Value].ModelIsInEstimationMode)
            {
                if (person.PaidParkingAtWorkplace < 0 || person.PaidParkingAtWorkplace > 1)
                {
                    return;
                }

                RunModel(choiceProbabilityCalculator, person, person.PaidParkingAtWorkplace);

                choiceProbabilityCalculator.WriteObservation();
            }
            else
            {
                RunModel(choiceProbabilityCalculator, person);

                var chosenAlternative = choiceProbabilityCalculator.SimulateChoice(person.Household.RandomUtility);
                var choice            = (int)chosenAlternative.Choice;

                person.PaidParkingAtWorkplace = choice;
            }
        }
        public void Run(IPersonWrapper person)
        {
            if (person == null)
            {
                throw new ArgumentNullException("person");
            }

            person.ResetRandom(3);

            if (Global.Configuration.IsInEstimationMode)
            {
                if (!_helpers[ParallelUtility.GetBatchFromThreadId()].ModelIsInEstimationMode)
                {
                    return;
                }
            }

            var choiceProbabilityCalculator = _helpers[ParallelUtility.GetBatchFromThreadId()].GetChoiceProbabilityCalculator(person.Id);

            if (_helpers[ParallelUtility.GetBatchFromThreadId()].ModelIsInEstimationMode)
            {
                if (person.TransitPassOwnership < 0 || person.TransitPassOwnership > 1)
                {
                    return;
                }

                RunModel(choiceProbabilityCalculator, person, person.TransitPassOwnership);

                choiceProbabilityCalculator.WriteObservation();
            }
            else
            {
                RunModel(choiceProbabilityCalculator, person);

                var chosenAlternative = choiceProbabilityCalculator.SimulateChoice(person.Household.RandomUtility);
                var choice            = (int)chosenAlternative.Choice;

                person.TransitPassOwnership = choice;
            }
        }
Beispiel #5
0
        public void Run(IPersonWrapper person)
        {
            if (person == null)
            {
                throw new ArgumentNullException("person");
            }

            person.ResetRandom(5);

            if (Global.Configuration.IsInEstimationMode)
            {
                if (Global.Configuration.EstimationModel != CHOICE_MODEL_NAME)
                {
                    return;
                }

                ChoiceProbabilityCalculator choiceProbabilityCalculator = _helpers[ParallelUtility.threadLocalAssignedIndex.Value].GetChoiceProbabilityCalculator(person.Id);

                RunModel(choiceProbabilityCalculator, person);

                choiceProbabilityCalculator.WriteObservation();
            }
            else
            {
                ChoiceProbabilityCalculator choiceProbabilityCalculator = _helpers[ParallelUtility.threadLocalAssignedIndex.Value].GetChoiceProbabilityCalculator(person.Id);

                RunModel(choiceProbabilityCalculator, person);

                ChoiceProbabilityCalculator.Alternative chosenAlternative = choiceProbabilityCalculator.SimulateChoice(person.Household.RandomUtility);

                if (chosenAlternative == null)
                {
                    Global.PrintFile.WriteNoAlternativesAvailableWarning(CHOICE_MODEL_NAME, "Run", person.Id);
                    return;
                }

                int choice = (int)chosenAlternative.Choice;
            }
        }
Beispiel #6
0
        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;
                }
            }

            var choiceProbabilityCalculator = _helpers[ParallelUtility.GetBatchFromThreadId()].GetChoiceProbabilityCalculator(person.Id);

            if (_helpers[ParallelUtility.GetBatchFromThreadId()].ModelIsInEstimationMode)
            {
                if (person.UsualSchoolParcel == null)
                {
                    return;
                }

                var choseHome    = person.UsualSchoolParcelId == person.Household.ResidenceParcelId; // JLB 20120403 added these two lines
                var 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
            {
                if (person.Household.HouseholdTotals.AllStudents > 1)
                {
                    //determine if student goes to the same school as a sibling
                    SiblingModel(person, person.Household.RandomUtility);
                }

                if (!(person.UsualSchoolParcelId > 0))
                {
                    RunModel(choiceProbabilityCalculator, person, sampleSize);

                    var chosenAlternative = choiceProbabilityCalculator.SimulateChoice(person.Household.RandomUtility);
                    var choice            = (ParcelWrapper)chosenAlternative.Choice;

                    person.UsualSchoolParcelId = choice.Id;
                    person.UsualSchoolParcel   = choice;
                    person.UsualSchoolZoneKey  = ChoiceModelFactory.ZoneKeys[choice.ZoneId];

                    var 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();
                }
            }
        }