Esempio n. 1
0
def main():

    G = gg.genGraph_import_graphML('../annotated_topo/Internetmci.graphml',
                                   3000)

    # rnd_sl= gg.randomize_service_load(G, seed = 0)
    #
    # rnd_sl.next()
    #
    # rnd_cap = gg.randomize_cap (G, 6000, seed =1)
    # rnd_cap.next()
    #
    # rt = FTCP_placement (G, 0.9999, 0.9999, 0.9999, 0.9999)
    #
    # for nd, nb in G.edges(data = False):
    #     print G[nd][nb]['capacity']
    #
    # controllers, Rmin = rt.run()

    controllers = [0, 1, 2]

    distance_matrix = nx.all_pairs_shortest_path_length(G)

    AR = Anealing_Clustering_Routing_Problem(G, distance_matrix)

    start_time = time.time()
    success, cluster, effort = AR.anneal_clustering(controllers)
    end_time = time.time()

    print "time consumed:", end_time - start_time
    print " clustering results "
    print success
    print cluster

    print effort
Esempio n. 2
0
        directory = directory_r +str(cap)+'/'

        if not os.path.exists(directory):
                os.makedirs(directory)

        directory_g = directory +graph_name +'/'
        if not os.path.exists(directory_g):

            os.makedirs(directory_g)


        graph_path = topoPath + graph_name+'.graphml'

        print graph_path
        G= gg.genGraph_import_graphML(graph_path, cap)


        for task_id in range(0, 1):
             d = [deepcopy(G), directory_g, task_id, 1, cap]
             data.append(d)

    mp_handler(data)

    # jobs = []
    # for i in range(2):
    #     d = [deepcopy(G), directory, i, 25, 1000]
    #     p = multiprocessing.Process(target=mp_worker, args=(d,))
    #     #jobs.append(p)
    #     p.start()
Esempio n. 3
0
            if new_cost == float('inf'):
                return best_clustering, best_controllers, best_rel, best_cost, best_effort

            T = T * alpha

        return best_clustering, best_controllers, best_rel, best_cost, best_effort


if __name__ == '__main__':

    logging.config.fileConfig('logging.config')
    logger = logging.getLogger("all_aneal_placement")

    logger.info("Program started")

    G = gg.genGraph_import_graphML('../annotated_topo/Internetmci.graphml',
                                   3000)

    rt = Anealing_Placement_Problem(G)

    best_clustering, best_controllers, best_rel, best_cost, best_effort = rt.anneal_placement(
    )

    #distance_matrix = nx.all_pairs_shortest_path_length(G)

    #AR = Anealing_Clustering_Routing_Problem (G, distance_matrix)

    #success, cluster, effort = AR.anneal_clustering(controllers)

    print " final results "
    print "clustering {}".format(best_clustering)
    print "controllers {}".format(best_controllers)