Example #1
0
#print(tm)

best_sol = None
best_net = None
min_delay = 0
best_run = 0

for i in range(0,1):

    net=nx.DiGraph()
    for node in nodes:
        net.add_node(node)

    for link in links:
        dist=geodist((pos[link[0]][1],pos[link[0]][0]),(pos[link[1]][1],pos[link[1]][0]))
        net.add_edge(link[0],link[1],distance=dist, load=0, delay=0)
        net.add_edge(link[1],link[0],distance=dist, load=0, delay=0)
        #print(link,dist,(pos[link[0]][1],pos[link[0]][0]),(pos[link[1]][1],pos[link[1]][0]))

    nx.draw(net,pos,with_labels=True)
    #plt.show()

    allpairs=list(itertools.permutations(nodes,2))

    sol, delay_avg = GreedyRandomized(allpairs, net, tm)

    repeat = True
    while repeat:
        neighbor_best_sol = None
        neighbor_best_net = None
                    default='network.dat')
args = parser.parse_args()

filename = args.file

with open(filename) as f:
    nodes, links, pos, tm = pickle.load(f)

print(tm)

net = nx.DiGraph()
for node in nodes:
    net.add_node(node)

for link in links:
    dist = geodist((pos[link[0]][1], pos[link[0]][0]),
                   (pos[link[1]][1], pos[link[1]][0]))
    net.add_edge(link[0], link[1], distance=dist, load=0, delay=0)
    net.add_edge(link[1], link[0], distance=dist, load=0, delay=0)
    #print(link,dist,(pos[link[0]][1],pos[link[0]][0]),(pos[link[1]][1],pos[link[1]][0]))

nx.draw(net, pos, with_labels=True)
plt.show()

allpairs = list(itertools.permutations(nodes, 2))
sol = {}

for pair in allpairs:
    path = nx.shortest_path(net, pair[0], pair[1], weight='load')
    sol.update({pair: path})
    for i in range(0, len(path) - 1):
        net[path[i]][path[i + 1]]['load'] += tm[pair[0]][pair[1]]