Ejemplo n.º 1
0
def TestMatrix_class3():
    print("______CLASSE 03 ___________")
    rs = RS()

    directory = "C:\\Users\\BACHI\\Desktop\\OPT_project\\Instances_scholl\\classe2"
    methode = ["RS", "FFD"]
    cpt = 0
    sum = [0, 0]
    bins = [0, 0]
    for filename in os.listdir(directory):
        if filename.endswith(".txt") and filename.startswith("H"):
            n, c, list = Instances_reader.ReadInstance(directory + "//" +
                                                       filename)
            t_exec = time.time()
            Sol = FF_FFD.first_fit(list, c)
            t_exec = time.time() - t_exec
            Zs = len(Sol)
            t_exec1 = time.time()
            Zs1, Sol1 = rs.RS_iteratif(n, c, list)
            t_exec1 = time.time() - t_exec1

            # use t_exec2, t_exec3 .. if you want to compare different functions

            sum[0] = sum[0] + t_exec
            sum[1] = sum[1] + t_exec1
            cpt = cpt + 1
            bins[0] = bins[0] + Zs
            bins[1] = bins[1] + Zs1

        print(methode[0] + ":       \n" + "Texec :" + str(sum[0] / cpt) +
              "\n NbBins:" + str(bins[0] / cpt))
        print(methode[1] + ":       \n" + "Texec :" + str(sum[1] / cpt) +
              "\n NbBins:" + str(bins[1] / cpt))
Ejemplo n.º 2
0
def ag_rs_rs(n, c, list):
    """rs inside AG, suivie d'un RS"""
    ag = main(5, 25, 10, n, c, list)
    sol = solution(ag[0])
    """get result and transform it to a list of Bins"""
    bins = []
    for i in range(sol[-1]):
        bins.append(Model.Bin(i, c))
        for j in range(len(sol[0][i])):
            bins[i].ranger_obj(
                Model.Objet(sol[0][i][j] - 1, list[sol[0][i][j] - 1]))
    print("\tAG_RS: {}".format(len(bins)))
    """execute RS"""
    rs = RS()
    nb, result = rs.RS_iteratif(n, c, list, bins)
    print("\tAG_RS*2: {}".format(nb))
    return result
Ejemplo n.º 3
0
def TestMatrix_class1():
    indications_class1 = ["N1", "N2", "N3", "N4"]
    methode = ["FFD", "RS"]
    rs = RS()

    print("______CLASSE 01 ___________")
    for indication in indications_class1:
        directory = "C:\\Users\\BACHI\\Desktop\\OPT_project\\Instances_scholl\\classe1"
        cpt = 0
        sum = [0, 0]
        bins = [0, 0]
        for filename in os.listdir(directory):
            if filename.endswith(".txt") and filename.startswith(indication):
                n, c, list = Instances_reader.ReadInstance(directory + "/" +
                                                           filename)
                # t_exec= temps d'execution de la fonction
                t_exec = time.time()
                Sol = FF_FFD.first_fit(list, c)
                t_exec = time.time() - t_exec
                Zs = len(Sol)
                t_exec1 = time.time()
                Zs1, Sol1 = rs.RS_iteratif(n, c, list)
                t_exec1 = time.time() - t_exec1

                # use t_exec2, t_exec3 .. if you want to compare different functions

                sum[0] = sum[0] + t_exec
                sum[1] = sum[1] + t_exec1
                cpt = cpt + 1
                bins[0] = bins[0] + Zs
                bins[1] = bins[1] + Zs1

        print(indication + " :\n")
        print(methode[0] + ":       \n" + "Texec :" + str(sum[0] / cpt) +
              "\n NbBins:" + str(bins[0] / cpt))
        print(methode[1] + ":       \n" + "Texec :" + str(sum[1] / cpt) +
              "\n NbBins:" + str(bins[1] / cpt))
Ejemplo n.º 4
0
print("__________CLASSE 01 ________________")
file2.write("__________CLASSE 01 ________________\n")
for filename in os.listdir("C:\\Users\\BACHI\\Desktop\\OPT_project\\Instances_scholl\\classe1"):
    if filename.endswith(".txt"):
        n, c, list = Instances_reader.ReadInstance(
            "C:\\Users\\BACHI\\Desktop\\OPT_project\\Instances_scholl\\classe1" + "\\" + filename)
        #t_exec = time.time()
        #SS = ls.ameliorer_Sol(n, c, list)
        #t_exec = time.time() - t_exec
        opt = get_opt_sol(1, filename)
        t_exec = time.time()
        liste_obj = FF_FFD.first_fit(list, c)
        Zs=len(liste_obj)
        t_exec = time.time() - t_exec
        t_exec2 = time.time()
        rss, sol = rs.RS_iteratif(n, c, list)
        t_exec2 = time.time() - t_exec2
        print(filename)
        file2.write(filename+"\n")
        print("\tSolution {}".format(opt))
        file2.write("\tSolution {}\n".format(opt))

        # print("Heuristique local search {}".format(len(SS)))
        print("\tBFD {}\t {}".format(Zs,t_exec))
        #file2.write("\tBFD {}\n".format(Zs,t_exec))
        print("\tRS {}\t {}".format(rss,t_exec2))
        file2.write("\tRS {}\t {}\n".format(rss,t_exec2))

        #if rss < Zs:
         #   print("Recuit simulé a trouvé une meilleure solution")