示例#1
0
        public float CalculateV(IZone origin, IZone destination, Time time)
        {
            CheckInterchangeZone();
            var zoneArray       = Root.ZoneSystem.ZoneArray;
            var flatOrigin      = zoneArray.GetFlatIndex(origin.ZoneNumber);
            var flatDestination = zoneArray.GetFlatIndex(destination.ZoneNumber);
            var flatInterchange = zoneArray.GetFlatIndex(InterchangeZone.ZoneNumber);

            // Make sure that this is a valid trip first
            var toDestinationTime = Second.InVehicleTravelTime(flatInterchange, flatDestination, time).ToMinutes();

            if (toDestinationTime > MaxAccessToDestinationTime)
            {
                return(float.NaN);
            }

            float v = LogParkingFactor * LogOfParking;

            if (ClosestZone.GetFlatData()[flatOrigin])
            {
                v += Closest;
            }

            // calculate this second in case the toDestinationTime is invalid
            // Cost of accessing the station
            v += AccessInVehicleTravelTime * First.TravelTime(flatOrigin, flatInterchange, time).ToMinutes()
                 + (AccessCost * (First.TravelCost(flatOrigin, flatInterchange, time) + FareTTC));

            // Station to Destination time
            v += InVehicleTravelTime * toDestinationTime;

            // Walk Time
            v += WalkTime * Second.WalkTime(flatInterchange, flatDestination, time).ToMinutes();
            return(v);
        }
示例#2
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);
        }
示例#3
0
文件: Transit.cs 项目: lunaxi7/XTMF
        /// <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);
        }
 public override float CalculateV(IZone origin, IZone destination, Time time)
 {
     if (IsContained(origin, destination))
     {
         return(NetworkData.WalkTime(origin, destination, time).ToMinutes() * Walk);
     }
     return(0f);
 }
示例#5
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]);
        }
示例#6
0
        private void LoadWalkTimes(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.WalkTime(i, j, time).ToMinutes();
                }
            }
        }
        /// <summary>
        /// Compute the utility of taking a particular egress station
        /// </summary>
        /// <param name="interchange">The access station to start from</param>
        /// <param name="egress">The station to get off at</param>
        /// <param name="origin">The destination to end the trip</param>
        /// <returns>The utility of using the egress station, NaN if no real egress station is used.</returns>
        private float ComputeEgressStationUtility(int interchange, int egress, int origin)
        {
            var goIvtt = GoTransitNetwork.InVehicleTravelTime(egress, interchange, TimeOfDay);
            var goWalk = GoTransitNetwork.WalkTime(egress, interchange, TimeOfDay);

            if (TransitNetwork.GetAllData(origin, egress, TimeOfDay, out Time ivtt, out Time walk, out Time wait, out Time boardings, out float cost))
            {
                if (ivtt <= Time.Zero)
                {
                    cost = 0f;
                }
                return(IvttFactor * (goIvtt + ivtt).ToMinutes()
                       + WaitTimeFactor * wait.ToMinutes()
                       + WalkTimeFactor * (goWalk + walk).ToMinutes()
                       + BoardingFactor * boardings.ToMinutes()
                       + TransitCostFactor * cost);
            }
            return(float.NaN);
        }
示例#8
0
 public bool ProduceResult(Pair <IZone, IZone> data)
 {
     return(NetworkData.WalkTime(data.First, data.Second, TripTime) > Time.Zero);
 }