Esempio n. 1
0
        public bool Equals(HTripTime other)
        {
            if (ReferenceEquals(null, other))
            {
                return(false);
            }

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

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

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

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

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


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

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

                    Times[i][alternativeIndex++] = time;
                }
            }
        }
Esempio n. 4
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 <dynamic> pathTypeModels =
                    PathTypeModelFactory.Model.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.Person.TransitPassOwnership,
                        tour.Household.OwnsAutomatedVehicles > 0,
                        tour.Person.GetTransitFareDiscountFraction(),
                        true,
                        pathMode);

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

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

                if (time.Available)
                {
                    time.ParkAndRideOriginStopAreaKey      = pathTypeModel.PathOriginStopAreaKey;
                    time.ParkAndRideDestinationStopAreaKey = pathTypeModel.PathDestinationStopAreaKey;
                    time.OriginAccessMode          = pathTypeModel.PathOriginAccessMode;
                    time.OriginAccessTime          = pathTypeModel.PathOriginAccessTime;
                    time.OriginAccessDistance      = pathTypeModel.PathOriginAccessDistance;
                    time.OriginAccessCost          = pathTypeModel.PathOriginAccessCost;
                    time.DestinationAccessMode     = pathTypeModel.PathDestinationAccessMode;
                    time.DestinationAccessTime     = pathTypeModel.PathDestinationAccessTime;
                    time.DestinationAccessDistance = pathTypeModel.PathDestinationAccessDistance;
                    time.DestinationAccessCost     = pathTypeModel.PathDestinationAccessCost;
                }

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