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