def group_stackercrane_approx( demand_hist, M, transport_graph, cost_label='cost' ) : cycles = group_cyclefactor_approx.group_cyclefactor_approx( demand_hist, M, transport_graph, cost_label ) tour = largearcs_connecting_heuristic( cycles, transport_graph, cost_label ) return tour
if __name__ == '__main__' : import testcase demand_hist = testcase.demand_hist M = testcase.M transport_graph = testcase.A import group_cyclefactor_approx as gcfp cycles_old = gcfp.group_cyclefactor_approx( demand_hist, M, transport_graph ) sctour = group_stackercrane_approx( demand_hist, M, transport_graph ) cycles = [ sctour ] station_tours = [] for cycle in cycles : tour = [] for x,y, _ in cycle : i = M.neighbors(x)[0] j = M.neighbors(y)[0] tour.append( (i,j) ) station_tours.append( tour ) freq_dict = dict()