Example #1
0
def neh(data, nb_machines, nb_jobs):
    order_seq = order_neh(data, nb_machines, nb_jobs)
    seq_current = [order_seq[0]]
    for i in range(1, nb_jobs):
        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]
def neh(data, nb_machines, nb_jobs):
    order_seq = order_neh(data, nb_machines, nb_jobs)
    #Ustawiamy task z najwyższą sumą jako pierwszy element listy
    seq_current = [order_seq[0]]
    for i in range(1, nb_jobs):
        #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]
Example #3
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
Example #4
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)
def random_seq(data, num_of_task, nb_mach):
    seq = list(range(0, num_of_task))
    random.shuffle(seq)
    time_of_seq = commonFunction.makespan(seq, data,
                                          nb_mach)[nb_mach - 1][len(seq)]
    return seq, time_of_seq
        #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()
Example #7
0
def johnson(data, nb_machines, nb_jobs):
    seq_current = commonFunction.u(data, nb_jobs) + commonFunction.v(data, nb_jobs)
    return seq_current, commonFunction.makespan(seq_current, p_ij, nb_machines)[nb_machines - 1][nb_jobs]
Example #8
0
import commonFunction
import interface


def johnson(data, nb_machines, nb_jobs):
    seq_current = commonFunction.u(data, nb_jobs) + commonFunction.v(data, nb_jobs)
    return seq_current, commonFunction.makespan(seq_current, p_ij, nb_machines)[nb_machines - 1][nb_jobs]


# run Johnson
nbm, nbj, p_ij = commonFunction.read_from_file("example.txt")
seq, cmax = johnson(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("johnson:", seq, cmax)
interface.graphic("Johnson", seq, nbj, nbm, commonFunction.makespan(seq, p_ij, nbm), p_ij)