Ejemplo n.º 1
0
 def run_experiment(self):
   with open(self._h('results.csv'), 'wt') as file:
     file.write('Grafo,Algoritmo,Tiempo,Heuristica,Tiempo\n')
   for i in range(11, 18, 2):
     n = 2**i
     for j in range(1, self._num_graphs+1):
       if j < 10: j = f'0{j}'
       filename = self._h(f'{self._graph_name}_{n}_{j}.gml')
       G = load_networkx_graph(filename)
       graph = to_siset_graph(G)
       del G
       start = perf_counter()
       serial_cactus(graph)
       end = perf_counter()
       algo_runtime = end - start
       algo_solution = graph.packing_size()
       start = perf_counter()
       greedy_heuristic(graph)
       end = perf_counter()
       heur_runtime = end - start
       heur_solution = graph.packing_size()
       with open(self._h('results.csv'), 'at') as file:
         file.write('{},{},{},{},{}\n'.format(
           filename, algo_solution, algo_runtime, heur_solution, 
           heur_runtime))
Ejemplo n.º 2
0
 def compute_packing(self):
     with open(self._h('results.csv'), 'wt') as file:
         file.write('Grafo,CIF,Tiempo\n')
     for i in range(11, 18, 2):
         n = 2**i
         filename = self._h(f'{self._graph_name}_{n}_01.gml')
         G = load_networkx_graph(filename)
         graph = to_siset_graph(G)
         del G
         start = perf_counter()
         greedy_heuristic(graph)
         end = perf_counter()
         with open(self._h('results.csv'), 'at') as file:
             file.write('{},{},{}\n'.format(filename, graph.packing_size(),
                                            end - start))
         del graph
Ejemplo n.º 3
0
 def create_batch(self):
     if not isdir(self._graph_name): mkdir(self._graph_name)
     for i in range(11, 18, 2):
         n = 2**i
         for j in range(1, self._num_graphs + 1):
             G = self._generate_graph(n)
             print(G.order(), G.size())
             graph = to_siset_graph(G)
             del G
             graph.shuffle()
             graph.relabel()
             G = to_networkx_graph(graph)
             del graph
             if j < 10: j = f'0{j}'
             nx.write_gml(G, self._h(f'{self._graph_name}_{n}_{j}.gml'))
             del G
Ejemplo n.º 4
0
 def run_experiment(self):
     with open(self._h('results.csv'), 'wt') as file:
         file.write('Grafo,Heuristica,Tiempo\n')
     for i in range(11, 18, 2):
         n = 2**i
         for j in range(1, self._num_graphs + 1):
             if j < 10: j = f'0{j}'
             filename = \
               self._h(f'{self._graph_name}{n}/{self._graph_name}_{n}_{j}.gml')
             G = load_networkx_graph(filename)
             graph = to_siset_graph(G)
             del G
             start = perf_counter()
             greedy_heuristic(graph)
             end = perf_counter()
             with open(self._h('results.csv'), 'at') as file:
                 file.write('{},{},{}\n'.format(filename,
                                                graph.packing_size(),
                                                end - start))