def ejecuta(self):
     for f in self.ficheros:
         print(f)
         g = Greedy(f, self.semilla)
         antes = time.time()
         gs = g.greedy()
         despues = time.time()
         self.tiempos.append(despues - antes)
         self.valores.append(g.evalua_sol(gs))
     self.imprime()
Ejemplo n.º 2
0
    def reducer(self, key, dataset):
        config = configparser.ConfigParser()
        config_file = ops.get_local_path('ConfigFile.ini')
        config.read(config_file)
        i = 0
        data_set = {}
        # Prepare the data for the greedy
        for data in dataset:
            i += 1
            for axe in data:
                data_set[i] = data[axe]
                i += 1
        medoids = Greedy.greedy(data_set, int(config['DEFAULT']['GREEDY_2']))

        # Yield all the medoids
        for medoid in medoids.values():
            data_str = ""
            for axe in medoid:
                if data_str == "":
                    data_str = str(axe)
                else:
                    data_str = data_str + " " + str(axe)

            yield "", data_str
Ejemplo n.º 3
0
 def mapper_final(self):
     config = configparser.ConfigParser()
     config_file = ops.get_local_path('ConfigFile.ini')
     config.read(config_file)
     yield 1, Greedy.greedy(self.data_set,
                            int(config['DEFAULT']['GREEDY_1']))
Ejemplo n.º 4
0
    exit(0)
else:
    for x in range(0, length):
        if x != length:
            pancake.append(user_in[x])

# Test Cases
# print(pancake[x], type(pancake[x]))
p1 = pk.Pancake(pancake)

# d is for DFS
if p1.choice == "d":
    dfs.add_path(p1)
    p1.update_h()
    dfs.print_dfs(p1)
    while p1.h != 0:
        dfs.compare_update(p1)
        p1.update_h()
        dfs.print_dfs(p1)
# This part is for UCS
elif p1.choice == "u":
    ucs.ucs(p1)
# This part is for Greedy
elif p1.choice == "g":
    p1.update_h()
    gdy.greedy(p1, p1.visited, 0)
# This part is for A-Star
elif p1.choice == "a":
    p1.update_h()
    astar.astar(p1, p1.visited, 0)