Ejemplo n.º 1
0

def cds(data, nb_machines, nb_jobs):
    c_max_best = float("inf")
    for k in range(1, nb_machines):
        p1_prime = get_merge(0, k, data, nb_jobs)
        p2_prime = get_merge(nb_machines - k, nb_machines, data, nb_jobs)
        ss_pb = [p1_prime, p2_prime]
        print(ss_pb)
        current_seq = commonFunction.u(ss_pb, nb_jobs) + commonFunction.v(
            ss_pb, nb_jobs)
        c_max = commonFunction.makespan(current_seq, data,
                                        nb_machines)[nb_machines - 1][nb_jobs]
        print(current_seq, c_max)
        if c_max < c_max_best:
            c_max_best = c_max
            best_seq = current_seq

    return best_seq, c_max_best


# run CDS
nbm, nbj, p_ij = commonFunction.read_from_file("example2.txt")
seq, cmax = cds(p_ij, nbm, nbj)
print("nbMachines:", nbm)
print("nbJobs:", nbj)
print("data: p_ij, the processing time of jth job on ith machine\n", p_ij)
print("cds:", seq, cmax)
interface.graphic("CDS", seq, nbj, nbm,
                  commonFunction.makespan(seq, p_ij, nbm), p_ij)
        #Zainicjowanie wartości minimalnej jako infinity
        min_cmax = float("inf")
        for j in range(0, i + 1):
            tmp_seq = insertion(seq_current, j, order_seq[i])
            cmax_tmp = commonFunction.makespan(
                tmp_seq, data, nb_machines)[nb_machines - 1][len(tmp_seq)]
            #print(tmp_seq, cmax_tmp)
            if min_cmax > cmax_tmp:
                best_seq = tmp_seq
                min_cmax = cmax_tmp
        seq_current = best_seq
    return seq_current, commonFunction.makespan(
        seq_current, data, nb_machines)[nb_machines - 1][nb_jobs]


# run NEH
time_table = np.array(data1).transpose()

seq, cmax = neh(time_table, num_of_divices, num_of_tasks)
print("nbMachines:", num_of_divices)
print("nbJobs:", num_of_tasks)
#print("data: p_ij, the processing time of jth job on ith machine\n", time_table)
print("neh: ", seq, cmax)
#print(cmax)
interface.graphic("NEH", seq, num_of_tasks, num_of_divices,
                  commonFunction.makespan(seq, time_table, num_of_divices),
                  time_table)

seque, t = sym_wyz(time_table, num_of_tasks, num_of_divices)
print("symul: ", seque, t)
matplotlib.pyplot.show()