/// <summary> /// Calculates the V value for the given trip /// </summary> /// <param name="trip">The trip to calculate for</param> /// <returns>The V for the trip</returns> public double CalculateV(ITrip trip) { double v = 0; IZone o = trip.OriginalZone, d = trip.DestinationZone; if ((o == d) & UseIntrazonalRegression) { v += IntrazonalConstantWeight + o.InternalDistance * IntrazonalDistanceWeight; } else { v += Constant; v += AutoData.TravelTime(o, d, trip.ActivityStartTime).ToMinutes() * TravelTimeBeta; v += AutoData.TravelCost(o, d, trip.ActivityStartTime) * TravelCostBeta; } v += d.ParkingCost * Parking; 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); }
/// <summary> /// Calcualtes the V value for the given trip /// </summary> /// <param name="trip">The trip to calcualte for</param> /// <returns>The V for the trip</returns> public double CalculateV(ITrip trip) { double V = 0; IZone o = trip.OriginalZone, d = trip.DestinationZone; if ((o == d) & UseIntrazonalRegression) { V += IntrazonalConstantWeight + o.InternalDistance * IntrazonalDistanceWeight; } else { V += this.Constant; V += AutoData.TravelTime(o, d, trip.ActivityStartTime).ToMinutes() * this.travelTime; V += AutoData.TravelCost(o, d, trip.ActivityStartTime) * this.travelCost; } V += d.ParkingCost * parking; if (trip.Purpose == Activity.Market | trip.Purpose == Activity.JointMarket) { V += this.dpurp_shop_drive; } else if (trip.Purpose == Activity.IndividualOther | trip.Purpose == Activity.JointOther) { V += this.dpurp_oth_drive; } return(V); }
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); }
public override float CalculateV(IZone origin, IZone destination, Time time) { if (IsContained(origin, destination)) { return(Cost * NetworkData.TravelCost(origin, destination, time)); } return(0); }
/// <summary> /// Computes the utility of a single interchange /// </summary> /// <param name="o">flat origin zone</param> /// <param name="d">flat destination zone</param> /// <param name="zones">an array of zones</param> /// <param name="interchange">the flat interchange zone to use</param> /// <param name="maxDistance">The maximum distance allowed</param> /// <param name="result">the utility of using this interchange</param> /// <param name="distanceByAuto">The distance the origin is from the interchange in auto travel time</param> /// <param name="parking"></param> /// <returns>True if this is a valid interchange zone, false if not feasible.</returns> private bool ComputeUtility(int o, int d, IZone[] zones, int interchange, float[] parking, float maxDistance, out float result, out float distanceByAuto) { result = float.NaN; Time ivtt, walk, wait, boarding; float cost; float v = 0.0f; var destinationDistance = AutoNetwork.TravelTime(o, d, TimeOfDay).ToMinutes(); if (Access) { // distance is actually the travel time distanceByAuto = AutoNetwork.TravelTime(o, interchange, TimeOfDay).ToMinutes(); // there is no need to continue if we have already found the max number of paths that are shorter // it also a valid choice to drive longer in order to use the access station compared to just going to the final destination. // we also are not feasible if there is no parking spots if (distanceByAuto >= maxDistance | destinationDistance < distanceByAuto | parking[interchange] <= 0) { return(false); } // get the from interchange to destination costs (we need to include boarding here even though we don't actually use it in our utility function // making individual calls for the data would be more expensive if (!TransitNetwork.GetAllData(interchange, d, TimeOfDay, out ivtt, out walk, out wait, out boarding, out cost) | ivtt <= Time.Zero | walk <= Time.Zero) { return(false); } } else { // This will be executed if we want to run the EGRESS model // distance is actually the travel time from the station we get off at to our destination distanceByAuto = AutoNetwork.TravelTime(interchange, d, TimeOfDay).ToMinutes(); // make sure we clip properly if (distanceByAuto >= maxDistance | destinationDistance < distanceByAuto | parking[interchange] <= 0) { return(false); } // in egress the transit trip is actually before the drive, so origin to the interchange is transit if (!TransitNetwork.GetAllData(o, interchange, TimeOfDay, out ivtt, out walk, out wait, out boarding, out cost) | ivtt <= Time.Zero | walk <= Time.Zero) { return(false); } } v += IvttFactor * ivtt.ToMinutes() + WaitTimeFactor * wait.ToMinutes() + WalkTimeFactor * walk.ToMinutes() + BoardingFactor * boarding.ToMinutes(); v += AutoTimeFactor * distanceByAuto; v += AutoCostFactor * AutoNetwork.TravelCost(o, interchange, TimeOfDay); v += ParkingFactor * (float)Math.Log(parking[interchange]); v += ParkingCostFactor * zones[interchange].ParkingCost; // Now add in the origin to interchange zone utilities result = v; return(true); }
/// <summary> /// Compute the utility of accessing the access station /// </summary> /// <param name="origin">The origin of the trip, flat</param> /// <param name="interchange">The access station, flat</param> /// <param name="weightedTravelTime"></param> /// <returns>The utility of picking the access station, NaN if it isn't possible</returns> private float ComputeAccessUtility(int origin, int interchange, out float weightedTravelTime) { float v = 0.0f; Time ivtt = AutoNetwork.TravelTime(origin, interchange, TimeOfDay); float cost = AutoNetwork.TravelCost(origin, interchange, TimeOfDay); // once we have the data we can then compute the utility v += AivttFactor * ivtt.ToMinutes() + AutoCostFactor * cost; // we can also compute the weighted travel time here in order to avoid additional lookups weightedTravelTime = ivtt.ToMinutes(); return(v); }
private void LoadCosts(SparseTwinIndex <float> data, INetworkData 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.TravelCost(i, j, time); } } }
/// <summary> /// Basic auto gas price from origin zone to destination zone /// </summary>return trip.TripChain.Person.Licence /// <param name="origin"></param> /// <param name="destination"></param> /// <param name="time"></param> /// <returns></returns> public float Cost(IZone origin, IZone destination, Time time) { return(AutoData.TravelCost(origin, destination, time)); }
private bool NonFastCalcV(ITrip driverOriginalTrip, ITrip passengerTrip, out float v) { Time dToPTime; Time tToPD; Time tToDD; v = float.NegativeInfinity; if (!IsThereEnoughTime(driverOriginalTrip, passengerTrip, out dToPTime, out tToPD, out tToDD)) { return(false); } var zoneDistances = Root.ZoneSystem.Distances; // Since this is going to be valid, start building a real utility! v = 0f; IZone passengerOrigin = passengerTrip.OriginalZone; IZone driverOrigin = driverOriginalTrip.OriginalZone; var sameOrigin = passengerOrigin == driverOrigin; IZone passengerDestination = passengerTrip.DestinationZone; var sameDestination = passengerDestination == driverOriginalTrip.DestinationZone; var passenger = passengerTrip.TripChain.Person; // we are going to add in the time of the to passenger destination twice var zeroTime = Time.Zero; int same = 0; // from driver's origin to passenger's origin if (dToPTime == zeroTime) { v += zoneDistances[driverOrigin.ZoneNumber, passengerOrigin.ZoneNumber] * 0.001f * IntrazonalDriverTripDistanceFactor; same++; } //from passenger origin to passenger destination if (tToPD == zeroTime) { v += zoneDistances[passengerOrigin.ZoneNumber, passengerDestination.ZoneNumber] * 0.001f * IntrazonalPassengerTripDistanceFactor; same++; } // time to driver destination if (tToDD == zeroTime) { v += zoneDistances[passengerDestination.ZoneNumber, driverOriginalTrip.DestinationZone.ZoneNumber] * 0.001f * IntrazonalDriverTripDistanceFactor; same++; } float timeFactor, passengerConstant, costFactor; GetPersonVariables(passenger, out timeFactor, out passengerConstant, out costFactor); // if all three are the same then apply the intrazonal constant, otherwise use the regular constant v += passengerConstant; if (same == 3) { v += IntrazonalConstant; } // apply the travel times (don't worry if we have intrazonals because they will be 0's). v += ((dToPTime + tToPD + tToDD) + tToPD).ToMinutes() * timeFactor; // Add in the travel cost v += ( (AutoData.TravelCost(driverOrigin, passengerOrigin, passengerTrip.ActivityStartTime) + AutoData.TravelCost(passengerOrigin, passengerDestination, passengerTrip.ActivityStartTime) + AutoData.TravelCost(passengerDestination, driverOriginalTrip.DestinationZone, passengerTrip.ActivityStartTime)) + driverOriginalTrip.DestinationZone.ParkingCost * Math.Min(MaximumHoursForParking, TimeToNextTrip(driverOriginalTrip, driverOriginalTrip.TripChain)) ) * costFactor; switch (passengerTrip.Purpose) { case Activity.School: v += SchoolFlag; break; case Activity.IndividualOther: case Activity.JointOther: v += OtherFlag; break; case Activity.Market: case Activity.JointMarket: v += MarketFlag; break; } if (passenger.Female) { v += FemaleFlag; } if (passenger.Licence) { v += PassengerHasLicenseFlag; } if (sameOrigin | sameDestination) { v += (sameOrigin & sameDestination) ? ShareBothPointsFlag : ShareAPointFlag; } var age = passenger.Age; v += AgeUtilLookup[Math.Min(Math.Max(age - 15, 0), 15)]; if (age >= 65) { v += Over65; } else if (age >= 55) { v += Over55; } return(true); }
public float Cost(IZone origin, IZone destination, Time time) { return(Network.TravelCost(origin, destination, time)); }