Beispiel #1
0
        /// <summary>
        /// Calculates the V for a given trip
        ///
        /// Returns a 'random' V
        ///
        ///
        /// </summary>
        /// <param name="trip">The trip to calculate V for</param>
        /// <returns>The V for this trip</returns>
        public double CalculateV(ITrip trip)
        {
            int egressStation = (int)trip["AccessStation"];
            //LatestAccessStation(trip.TripChain, trip);
            var   auto    = TashaRuntime.AutoMode;
            var   station = TashaRuntime.ZoneSystem.Get(egressStation);
            float v       = CDriveEgress;

            v += AutoTime * auto.TravelTime(trip.DestinationZone, station, trip.TripStartTime).ToMinutes();
            v += WalkTime * TransitAccessData.WalkTime(station, trip.OriginalZone, trip.TripStartTime).ToMinutes();
            v += WaitTime * TransitAccessData.WaitTime(station, trip.OriginalZone, trip.TripStartTime).ToMinutes();
            v += AutoCost * auto.Cost(trip.DestinationZone, station, trip.TripStartTime);
            v += TransitTime * TransitAccessData.InVehicleTravelTime(station, trip.OriginalZone, trip.TripStartTime).ToMinutes();
            v += ParkingCost * TransitAccessData.Station(station).ParkingCost;
            if ((Common.GetTimePeriod(trip.ActivityStartTime) == TravelTimePeriod.Morning) ||
                (Common.GetTimePeriod(trip.ActivityStartTime) == TravelTimePeriod.Afternoon))
            {
                v += PeakTrip;
            }
            if (trip.TripChain.Person.Occupation == Occupation.Retail)
            {
                v += OccSalesTransit;
            }
            else if (trip.TripChain.Person.Occupation == Occupation.Office)
            {
                v += OccGeneralTransit;
            }
            return(v);
        }
Beispiel #2
0
        /// <summary>
        ///
        /// </summary>
        public double CalculateV(ITrip trip)
        {
            double v      = 0;
            var    person = trip.TripChain.Person;

            if (trip.OriginalZone == trip.DestinationZone && UseIntrazonalRegression)
            {
                v += IntrazonalConstantWeight + trip.OriginalZone.InternalDistance * IntrazonalDistanceWeight;
            }
            else
            {
                //transit constant
                v += CTransit;
                //In vehicle Travel Time
                v += Data.InVehicleTravelTime(trip.OriginalZone, trip.DestinationZone, trip.ActivityStartTime).ToMinutes() * TravelTimeBeta;
                //Wait time
                v += Data.WaitTime(trip.OriginalZone, trip.DestinationZone, trip.ActivityStartTime).ToMinutes() * WaitTime;
                //walk time
                v += Data.WalkTime(trip.OriginalZone, trip.DestinationZone, trip.ActivityStartTime).ToMinutes() * WalkTime;
                //cost
                if (person.TransitPass != TransitPass.Metro | person.TransitPass != TransitPass.Combination)
                {
                    v += Data.TravelCost(trip.OriginalZone, trip.DestinationZone, trip.ActivityStartTime) * Fare;
                }
            }
            if (person.Occupation == Occupation.Retail)
            {
                v += OccSalesTransit;
            }
            if (person.Child)
            {
                v += ChildBus;
            }
            if (person.Occupation == Occupation.Office)
            {
                v += OccGeneralTransit;
            }
            if (trip.Purpose == Activity.Market | trip.Purpose == Activity.JointMarket)
            {
                v += DpurpShopDrive;
            }
            else if (trip.Purpose == Activity.IndividualOther | trip.Purpose == Activity.JointOther)
            {
                v += DpurpOthDrive;
            }
            return(v);
        }
Beispiel #3
0
 public override float CalculateV(IZone origin, IZone destination, Time time)
 {
     if (IsContained(origin, destination))
     {
         return(NetworkData.WaitTime(origin, destination, time).ToMinutes() * Wait);
     }
     return(0f);
 }
Beispiel #4
0
        /// <summary>
        /// Calculates the V for closest stations and then chooses one based on a distribution function
        /// </summary>
        /// <param name="trip">The trip to calculate v for</param>
        /// <returns>a V value based on a distribution</returns>
        public double CalculateV(ITrip trip)
        {
            int[] accessStations = (int[])trip.GetVariable("feasible-subway-stations");

            double[] v    = new double[accessStations.Length];
            var      auto = TashaRuntime.AutoMode;

            for (int i = 0; i < accessStations.Length; i++)
            {
                var station = TashaRuntime.ZoneSystem.Get(accessStations[i]);
                v[i]  = CDriveAccess;
                v[i] += AutoTime * auto.TravelTime(trip.OriginalZone, station, trip.TripStartTime).ToFloat();
                v[i] += WalkTime * TransitAccessData.WalkTime(station, trip.DestinationZone, trip.TripStartTime).ToMinutes();
                v[i] += WaitTime * TransitAccessData.WaitTime(station, trip.DestinationZone, trip.TripStartTime).ToMinutes();
                v[i] += AutoCost * auto.Cost(trip.OriginalZone, station, trip.TripStartTime);
                v[i] += TransitTime * TransitAccessData.InVehicleTravelTime(station, trip.DestinationZone, trip.TripStartTime).ToMinutes();
                v[i] += ParkingCost * TransitAccessData.Station(station).ParkingCost;
                if ((Common.GetTimePeriod(trip.ActivityStartTime) == TravelTimePeriod.Morning) ||
                    (Common.GetTimePeriod(trip.ActivityStartTime) == TravelTimePeriod.Afternoon))
                {
                    v[i] += PeakTrip;
                }

                if (trip.TripChain.Person.Occupation == Occupation.Retail)
                {
                    v[i] += OccSalesTransit;
                }

                if (trip.TripChain.Person.Occupation == Occupation.Office)
                {
                    v[i] += OccGeneralTransit;
                }
            }

            Array.Sort(v);

            //int RndChoice = Common.RandChoiceCDF(V, int.Parse(this.Configuration.Get("Seed")));
            int rndChoice = 0;

            trip.Attach("subway-access-station", accessStations[rndChoice < 0 ? 0 : rndChoice]);

            return(v[rndChoice < 0 ? 0 : rndChoice]);
        }
Beispiel #5
0
        private void LoadWaitTimes(SparseTwinIndex <float> data, ITripComponentData network)
        {
            var flatData = data.GetFlatData();
            var time     = TimeToLoad;

            for (int i = 0; i < flatData.Length; i++)
            {
                var row = flatData[i];
                for (int j = 0; j < row.Length; j++)
                {
                    row[j] = network.WaitTime(i, j, time).ToMinutes();
                }
            }
        }