def aggregate_accessibility(folder_names): """uses the accessibility results instead of the by-income ones to compute. tricky thing is that goes by different modes and by peak and off-peak. So, maybe it'd be better to get the one by income and then aggregate those?""" scenario_results = [] for folder_name in folder_names: print "starting folder: ", folder_name scenario_results.append(import_acc_results.grab_cumulative_accessibility(folder_name)) # TODO: use new function that aggregates across taz and income # accs = import_acc_results.grab_accessibility_by_income(folder_name) # print 'acc for one sceanrio: ', accs # #package up accessiblity # for ac in accs: # scenario_results.append(np.mean(ac)) # acc_tot = import_acc_results.grab_general_accessibility(folder_name) # 2 lists, peak and off-peak # new_acc = [np.mean(a) for a in acc_tot] #just take average # scenario_results.append(np.mean(new_acc)) return scenario_results
def test(): print "testing get support" weights = [0.1, 0.05, 0.222] match_indices = [1, 3] item_indices = [1, 2, 3, 4, 6, 7, 8, 9] list_of_baskets = [[1, 2, 3], [9, 8], [4]] support_list = get_support(weights, match_indices, item_indices, list_of_baskets) assert support_list == [[1, 0.1], [2, 0.1], [3, 0.1], [4, 0.222], [5, 0], [6, 0], [7, 0], [8, 0], [9, 0]] assert len(get_scenario_weights("12-Dec-2013_12_3909_50_0.55556_25_weights.csv")) == 25 assert sum(get_scenario_weights("12-Dec-2013_12_3909_50_0.55556_25_weights.csv")) > 0.024 assert sum(get_scenario_weights("12-Dec-2013_12_3909_50_0.55556_25_weights.csv")) < 0.025 TARGETS = [ 20, 33, 36, 137, 142, 143, 144, 151, 152, 159, 166, 167, 171, 173, 183, 184, 192, 193, 194, 196, 205, 1676, 1692, 2851, 2914, ] # data within: 12-Dec-2013_12_3909_50_0.55556_25.mat #indices between 0 and 2110. the scenarios for which you want to save the damaged bridge data # y = aggregate_accessibility([183]) #TODO y = import_acc_results.grab_cumulative_accessibility("all_damaged") print y