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