private static void AssignFeasibility(ITashaHousehold household) { //loop through each trip in the household and assign all possible auxiliary trips var modes = TashaRuntime.SharedModes; var nonSharedModes = TashaRuntime.NonSharedModes.Count; var modesLength = modes.Count; // clear out all of the aux trip chains to begin with var persons = household.Persons; for (int i = 0; i < persons.Length; i++) { persons[i].AuxTripChains.Clear(); } for (int i = 0; i < persons.Length; i++) { var tripChains = persons[i].TripChains; for (int j = 0; j < tripChains.Count; j++) { var trips = tripChains[j].Trips; for (int k = 0; k < trips.Count; k++) { ModeData md = ModeData.Get(trips[k]); //get the mode data saved on the object for (int l = 0; l < modesLength; l++) { if (!(md.Feasible[l + nonSharedModes] = modes[l].Feasible(trips[k]))) { } } } } } }
internal void RecalculateU() { int tripPlace = 0; double NewU = 0; var numberOfModes = ModeChoice.NonSharedModes.Count; if (this.Chain == null || this.Chain.Trips == null) { return; } foreach (var trip in this.Chain.Trips) { var data = ModeData.Get(trip); for (int mode = 0; mode < numberOfModes; mode++) { if (ModeChoice.NonSharedModes[mode] == this.ChosenMode[tripPlace]) { NewU += data.U(mode); break; } } tripPlace++; } this.U = NewU; }
/// <summary> /// Generates all feasible sets of modes for the trip chain /// </summary> /// <param name="chain">The chain to operate on</param> public static void GenerateModeSets(this ITripChain chain) { //initiates the mode set ModeSet.InitModeSets(chain); ModeData[] data = new ModeData[chain.Trips.Count]; // Generate the random terms var trips = chain.Trips; for (int i = 0; i < data.Length; i++) { data[i] = ModeData.Get(trips[i]); if (data[i] != null) { data[i].GenerateError(); } } ModeSet set = ModeSet.Make(chain); // launch the recursive version to explore all sets GenerateModeSets(chain, data, set); //clear temp var 'mode' that was used in generate mode set algo foreach (var trip in chain.Trips) { trip.Mode = null; } }
/// <summary> /// Goes through the data and regenerates the random components for utility /// </summary> /// <param name="household"></param> public static void UpdateUtilities(this ITashaHousehold household) { foreach (var p in household.Persons) { foreach (var chain in p.TripChains) { foreach (var trip in chain.Trips) { ModeData.Get(trip).GenerateError(); } foreach (var modeSet in ModeSet.GetModeSets(chain)) { modeSet.RecalculateU(); } chain.SelectBestPerVehicleType(); } } }
public double CalculateU(ITripChain tripChain) { ITrip facilitatedTrip = tripChain["FacilitateTrip"] as ITrip; ISharedMode facilitatedTripMode = (ISharedMode)tripChain["SharedMode"]; //the mode data for the facilitated trip ModeData facilitatedTripData = ModeData.Get(facilitatedTrip); if (facilitatedTripData == null) { throw new XTMFRuntimeException(null, "There was no facilitated Trip Data!"); } if (TashaRuntime == null) { throw new XTMFRuntimeException(null, "Tasha runtime was null!"); } double passengersU = facilitatedTripData.U(facilitatedTripMode.ModeChoiceArrIndex); double driversU = CalculateUofAuxTrip(tripChain); return(passengersU + driversU); }
/// <summary> /// Get all of the V's for this trip, one for each mode. /// </summary> /// <param name="trip">The trip to get this from</param> /// <returns>An array of V's for each mode</returns> public static double[] GetV(this ITrip trip) { return(ModeData.Get(trip).V); }