Example #1
0
        public static void InitializeTourModeTimes()
        {
            {
                if (ModeTimes != null)
                {
                    return;
                }

                ModeTimes = new HTourModeTime[ParallelUtility.NThreads][];
                for (int i = 0; i < ParallelUtility.NThreads; i++)
                {
                    ModeTimes[i] = new HTourModeTime[TotalTourModeTimes];

                    int alternativeIndex       = 0;
                    int periodCombinationIndex = -1;

                    for (int arrivalPeriodIndex = 0;
                         arrivalPeriodIndex < DayPeriod.H_BIG_DAY_PERIOD_TOTAL_TOUR_TIMES;
                         arrivalPeriodIndex++)
                    {
                        MinuteSpan arrivalPeriod = DayPeriod.HBigDayPeriods[arrivalPeriodIndex];
                        for (int departurePeriodIndex = arrivalPeriodIndex;
                             departurePeriodIndex < DayPeriod.H_BIG_DAY_PERIOD_TOTAL_TOUR_TIMES;
                             departurePeriodIndex++)
                        {
                            MinuteSpan departurePeriod = DayPeriod.HBigDayPeriods[departurePeriodIndex];
                            periodCombinationIndex++;

                            for (int mode = Global.Settings.Modes.Walk; mode <= Global.Settings.Modes.MaxMode; mode++)
                            {
                                HTourModeTime modeTimes = new HTourModeTime(alternativeIndex, mode, arrivalPeriod, departurePeriod, periodCombinationIndex);

                                ModeTimes[i][alternativeIndex++] = modeTimes;
                            }
                        }
                    }
                }
            }
        }
 public HTourDestinationModeTime(IParcelWrapper destination, HTourModeTime modeTimes)
 {
     Destination = destination;
     ModeTimes   = modeTimes;
 }
Example #3
0
        public static void SetImpedanceAndWindow(ITimeWindow timeWindow, ITourWrapper tour, HTourModeTime modeTimes, int constrainedHouseholdCars, double constrainedTransitDiscountFraction, IParcelWrapper alternativeDestination = null)
        {
            {
                int            alternativeIndex  = modeTimes.Index;
                MinuteSpan     arrivalPeriod     = modeTimes.ArrivalPeriod;
                MinuteSpan     departurePeriod   = modeTimes.DeparturePeriod;
                int            mode              = modeTimes.Mode;
                IParcelWrapper destinationParcel = (alternativeDestination != null) ? alternativeDestination : tour.DestinationParcel;

                int    arrivalPeriodAvailableMinutes   = timeWindow.TotalAvailableMinutes(arrivalPeriod.Start, arrivalPeriod.End);
                int    departurePeriodAvailableMinutes = timeWindow.TotalAvailableMinutes(departurePeriod.Start, departurePeriod.End);
                int    householdCars           = constrainedHouseholdCars >= 0 ? constrainedHouseholdCars : tour.Household.VehiclesAvailable;
                double transitDiscountFraction = constrainedTransitDiscountFraction >= 0 ? constrainedTransitDiscountFraction : tour.Person.GetTransitFareDiscountFraction();


                // set round trip mode LOS and mode availability
                if (arrivalPeriodAvailableMinutes <= 0 || departurePeriodAvailableMinutes <= 0 ||
                    (mode == Global.Settings.Modes.ParkAndRide && tour.DestinationPurpose != Global.Settings.Purposes.Work) ||
                    (mode == Global.Settings.Modes.SchoolBus && tour.DestinationPurpose != Global.Settings.Purposes.School) ||
                    (Global.Configuration.IsInEstimationMode && destinationParcel == null))
                {
                    modeTimes.ModeAvailableToDestination   = false;
                    modeTimes.ModeAvailableFromDestination = false;
                }
                //ACTUM must also use round trip path type to preserve the tour-based nonlinear gamma utility functions
                //else if (mode == Global.Settings.Modes.ParkAndRide) {
                else if (mode == Global.Settings.Modes.ParkAndRide || Global.Configuration.PathImpedance_UtilityForm_Auto == 1 ||
                         Global.Configuration.PathImpedance_UtilityForm_Transit == 1)
                {
                    // park and ride has to use round-trip path type, approximate each half
                    IEnumerable <IPathTypeModel> pathTypeModels =
                        PathTypeModelFactory.Singleton.Run(
                            tour.Household.RandomUtility,
                            tour.OriginParcel,
                            destinationParcel,
                            arrivalPeriod.Middle,
                            departurePeriod.Middle,
                            tour.DestinationPurpose,
                            tour.CostCoefficient,
                            tour.TimeCoefficient,
                            tour.Person.IsDrivingAge,
                            householdCars,
                            tour.Person.TransitPassOwnership,
                            tour.Household.OwnsAutomatedVehicles > 0,
                            transitDiscountFraction,
                            false,
                            mode);

                    IPathTypeModel pathTypeModel = pathTypeModels.First(x => x.Mode == mode);

                    modeTimes.ModeAvailableToDestination   = pathTypeModel.Available;
                    modeTimes.ModeAvailableFromDestination = pathTypeModel.Available;

                    if (pathTypeModel.Available)
                    {
                        modeTimes.TravelTimeToDestination           = pathTypeModel.PathTime / 2.0;
                        modeTimes.GeneralizedTimeToDestination      = pathTypeModel.GeneralizedTimeLogsum / 2.0;
                        modeTimes.TravelTimeFromDestination         = pathTypeModel.PathTime / 2.0;
                        modeTimes.GeneralizedTimeFromDestination    = pathTypeModel.GeneralizedTimeLogsum / 2.0;
                        modeTimes.ParkAndRideOriginStopAreaKey      = pathTypeModel.PathOriginStopAreaKey;
                        modeTimes.ParkAndRideDestinationStopAreaKey = pathTypeModel.PathDestinationStopAreaKey;
                        modeTimes.TransitTime            = pathTypeModel.PathTransitTime;
                        modeTimes.TransitDistance        = pathTypeModel.PathTransitDistance;
                        modeTimes.TransitCost            = pathTypeModel.PathTransitCost;
                        modeTimes.TransitGeneralizedTime = pathTypeModel.PathTransitGeneralizedTime;
                        modeTimes.WalkTime                  = pathTypeModel.PathWalkTime;
                        modeTimes.WalkDistance              = pathTypeModel.PathWalkDistance;
                        modeTimes.BikeTime                  = pathTypeModel.PathBikeTime;
                        modeTimes.BikeDistance              = pathTypeModel.PathBikeDistance;
                        modeTimes.BikeCost                  = pathTypeModel.PathBikeCost;
                        modeTimes.OriginAccessMode          = pathTypeModel.PathOriginAccessMode;
                        modeTimes.OriginAccessTime          = pathTypeModel.PathOriginAccessTime;
                        modeTimes.OriginAccessDistance      = pathTypeModel.PathOriginAccessDistance;
                        modeTimes.OriginAccessCost          = pathTypeModel.PathOriginAccessCost;
                        modeTimes.DestinationAccessMode     = pathTypeModel.PathDestinationAccessMode;
                        modeTimes.DestinationAccessTime     = pathTypeModel.PathDestinationAccessTime;
                        modeTimes.DestinationAccessDistance = pathTypeModel.PathDestinationAccessDistance;
                        modeTimes.DestinationAccessCost     = pathTypeModel.PathDestinationAccessCost;
                        modeTimes.PathDistance              = pathTypeModel.PathDistance;
                        modeTimes.PathCost                  = pathTypeModel.PathCost;
                    }
                }
                else
                {
                    // get times for each half tour separately, using HOV3 for school bus
                    int pathMode = (mode == Global.Settings.Modes.SchoolBus) ? Global.Settings.Modes.Hov3 : mode;

                    //if (tour.Household.Id == 80205 && tour.PersonDay.HouseholdDay.AttemptedSimulations == 9 && (pathMode == 1 || pathMode == 5)) {
                    if (tour.Person.IsDrivingAge == true && tour.Household.VehiclesAvailable > 0 && pathMode == 3)
                    {
                    }
                    IEnumerable <IPathTypeModel> pathTypeModels =
                        PathTypeModelFactory.Singleton.Run(
                            tour.Household.RandomUtility,
                            tour.OriginParcel,
                            destinationParcel,
                            arrivalPeriod.Middle,
                            0,
                            tour.DestinationPurpose,
                            tour.CostCoefficient,
                            tour.TimeCoefficient,
                            tour.Person.IsDrivingAge,
                            householdCars,
                            tour.Person.TransitPassOwnership,
                            tour.Household.OwnsAutomatedVehicles > 0,
                            transitDiscountFraction,
                            false,
                            pathMode);

                    IPathTypeModel pathTypeModel = pathTypeModels.First(x => x.Mode == pathMode);

                    modeTimes.ModeAvailableToDestination = pathTypeModel.Available;

                    if (pathTypeModel.Available)
                    {
                        modeTimes.TravelTimeToDestination      = pathTypeModel.PathTime;
                        modeTimes.GeneralizedTimeToDestination = pathTypeModel.GeneralizedTimeLogsum;
                    }

                    pathTypeModels =
                        PathTypeModelFactory.Singleton.Run(
                            tour.Household.RandomUtility,
                            destinationParcel,
                            tour.OriginParcel,
                            departurePeriod.Middle,
                            0,
                            tour.DestinationPurpose,
                            tour.CostCoefficient,
                            tour.TimeCoefficient,
                            tour.Person.IsDrivingAge,
                            householdCars,
                            tour.Person.TransitPassOwnership,
                            tour.Household.OwnsAutomatedVehicles > 0,
                            transitDiscountFraction,
                            false,
                            pathMode);

                    pathTypeModel = pathTypeModels.First(x => x.Mode == pathMode);

                    modeTimes.ModeAvailableFromDestination = pathTypeModel.Available;

                    if (pathTypeModel.Available)
                    {
                        modeTimes.TravelTimeFromDestination      = pathTypeModel.PathTime;
                        modeTimes.GeneralizedTimeFromDestination = pathTypeModel.GeneralizedTimeLogsum;
                    }
                }
                if (tour.Household.Id == 2138 && tour.Person.Sequence == 1 && tour.Sequence == 1)
                {
                }

                if (modeTimes.ModeAvailableToDestination == false)
                {
                }
                if (modeTimes.ModeAvailableFromDestination == false)
                {
                }


                if (modeTimes.ModeAvailableToDestination && modeTimes.ModeAvailableFromDestination)
                {
                    modeTimes.LongestFeasibleWindow = timeWindow.LongestAvailableFeasibleWindow(arrivalPeriod.End,
                                                                                                departurePeriod.Start,
                                                                                                modeTimes.TravelTimeToDestination,
                                                                                                modeTimes.TravelTimeFromDestination,
                                                                                                Global.Settings.Times.MinimumActivityDuration);
                }
            }
        }