/// <summary> /// Gets the number of vehicles available in the household for the given timespan /// </summary> /// <param name="h"></param> /// <param name="span"></param> /// <param name="vehicleType"></param> /// <param name="includeAuxTripChains"></param> /// <returns></returns> public static int NumberOfVehicleAvailable(this ITashaHousehold h, TashaTimeSpan span, IVehicleType vehicleType, bool includeAuxTripChains) { Dictionary <TashaTimeSpan, int> availabilities = h.FindVehicleAvailabilites(vehicleType, includeAuxTripChains); var vehicles = h.Vehicles; int available = 0; for (int i = 0; i < vehicles.Length; i++) { if (vehicles[i].VehicleType == vehicleType) { available++; } } foreach (var a in availabilities) { if ((a.Key.Start < span.End) && (a.Key.End > span.Start)) { // this is strictly less than since we want the min of the vehicles if (a.Value < available) { available = a.Value; } } } return(available); }