SHARE
TWEET

Untitled

a guest Dec 9th, 2018 54 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import tsp
  2. def adj_cluster030(distance_list , item):
  3.     adj_list = []
  4.     for i in range (0,len(distance_list)):
  5.         if ((distance_list[i][1]-distance_list[i][0])/distance_list[i][0] < 0.3 ):
  6.             #print(distance_list[i])
  7.             adj_list.append(item[i])
  8.     return adj_list
  9.  
  10. def adj_cluster015(distance_list , item):
  11.     adj_list = []
  12.     for i in range (0,len(distance_list)):
  13.         if ((distance_list[i][1]-distance_list[i][0])/distance_list[i][0] < 0.15 ):
  14.             #print(distance_list[i])
  15.             adj_list.append(item[i])
  16.     return adj_list
  17.  
  18. def FindMinDist(clusterList,adjList,sort1,VC):
  19.         for i in range(0,len(adjList)):
  20.                 adjNum = adjList[i][0]
  21.                 Min1 = sort1[adjNum][0]
  22.                 Min2 = sort1[adjNum][1]
  23.                 clusterList[Min1].append(adjList[i])
  24.                 temp_list1 = clusterList[Min1]
  25.                 clusterList[Min1].pop()
  26.                 clusterList[Min2].append(adjList[i])
  27.                 temp_list2 = clusterList[Min2]
  28.                 clusterList[Min2].pop()
  29.                 tsp1_1 = tsp.tsp(clusterList[Min1])
  30.                 tsp1_2 = tsp.tsp(temp_list1)
  31.                 tsp2_1 = tsp.tsp(clusterList[Min2])
  32.                 tsp2_2 = tsp.tsp(temp_list2)
  33.                 Extra1 = tsp1_1[0] - tsp1_2[0]
  34.                 Extra2 = tsp2_1[0] - tsp2_2[0]
  35.                 if(Extra1 >= Extra2 and CapLimit(temp_list2,VC) == True):
  36.                         clusterList[Min2] = temp_list2
  37.                
  38.                 elif(Extra2 > Extra1 and CapLimit(temp_list1,VC) == True):
  39.                         clusterList[Min1] = temp_list1
  40.         return clusterList
  41.  
  42. def CapLimit(list1,VC):
  43.         cap = 0
  44.         for i in range(0,len(list1)):
  45.                 cap = list1[i][3] + cap
  46.         if(cap <= VC):
  47.                 return True
  48.         else:
  49.                 return False
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top