Exemplo n.º 1
0
        public void Run(PersonWrapper person, int sampleSize)
        {
            if (person == null)
            {
                throw new ArgumentNullException("person");
            }

            person.ResetRandom(0);

            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.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.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();
            }
        }
Exemplo n.º 2
0
        public void Run(PersonWrapper 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 < 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;
            }
        }