def ds_generate(G,chosen,choice_set_config,link_randomizer,ext_bound,time_dependent_relation=None,trip_time=None): if choice_set_config['allow_duplicates_of_chosen_route']: master_set=ds_generate_master(G,chosen,choice_set_config,link_randomizer,time_dependent_relation,trip_time,ext_bound) overlap=calc_chosen_overlap(G,chosen,master_set,choice_set_config) filtered_set=filter_master(G,None,master_set[1:],choice_set_config) return ([chosen]+filtered_set,overlap) else: return filter_master(G,chosen,ds_generate_master(G,chosen,choice_set_config,link_randomizer,time_dependent_relation,trip_time,ext_bound),choice_set_config)
def inverted_estimation_filter_worker(work_queue,done_queue,G,master_sets,choice_set_config): for trip_id in iter(work_queue.get,'STOP'): if choice_set_config['allow_duplicates_of_chosen_route']: chosen_overlap=calc_chosen_overlap(G,master_sets[trip_id][0],master_sets[trip_id][1:],choice_set_config) choice_set=ds.filter_master(G,None,master_sets[trip_id][1:],choice_set_config) choice_set=[master_sets[trip_id][0]]+choice_set done_queue.put((trip_id,choice_set,chosen_overlap)) else: choice_set,chosen_overlap=ds.filter_master(G,master_sets[trip_id][0],master_sets[trip_id][1:],choice_set_config) done_queue.put((trip_id,choice_set,chosen_overlap)) done_queue.put('STOP') return True
def predict_holdback_filter_worker(work_queue,done_queue,G,master_sets,choice_set_config): for trip_id in iter(work_queue.get,'STOP'): if choice_set_config['allow_duplicates_of_chosen_route']: choice_set=ds.filter_master(G,None,master_sets[trip_id][1:],choice_set_config) chosen_overlap=[1] for i in range(len(choice_set)): chosen_overlap.append(calc_chosen_overlap(G,master_sets[trip_id][0],[choice_set[i]],choice_set_config)) choice_set=[master_sets[trip_id][0]]+choice_set done_queue.put((trip_id,choice_set,chosen_overlap)) else: raise Exception, 'must allow duplicates of chosen route for predicting a holdback sample' done_queue.put('STOP') return True
def inverted_estimation_filter_worker(work_queue, done_queue, G, master_sets, choice_set_config): for trip_id in iter(work_queue.get, 'STOP'): if choice_set_config['allow_duplicates_of_chosen_route']: chosen_overlap = calc_chosen_overlap(G, master_sets[trip_id][0], master_sets[trip_id][1:], choice_set_config) choice_set = ds.filter_master(G, None, master_sets[trip_id][1:], choice_set_config) choice_set = [master_sets[trip_id][0]] + choice_set done_queue.put((trip_id, choice_set, chosen_overlap)) else: choice_set, chosen_overlap = ds.filter_master( G, master_sets[trip_id][0], master_sets[trip_id][1:], choice_set_config) done_queue.put((trip_id, choice_set, chosen_overlap)) done_queue.put('STOP') return True