Esempio n. 1
0
        public static void SetTimeImpedanceAndWindow(ITripWrapper trip, HTripTime time)
        {
            var tour             = trip.Tour;
            var alternativeIndex = time.Index;
            var period           = time.DeparturePeriod;

            // set mode LOS and mode availability
            if (period.End < trip.EarliestDepartureTime || period.Start > trip.LatestDepartureTime)
            {
                time.Available = false;
            }
            else
            {
                var pathMode = (trip.Mode >= Global.Settings.Modes.SchoolBus - 1) ? Global.Settings.Modes.Hov3 : trip.Mode;

                IEnumerable <IPathTypeModel> pathTypeModels =
                    PathTypeModelFactory.Singleton.Run(
                        trip.Household.RandomUtility,
                        trip.IsHalfTourFromOrigin ? trip.DestinationParcel : trip.OriginParcel,
                        trip.IsHalfTourFromOrigin ? trip.OriginParcel : trip.DestinationParcel,
                        period.Middle,
                        0,
                        tour.DestinationPurpose,
                        tour.CostCoefficient,
                        tour.TimeCoefficient,
                        tour.Person.IsDrivingAge,
                        tour.Household.VehiclesAvailable,
                        tour.Household.OwnsAutomatedVehicles > 0,
                        tour.Person.GetTransitFareDiscountFraction(),
                        true,
                        pathMode);

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

                time.Available = pathTypeModel.Available;
                time.ModeLOS   = pathTypeModel;

                //set the feasible window within the small period, accounting for travel time, and recheck availability
                if (time.Available)
                {
                    time.EarliestFeasibleDepatureTime = Math.Max(period.Start,
                                                                 trip.IsHalfTourFromOrigin
                                                                 //JLB 20130723 replace next line
                                                                 //? trip.ArrivalTimeLimit + - (int) (time.ModeLOS.PathTime + 0.5)
                            ? trip.ArrivalTimeLimit + (int)(time.ModeLOS.PathTime + 0.5)
                            : trip.EarliestDepartureTime);

                    time.LatestFeasibleDepartureTime = Math.Min(period.End,
                                                                trip.IsHalfTourFromOrigin
                            ? trip.LatestDepartureTime
                            : trip.ArrivalTimeLimit - (int)(time.ModeLOS.PathTime + 0.5));

                    time.Available = time.EarliestFeasibleDepatureTime < time.LatestFeasibleDepartureTime;
                }
            }
        }
Esempio n. 2
0
        public bool Equals(HTripTime other)
        {
            if (ReferenceEquals(null, other))
            {
                return(false);
            }

            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return(other.Index == Index);
        }
Esempio n. 3
0
        public int GetRandomFeasibleMinute(ITripWrapper trip, HTripTime time)
        {
            if (trip == null || time == null)
            {
                throw new ArgumentNullException("trip time");
            }

            ITimeWindow timeWindow    = trip.Tour.ParentTour == null ? trip.Tour.PersonDay.TimeWindow : trip.Tour.ParentTour.TimeWindow;
            int         departureTime = timeWindow.GetAvailableMinute(trip.Household.RandomUtility, time.EarliestFeasibleDepatureTime, time.LatestFeasibleDepartureTime);

            //if (departureTime == Constants.DEFAULT_VALUE) {
            //    throw new InvalidDepartureTimeException();
            //}

            return(departureTime);
        }
Esempio n. 4
0
        public static void InitializeTripTimes()
        {
            if (Times != null)
            {
                return;
            }


            Times = new HTripTime[ParallelUtility.NThreads][];
            for (int i = 0; i < ParallelUtility.NThreads; i++)
            {
                Times[i] = new HTripTime[TOTAL_TRIP_TIMES];
                int alternativeIndex = 0;

                foreach (MinuteSpan minuteSpan in DayPeriod.HSmallDayPeriods)
                {
                    HTripTime time = new HTripTime(alternativeIndex, minuteSpan);

                    Times[i][alternativeIndex++] = time;
                }
            }
        }