/// <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> /// Compute which egress station to use /// </summary> /// <param name="interchange">The access zone to start from, flat</param> /// <param name="destination">The destination zone that we need to get to, flat</param> /// <param name="egressZones">The list of all possible egress zones, flat</param> /// <param name="trains"></param> /// <param name="parking">The amount of parking available</param> /// <param name="egressUtility">The utility of taking the given egress station</param> /// <param name="egressTime"></param> /// <param name="egressZone">The egress station to use for this access station</param> private void ComputeEgressStation(int interchange, int destination, int[] egressZones, float[] trains, float[] parking, out float egressUtility, out float egressTime, out int egressZone) { int bestZone = -1; // only compute the egress logic if we have parking spots available. if (parking[interchange] > 0) { // Set the best utility initially to the time it takes to go from the access station to the destination // if we can't find an egress station better than this the Access -> Egress pair isn't valid float maxEgressTime = ComputeWeightedTimeWithoutRail(interchange, destination); float bestTravelTime = float.MaxValue; if (float.IsNaN(maxEgressTime)) { maxEgressTime = 200f; } for (int i = 0; i < egressZones.Length; i++) { // you are not allowed to egress from the station you originally accessed float egressGeneralTime = ComputeWeightedTimeWithoutRail(egressZones[i], destination); var goTime = GoTransitNetwork.InVehicleTravelTime(interchange, egressZones[i], TimeOfDay).ToMinutes(); if (goTime <= 0) { continue; } if (!float.IsNaN(egressGeneralTime) & (egressGeneralTime <= maxEgressTime)) { // Now add on the go transit time egressGeneralTime += goTime; if (egressGeneralTime < bestTravelTime) { bestZone = egressZones[i]; bestTravelTime = egressGeneralTime; } } } } // If there is no egress station we are invalid if ((bestZone < 0) | (bestZone == interchange)) { egressUtility = float.NaN; egressZone = -1; egressTime = float.NaN; } else { egressUtility = ComputeEgressStationUtility(interchange, bestZone, destination) + TrainsFactor * trains[interchange] + ParkingFactor * parking[interchange]; egressZone = bestZone; egressTime = ComputeWeightedTimeWithoutRail(bestZone, destination); } }
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); }
/// <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.InVehicleTravelTime(origin, destination, time).ToMinutes() * IVTT); } return(0f); }
/// <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]); }
private void LoadInVehicleTimes(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.InVehicleTravelTime(i, j, time).ToMinutes(); } } }