private void RunModel(ChoiceProbabilityCalculator choiceProbabilityCalculator, IPersonWrapper person, int sampleSize, IParcelWrapper choice = null, bool choseHome = false) { var segment = Global.Kernel.Get <SamplingWeightsSettingsFactory>().SamplingWeightsSettings.GetTourDestinationSegment(Global.Settings.Purposes.School, Global.Settings.TourPriorities.UsualLocation, Global.Settings.Modes.Sov, person.PersonType); var destinationSampler = new DestinationSampler(choiceProbabilityCalculator, segment, sampleSize, person.Household.ResidenceParcel, choice); var destinationArrivalTime = ChoiceModelUtility.GetDestinationArrivalTime(Global.Settings.Models.SchoolTourModeModel); var destinationDepartureTime = ChoiceModelUtility.GetDestinationDepartureTime(Global.Settings.Models.SchoolTourModeModel); var schoolLocationUtilities = new SchoolLocationUtilities(person, sampleSize, destinationArrivalTime, destinationDepartureTime); destinationSampler.SampleTourDestinations(schoolLocationUtilities); // var alternative = choiceProbabilityCalculator.GetAlternative(countSampled, true); // JLB 20120403 added third call parameter to idenitfy whether this alt is chosen or not var alternative = choiceProbabilityCalculator.GetAlternative(sampleSize, true, choseHome); alternative.Choice = person.Household.ResidenceParcel; alternative.AddUtilityTerm(50, 1); alternative.AddUtilityTerm(51, (!person.IsStudentAge).ToFlag()); alternative.AddUtilityTerm(52, person.Household.Size); alternative.AddUtilityTerm(98, 100); //dummy size variable for oddball alt //make oddball alt unavailable and remove nesting for estimation of conditional MNL // alternative.Available = false; alternative.AddNestedAlternative(sampleSize + 3, 1, 99); }
private void RunModel(ChoiceProbabilityCalculator choiceProbabilityCalculator, IPersonWrapper person, int sampleSize, IParcelWrapper choice = null, bool choseHome = false) { int segment = Global.ContainerDaySim.GetInstance <SamplingWeightsSettingsFactory>().SamplingWeightsSettings.GetTourDestinationSegment(Global.Settings.Purposes.Work, Global.Settings.TourPriorities.HomeBasedTour, Global.Settings.Modes.Sov, person.PersonType); DestinationSampler destinationSampler = new DestinationSampler(choiceProbabilityCalculator, segment, sampleSize, choice, person.Household.ResidenceParcel); int destinationArrivalTime = ChoiceModelUtility.GetDestinationArrivalTime(Global.Settings.Models.WorkTourModeModel); int destinationDepartureTime = ChoiceModelUtility.GetDestinationDepartureTime(Global.Settings.Models.WorkTourModeModel); WorkLocationUtilities workLocationUtilites = new WorkLocationUtilities(this, person, sampleSize, destinationArrivalTime, destinationDepartureTime); destinationSampler.SampleTourDestinations(workLocationUtilites); //var alternative = choiceProbabilityCalculator.GetAlternative(countSampled, true); // JLB 20120329 added third call parameter to idenitfy whether this alt is chosen or not ChoiceProbabilityCalculator.Alternative alternative = choiceProbabilityCalculator.GetAlternative(sampleSize, true, choseHome); alternative.Choice = person.Household.ResidenceParcel; alternative.AddUtilityTerm(41, 1); alternative.AddUtilityTerm(42, person.IsPartTimeWorker.ToFlag()); alternative.AddUtilityTerm(43, person.IsStudentAge.ToFlag()); alternative.AddUtilityTerm(44, person.IsFemale.ToFlag()); alternative.AddUtilityTerm(90, 100); //make oddball alt unavailable and remove nesting for estimation of conditional MNL // alternative.Available = false; alternative.AddNestedAlternative(sampleSize + 3, 1, 98); }
private void RunModel(ChoiceProbabilityCalculator choiceProbabilityCalculator, IPersonWrapper person, int sampleSize, IParcelWrapper choice = null, bool choseHome = false) { int segment = Global.ContainerDaySim.GetInstance <SamplingWeightsSettingsFactory>().SamplingWeightsSettings.GetTourDestinationSegment(Global.Settings.Purposes.Work, Global.Settings.TourPriorities.HomeBasedTour, Global.Settings.Modes.Sov, person.PersonType); DestinationSampler destinationSampler = new DestinationSampler(choiceProbabilityCalculator, segment, sampleSize, choice, person.Household.ResidenceParcel); int destinationArrivalTime = ChoiceModelUtility.GetDestinationArrivalTime(Global.Settings.Models.WorkTourModeModel); int destinationDepartureTime = ChoiceModelUtility.GetDestinationDepartureTime(Global.Settings.Models.WorkTourModeModel); WorkLocationUtilities workLocationUtilites = new WorkLocationUtilities(this, person, sampleSize, destinationArrivalTime, destinationDepartureTime); destinationSampler.SampleTourDestinations(workLocationUtilites); //var alternative = choiceProbabilityCalculator.GetAlternative(countSampled, true); // JLB 20120329 added third call parameter to idenitfy whether this alt is chosen or not if (Global.Configuration.IsInEstimationMode && !ESTIMATE_NESTED_MODEL) { return; } ChoiceProbabilityCalculator.Alternative alternative = choiceProbabilityCalculator.GetAlternative(sampleSize, true, choseHome); alternative.Choice = person.Household.ResidenceParcel; alternative.AddUtilityTerm(41, 1); alternative.AddUtilityTerm(42, person.IsPartTimeWorker.ToFlag()); alternative.AddUtilityTerm(43, person.IsStudentAge.ToFlag()); alternative.AddUtilityTerm(44, person.IsFemale.ToFlag()); alternative.AddUtilityTerm(89, 1); //new dummy size variable for oddball alt alternative.AddUtilityTerm(90, 100); //old dummy size variable for oddball alt // OD shadow pricing - add for work at home if (Global.Configuration.ShouldUseODShadowPricing && Global.Configuration.UseODShadowPricingForWorkAtHomeAlternative) { int res = person.Household.ResidenceParcel.District; int des = person.Household.ResidenceParcel.District; //var first = res <= des? res : des; //var second = res <= des? des : res; double shadowPriceConfigurationParameter = res == des ? Global.Configuration.WorkLocationOOShadowPriceCoefficient : Global.Configuration.WorkLocationODShadowPriceCoefficient; int odShadowPriceF12Value = MAX_REGULAR_PARAMETER + Global.Configuration.NumberOfODShadowPricingDistricts * (res - 1) + des; alternative.AddUtilityTerm(odShadowPriceF12Value, shadowPriceConfigurationParameter); } // set shadow price depending on persontype and add it to utility // we are using the sampling adjustment factor assuming that it is 1 if (Global.Configuration.ShouldUseShadowPricing && Global.Configuration.UseWorkShadowPricingForWorkAtHomeAlternative) { alternative.AddUtilityTerm(1, person.Household.ResidenceParcel.ShadowPriceForEmployment); } //make oddball alt unavailable and remove nesting for estimation of conditional MNL alternative.AddNestedAlternative(sampleSize + 3, 1, THETA_PARAMETER); }
private void RunModel(ChoiceProbabilityCalculator choiceProbabilityCalculator, ITourWrapper tour, int sampleSize, IParcelWrapper choice = null) { var household = tour.Household; var person = tour.Person; var personDay = tour.PersonDay; // var totalAvailableMinutes = // tour.ParentTour == null // ? personDay.TimeWindow.TotalAvailableMinutes(1, Global.Settings.Times.MinutesInADay) // : tour.ParentTour.TimeWindow.TotalAvailableMinutes(1, Global.Settings.Times.MinutesInADay); var maxAvailableMinutes = tour.ParentTour == null ? personDay.TimeWindow.MaxAvailableMinutesAfter(121) : tour.ParentTour.DestinationDepartureTime - tour.ParentTour.DestinationArrivalTime; // var hoursAvailableInverse = // tour.IsHomeBasedTour // ? (personDay.HomeBasedTours - personDay.SimulatedHomeBasedTours + 1) / (Math.Max(totalAvailableMinutes - 360, 30) / 60D) // : 1 / (Math.Max(totalAvailableMinutes, 1) / 60D); var fastestAvailableTimeOfDay = tour.IsHomeBasedTour || tour.ParentTour == null ? 1 : tour.ParentTour.DestinationArrivalTime + (tour.ParentTour.DestinationDepartureTime - tour.ParentTour.DestinationArrivalTime) / 2; var tourCategory = tour.GetTourCategory(); var primaryFlag = ChoiceModelUtility.GetPrimaryFlag(tourCategory); var secondaryFlag = ChoiceModelUtility.GetSecondaryFlag(tourCategory); ChoiceModelUtility.DrawRandomTourTimePeriods(tour, tourCategory); var segment = Global.Kernel.Get <SamplingWeightsSettingsFactory>().SamplingWeightsSettings.GetTourDestinationSegment(tour.DestinationPurpose, tour.IsHomeBasedTour ? Global.Settings.TourPriorities.HomeBasedTour : Global.Settings.TourPriorities.WorkBasedTour, Global.Settings.Modes.Sov, person.PersonType); var excludedParcel = person.UsualWorkParcel == null || person.UsualWorkParcelId == household.ResidenceParcelId || tour.DestinationPurpose != Global.Settings.Purposes.Work || tour.GetTourCategory() == Global.Settings.TourCategories.WorkBased ? null : person.UsualWorkParcel; var destinationSampler = new DestinationSampler(choiceProbabilityCalculator, segment, sampleSize, tour.OriginParcel, excludedParcel, excludedParcel, choice); var tourDestinationUtilities = new TourDestinationUtilities(tour, sampleSize, primaryFlag, secondaryFlag, fastestAvailableTimeOfDay, maxAvailableMinutes); destinationSampler.SampleTourDestinations(tourDestinationUtilities); }
private void RunModel(ChoiceProbabilityCalculator choiceProbabilityCalculator, ITourWrapper tour, int sampleSize, IParcelWrapper choice = null) { // var household = tour.Household; var person = tour.Person; var personDay = tour.PersonDay; // var totalAvailableMinutes = // tour.ParentTour == null // ? personDay.TimeWindow.TotalAvailableMinutes(1, Global.Settings.Times.MinutesInADay) // : tour.ParentTour.TimeWindow.TotalAvailableMinutes(1, Global.Settings.Times.MinutesInADay); var maxAvailableMinutes = tour.ParentTour == null ? personDay.TimeWindow.MaxAvailableMinutesAfter(121) : tour.ParentTour.DestinationDepartureTime - tour.ParentTour.DestinationArrivalTime; // var hoursAvailableInverse = // tour.IsHomeBasedTour // ? (personDay.HomeBasedTours - personDay.SimulatedHomeBasedTours + 1) / (Math.Max(totalAvailableMinutes - 360, 30) / 60D) // : 1 / (Math.Max(totalAvailableMinutes, 1) / 60D); var fastestAvailableTimeOfDay = tour.IsHomeBasedTour || tour.ParentTour == null ? 1 : tour.ParentTour.DestinationArrivalTime + (tour.ParentTour.DestinationDepartureTime - tour.ParentTour.DestinationArrivalTime) / 2; var tourCategory = tour.GetTourCategory(); // var primaryFlag = ChoiceModelUtility.GetPrimaryFlag(tourCategory); var secondaryFlag = ChoiceModelUtility.GetSecondaryFlag(tourCategory); ChoiceModelUtility.DrawRandomTourTimePeriods(tour, tourCategory); var segment = Global.ContainerDaySim.GetInstance <SamplingWeightsSettingsFactory>().SamplingWeightsSettings.GetTourDestinationSegment(tour.DestinationPurpose, tour.IsHomeBasedTour ? Global.Settings.TourPriorities.HomeBasedTour : Global.Settings.TourPriorities.WorkBasedTour, Global.Settings.Modes.Sov, person.PersonType); var destinationSampler = new DestinationSampler(choiceProbabilityCalculator, segment, sampleSize, choice, tour.OriginParcel); var tourDestinationUtilities = new TourDestinationUtilities(this, tour, sampleSize, secondaryFlag, personDay.GetIsWorkOrSchoolPattern().ToFlag(), personDay.GetIsOtherPattern().ToFlag(), fastestAvailableTimeOfDay, maxAvailableMinutes); destinationSampler.SampleTourDestinations(tourDestinationUtilities); }
private void RunModel(ChoiceProbabilityCalculator choiceProbabilityCalculator, ITourWrapper tour, IHouseholdDayWrapper householdDay, int sampleSize, IParcelWrapper choice = null) { // var household = tour.Household; IPersonWrapper person = tour.Person; IPersonDayWrapper personDay = tour.PersonDay; // var totalAvailableMinutes = // tour.ParentTour == null // ? personDay.TimeWindow.TotalAvailableMinutes(1, Global.Settings.Times.MinutesInADay) // : tour.ParentTour.TimeWindow.TotalAvailableMinutes(1, Global.Settings.Times.MinutesInADay); TimeWindow timeWindow = new TimeWindow(); if (tour.JointTourSequence > 0) { foreach (PersonDayWrapper pDay in householdDay.PersonDays) { ITourWrapper tInJoint = pDay.Tours.Find(t => t.JointTourSequence == tour.JointTourSequence); if (!(tInJoint == null)) { // set jointTour time window timeWindow.IncorporateAnotherTimeWindow(tInJoint.PersonDay.TimeWindow); } } } else if (tour.ParentTour == null) { timeWindow.IncorporateAnotherTimeWindow(personDay.TimeWindow); } timeWindow.SetBusyMinutes(Global.Settings.Times.EndOfRelevantWindow, Global.Settings.Times.MinutesInADay + 1); int maxAvailableMinutes = (tour.JointTourSequence > 0 || tour.ParentTour == null) ? timeWindow.MaxAvailableMinutesAfter(Global.Settings.Times.FiveAM) : tour.ParentTour.DestinationDepartureTime - tour.ParentTour.DestinationArrivalTime; // var hoursAvailableInverse = // tour.IsHomeBasedTour // ? (personDay.HomeBasedTours - personDay.SimulatedHomeBasedTours + 1) / (Math.Max(totalAvailableMinutes - 360, 30) / 60D) // : 1 / (Math.Max(totalAvailableMinutes, 1) / 60D); int fastestAvailableTimeOfDay = tour.IsHomeBasedTour || tour.ParentTour == null ? 1 : tour.ParentTour.DestinationArrivalTime + (tour.ParentTour.DestinationDepartureTime - tour.ParentTour.DestinationArrivalTime) / 2; int tourCategory = tour.GetTourCategory(); // var primaryFlag = ChoiceModelUtility.GetPrimaryFlag(tourCategory); int secondaryFlag = ChoiceModelUtility.GetSecondaryFlag(tourCategory); ChoiceModelUtility.DrawRandomTourTimePeriodsActum(tour, tourCategory); int segment = Global.ContainerDaySim.GetInstance <SamplingWeightsSettingsFactory>().SamplingWeightsSettings.GetTourDestinationSegment(tour.DestinationPurpose, tour.IsHomeBasedTour ? Global.Settings.TourPriorities.HomeBasedTour : Global.Settings.TourPriorities.WorkBasedTour, Global.Settings.Modes.Sov, person.PersonType); DestinationSampler destinationSampler = new DestinationSampler(choiceProbabilityCalculator, segment, sampleSize, choice, tour.OriginParcel); TourDestinationUtilities tourDestinationUtilities = new TourDestinationUtilities(tour, sampleSize, secondaryFlag, personDay.GetIsWorkOrSchoolPattern().ToFlag(), personDay.GetIsOtherPattern().ToFlag(), fastestAvailableTimeOfDay, maxAvailableMinutes); destinationSampler.SampleTourDestinations(tourDestinationUtilities); }