Exemplo n.º 1
0
 def run_algorithm(self):
     val_0 = int(self.w.val_0.value())
     val_1 = int(self.w.val_1.value())
     val_2 = int(self.w.val_2.value())
     val_3 = int(self.w.val_3.value())
     val_4 = int(self.w.val_4.value())
     val_5 = int(self.w.doubleSpinBox.value())
     print(val_0, val_1, val_2)
     print(val_5)
     #self.w.text.append("CLicked with values %d, %d , %d " % (val_0, val_1, val_2))
     if self.type == 0:  #branch and bound
         pass
     elif self.type == 1:  #NEH
         pass
     elif self.type == 2:  #NEH Amelioree
         pass
     elif self.type == 3:  #CDS
         pass
     elif self.type == 4:  #Algorithme genetique
         sequence, makespan = solve_problem.solve_benchmark_problem(
             val_0, val_2, val_1, val_3, val_4, val_5)
     elif self.type == 5:  #VNS
         pass
     elif self.type == 6:  #Hyper Heuristqiue
         pass
     elif self.type == 7:  #Palmer
         pass
     print(sequence, makespan)
     self.w.label_resultat.setText(str(sequence))
     self.w.timeField.display(makespan)
Exemplo n.º 2
0
def test_AG(instance, job, machine):
    print("probleme ", instance, job, machine, "  : \n")
    makespan_list = []
    # toutes les combinaisons possibles de probabilites et de taille population et taille generation
    for p in list_probabilite:
        for o in list_population:
            for g in list_generation:
                sequence, makespan = solve_problem.solve_benchmark_problem(
                    instance, job, machine, o, g, p)
                makespan_list.append(makespan)
    print("mutations probabilite: ", p, "generation", g, "population", o)
    print(makespan_list)
    print(np.min(makespan_list))
Exemplo n.º 3
0
def AG_study():
    #on parcours tous les problemes
    for i in range(1, 10):
        #on parcours tous les tailles d'instances
        for j in list_machine:
            for k in list_job:
                print("probleme ", i, j, k, "  : \n")
                makespan_list = []
                #toutes les combinaisons possibles de probabilites et de taille population et taille generation
                for p in list_probabilite:
                    for o in list_population:
                        for g in list_generation:
                            sequence, makespan = solve_problem.solve_benchmark_problem(
                                i, k, j, o, g, p)
                            makespan_list.append(makespan)
                print(makespan_list)
                print(np.min(makespan_list))
Exemplo n.º 4
0
def run_main(problem):
    jobs, machines, timeseed, prev_best_makespan = read_problem(
        taillard, problem)

    best_sequence, best_makespan = \
        solve_benchmark_problem(problem, jobs, machines, timeseed, show_matrix=False)

    best_sequence = list(map(int, best_sequence))
    best_sequence = list(map(str, best_sequence))
    best_sequence = ', '.join(best_sequence)

    print("Jobs: ", jobs, "\nMachines: ", machines, "\nTimeseed: ", timeseed,
          "\nOptimal sequence: ", best_sequence, "\nOptimal makespan: ",
          best_makespan)

    if best_makespan < prev_best_makespan:
        write_new_best(problem,
                       best_sequence,
                       best_makespan,
                       taillard,
                       taillard_file,
                       benchmark_file=benchmark_file)
Exemplo n.º 5
0
def test_AG(instance, job, machine):
    print("probleme ", instance, job, machine, "  : \n")
    makespan_list = []
    min = 10000000
    population = 0
    generation = 0
    proba = 0
    makespan_parameter = {}
    # toutes les combinaisons possibles de probabilites et de taille population et taille generation
    for p in list_probabilite:
        for o in list_population:
            for g in list_generation:
                sequence, makespan = solve_problem.solve_benchmark_problem(
                    instance, job, machine, o, g, p)
                if makespan < min:
                    min = makespan
                    population = o
                    generation = g
                    proba = p
                    # makespan_parameter.append({makespan:[p,o,g]})
                    print("mutations probabilite: ", p, "generation", g,
                          "population", o, "resultat", makespan)
    """print(makespan_list)
    minimum = np.min(makespan_list)
    print(makespan_parameter.fromkeys(minimum))
    """

    row = []
    row.append(str(instance) + str(machine) + str(job) + ".txt")
    row.append(sequence)
    row.append(min)
    row.append(proba)
    row.append(population)
    row.append(generation)
    print(row)
    with open('resultat5.csv', 'a') as csvFile:
        writer = csv.writer(csvFile)
        writer.writerow(row)
    csvFile.close()
Exemplo n.º 6
0
    def run_algorithm(self):
        val_0 = int(self.w.val_0.value())
        val_1 = int(self.w.val_1.value())
        val_2 = int(self.w.val_2.value())
        val_3 = int(self.w.val_3.value())
        val_4 = int(self.w.val_4.value())
        val_5 = int(self.w.doubleSpinBox.value())
        print(val_0, val_1, val_2)
        print(val_5)
        # get the file name for NEH amelioree and CDS
        file_name = str(self.w.val_0.value()) + str(
            self.w.val_1.value()) + str(self.w.val_2.value()) + ".txt"
        open("instance/" + file_name, 'r')
        # self.w.text.append("CLicked with values %d, %d , %d " % (val_0, val_1, val_2))
        if self.type == 0:  # branch and bound
            pass
        elif self.type == 1:  # NEH
            sequence2 = sb.check_output(
                ['neh.exe', 'instance/' + str(file_name)])
            sequence = sequence2.decode("utf-8")
            x = sequence.split(",")
            makespan = x[self.w.val_2.value()]
            pass
        elif self.type == 2:  # NEH Amelioree
            a = 'NehAmelioree.exe instance/' + str(file_name)
            sequence = sb.getoutput(str(a))
            # get the makespan from the sequence string
            x = sequence.split(",")
            makespan = x[self.w.val_2.value()]
        elif self.type == 3:  # CDS
            a = 'cds.exe instance/' + str(file_name)
            sequence = sb.getoutput(str(a))
            # get the makespan from the sequence string
            x = sequence.split(",")
            makespan = x[self.w.val_2.value()]
        elif self.type == 4:  # Algorithme genetique
            sequence, makespan = solve_problem.solve_benchmark_problem(
                val_0, val_2, val_1, val_3, val_4, val_5)
        elif self.type == 5:  # VNS

            sequence2 = sb.check_output(
                ['neh.exe', 'instance/' + str(file_name)])
            sequence3 = sb.check_output([
                'vns.exe', 'instance/' + str(file_name),
                str(val_0),
                sequence2.decode("utf-8"), "0",
                str(val_1),
                str(int(val_2))
            ])
            sequence = sequence3.decode("utf-8")
            x = sequence.split(",")
            makespan = x[self.w.val_2.value()]
        elif self.type == 6:  # Hyper Heuristqiue
            res = sb.getoutput('python hyper.py' + ' instance/' + file_name)
            print(res)
            res = res.split(',')
            sequence = res[:-1]
            # Convert them to a list of int
            # sequence = list(map(int, sequence))
            makespan = res[-1]
        elif self.type == 7:  # Palmer
            res = sb.getoutput('python Palmer_s_Heurtistic.py' + ' instance/' +
                               file_name).split(',')
            sequence = res[:-1]
            # Convert them to a list of int
            sequence = list(map(int, sequence))
            makespan = res[-1]

        print(sequence, makespan)
        self.w.label_resultat.setText(str(sequence))
        self.w.timeField.display(makespan)