Example #1
0
 def setUpClass(cls):
     logging.basicConfig(level=logging.INFO)
     parser = Parser('../test_data', 'euro16_k2.txt')
     parser = parser.get_scenario(2)
     networkTopology = parser.networkTopology
     cls.graph = graph_factory(networkTopology)
     cls.candidate_path_fetcher = CandidatePathsFetcher(parser.candidatePaths,
                                                        networkTopology.n_nodes,
                                                        parser.pathsLengths)
 def setUp(self):
     parser = Parser('./data', 'euro16_k2.txt')
     self.scenario = parser.get_scenario(0)
     self.graph = graph_factory(self.scenario.networkTopology)
     self.logger = logging.getLogger(str(self.__class__))
     candidate_path_fetcher = CandidatePathsFetcher(self.scenario.candidatePaths,
                                                    self.scenario.networkTopology.n_nodes,
                                                    self.scenario.pathsLengths)
     self.demand_factory = DemandsFactory(candidate_path_fetcher)
     self.sa = SimulatedAnnealing()
 def setUpClass(cls):
     logging.basicConfig(level=logging.INFO)
     parser = Parser('../test_data', 'euro16_k2.txt')
     scenario = parser.get_scenario(2)
     networkTopology = scenario.networkTopology
     cls.graph = graph_factory(networkTopology)
     cls.candidate_path_fetcher = CandidatePathsFetcher(scenario.candidatePaths,
                                                        networkTopology.n_nodes,
                                                        scenario.pathsLengths)
     cls.demands = unicast_demands_factory(scenario.unicastDemands, cls.candidate_path_fetcher)
 def setUp(self):
     parser = Parser("../test_data", "euro16_k2.txt")
     scenario = parser.get_scenario(2)
     graph = graph_factory(scenario.networkTopology)
     candidatePathFetcher = CandidatePathsFetcher(scenario.candidatePaths, len(graph.nodes), scenario.pathsLengths)
     # get path
     list_of_paths1 = candidatePathFetcher.fetch_candidates(0, 1)
     # 1, 6, 10
     self.path = list_of_paths1[1]
     self.edges = graph.edges
     self.sa = SpectrumAllocator(graph)
    def setUpClass(cls):
        logging.basicConfig(level=logging.INFO)
        parser = Parser('../test_data', 'euro16_k2.txt')
        # 40.dem, 10.dea, 31.rep
        cls.parser = parser.get_scenario(261)
        networkTopology = cls.parser.networkTopology
        cls.graph = graph_factory(networkTopology)
        cls.candidate_path_fetcher = CandidatePathsFetcher(cls.parser.candidatePaths,
                                                           networkTopology.n_nodes,
                                                           cls.parser.pathsLengths)
        cls.demand_factory = DemandsFactory(cls.candidate_path_fetcher)

        cls.unicast_demands = cls.demand_factory.get_unicast_demands(cls.parser.unicastDemands)
        cls.anycast_demands = cls.demand_factory.get_anycast_demands(cls.parser.anycastDemands, cls.parser.dataCenters)
 def setUpClass(cls):
     logging.basicConfig(level=logging.INFO)
     parser = Parser('../test_data', 'euro16_k2.txt')
     parser = parser.get_scenario(0)
     cls.networkTopology = parser.networkTopology
     cls.graph = graph_factory(cls.networkTopology)
Example #7
0
        # for each edge add its index to corresponding node
        for key, edge in edges.items():
            nodes[edge.source].add_edge(key)
        return nodes

    logger = logging.getLogger(graph_factory.__name__)
    assert isinstance(network_topology, parser.parser.NetworkTopology)

    graph = Graph()
    logger.debug("filling edges")
    graph.edges = generate_edges(network_topology.matrix_of_net_links)
    logger.debug("filling nodes")
    graph.nodes = generate_nodes(network_topology.matrix_of_net_links, graph.edges)
    logger.info("graph created")
    return graph


if __name__ == "__main__":
    from parser.parser import Parser
    test_parser = Parser('../test/test_data', 'euro16_k2.txt')
    test_parser = test_parser.get_scenario(2)
    test_graph = graph_factory(test_parser.networkTopology)

    for edge in test_graph.edges:
        print test_graph.edges[edge]

    for node in test_graph.nodes:
        print test_graph.nodes[node]

Example #8
0
    def cool_temperature(self):
        self.temperature *= 1 - self.cooling_rate

    def is_not_cold(self):
        return self.temperature > self.minimal_temperature


if __name__ == "__main__":
    from parser.parser import Parser
    from graph.graph import graph_factory
    from graph.path import CandidatePathsFetcher
    from demand.demand import DemandsFactory
    logging.basicConfig(level=logging.INFO)
    test_parser = Parser('../test/test_data', 'euro16_k2.txt')
    scenario = test_parser.get_scenario(100)
    graph = graph_factory(scenario.networkTopology)
    candidate_path_fetcher = CandidatePathsFetcher(scenario.candidatePaths,
                                                   scenario.networkTopology.n_nodes,
                                                   scenario.pathsLengths)
    demand_factory = DemandsFactory(candidate_path_fetcher)
    sa = SimulatedAnnealing()
    uni_demands = demand_factory.get_unicast_demands(scenario.unicastDemands)
    any_demands = demand_factory.get_anycast_demands(scenario.anycastDemands, scenario.dataCenters)
    demands = uni_demands + any_demands
    sa.run(graph, demands)
    print sa.best_energy
    # for demand in sa.best_solution:
    #     if isinstance(demand, UnicastDemand):
    #         print demand.get_selected_path()
    #     elif isinstance(demand, AnycastDemand):