def solve(input_data,m,lambda1): lambda2 = 1 - lambda1 Data = input_data.split('\n') # load data n = len(Data) -1 # get the amount of items items = [] for j in xrange(n): data = Data[j] parts = data.split() p = int(parts[0]) # get the process time r = int(parts[1]) # get the release time s = int(parts[2]) # get the setup time d = int(parts[3]) # get the due date wt = int(parts[4]) # get the tardiness weights wc = int(parts[5]) # get the completion weights items.append(Item(p,r,s,d,wt,wc)) # combine those item data print 'Data loaded!' S,L,completion,item_free = generate.initialization_c(items,n,m) print 'Initialization done!' line_values,G = generate.Goal(completion,items,S,lambda1,lambda2) print 'Initialization values done!' print G NR = 19 item_values = h(S,completion,items,lambda1,lambda2) for k in xrange(NR): l_p,l_m = generate.reorder(items,S,line_values,item_values) S[l_p],c_p = ATCS(items,S[l_p],m) S[l_m],c_m = ATCS(items,S[l_m],m) completion,line_values = complete_time(S,items,lambda1,lambda2) item_values = h(S,completion,items,lambda1,lambda2) G = sum(line_values) Rb,c= generate.balance_rate(completion,S) return G,Rb
def solve(input_data, m, lambda1): lambda2 = 1 - lambda1 Data = input_data.split('\n') # load data n = len(Data) - 1 # get the amount of items items = [] for j in xrange(n): data = Data[j] parts = data.split() p = int(parts[0]) # get the process time r = int(parts[1]) # get the release time s = int(parts[2]) # get the setup time d = int(parts[3]) # get the due date wt = int(parts[4]) # get the tardiness weights wc = int(parts[5]) # get the completion weights items.append(Item(p, r, s, d, wt, wc)) # combine those item data print 'Data loaded!' S, L, completion, item_free = generate.initialization_c(items, n, m) print 'Initialization done!' line_values, G = generate.Goal(completion, items, S, lambda1, lambda2) print 'Initialization values done!' print G NR = 19 item_values = h(S, completion, items, lambda1, lambda2) for k in xrange(NR): l_p, l_m = generate.reorder(items, S, line_values, item_values) S[l_p], c_p = ATCS(items, S[l_p], m) S[l_m], c_m = ATCS(items, S[l_m], m) completion, line_values = complete_time(S, items, lambda1, lambda2) item_values = h(S, completion, items, lambda1, lambda2) G = sum(line_values) Rb, c = generate.balance_rate(completion, S) return G, Rb
def solve(input_data, lambda1, N, NL, m): lambda2 = 1 - lambda1 Data = input_data.split('\n') # load data n = len(Data) - 1 # get the amount of items m = 5 items = [] for j in xrange(n): data = Data[j] parts = data.split() p = int(parts[0]) # get the process time r = int(parts[1]) # get the release time s = int(parts[2]) # get the setup time d = int(parts[3]) # get the due date wt = int(parts[4]) # get the tardiness weights wc = int(parts[5]) # get the completion weights items.append(Item(p, r, s, d, wt, wc)) # combine those item data print 'Data loaded!' S, L, completion, item_free = generate.initialization_c(items, n, m) print 'Initialization done!' line_values, G = generate.Goal(completion, items, S, lambda1, lambda2) print 'Initialization values done!' print G NR = 10 item_values = continueatcs.h(S, completion, items, lambda1, lambda2) G_star = G S_star = [] for s in S: S_star.append(s[:]) for k in xrange(NR): l_p, l_m = generate.reorder(items, S_star, line_values, item_values) completion, line_values = continueatcs.complete_time( S_star, items, lambda1, lambda2) G_star = sum(line_values) G_star, S_star, line_values, completion = tabu(N, NL, S_star, l_p, items, G_star, completion, line_values, lambda1, lambda2) G_star, S_star, line_values, completion = tabu(N, NL, S_star, l_m, items, G_star, completion, line_values, lambda1, lambda2) item_values = continueatcs.h(S_star, completion, items, lambda1, lambda2) Rb, _ = generate.balance_rate(completion, S) completion, line_values = continueatcs.complete_time( S_star, items, lambda1, lambda2) return G_star, Rb
def solve(input_data,lambda1,N,NL,m): lambda2 = 1 - lambda1 Data = input_data.split('\n') # load data n = len(Data) -1 # get the amount of items m = 5 items = [] for j in xrange(n): data = Data[j] parts = data.split() p = int(parts[0]) # get the process time r = int(parts[1]) # get the release time s = int(parts[2]) # get the setup time d = int(parts[3]) # get the due date wt = int(parts[4]) # get the tardiness weights wc = int(parts[5]) # get the completion weights items.append(Item(p,r,s,d,wt,wc)) # combine those item data print 'Data loaded!' S,L,completion,item_free = generate.initialization_c(items,n,m) print 'Initialization done!' line_values,G = generate.Goal(completion,items,S,lambda1,lambda2) print 'Initialization values done!' print G NR = 10 item_values = continueatcs.h(S,completion,items,lambda1,lambda2) G_star = G S_star =[] for s in S: S_star.append(s[:]) for k in xrange(NR): l_p,l_m = generate.reorder(items,S_star,line_values,item_values) completion,line_values = continueatcs.complete_time(S_star,items,lambda1,lambda2) G_star = sum(line_values) G_star,S_star,line_values,completion = tabu(N,NL,S_star,l_p,items,G_star,completion,line_values,lambda1,lambda2) G_star,S_star,line_values,completion = tabu(N,NL,S_star,l_m,items,G_star,completion,line_values,lambda1,lambda2) item_values = continueatcs.h(S_star,completion,items,lambda1,lambda2) Rb,_ = generate.balance_rate(completion,S) completion,line_values = continueatcs.complete_time(S_star,items,lambda1,lambda2) return G_star,Rb
def solve(input_data,m,lambda1,NR): lambda2 = 1- lambda1 Data = input_data.split('\n') # load data n = len(Data) -1 # get the amount of items items = [] for j in xrange(n): data = Data[j] parts = data.split() p = int(parts[0]) # get the process time s = int(parts[2]) # get the setup time d = int(parts[3]) # get the due date wt = int(parts[4]) # get the tardiness weights wc = int(parts[5]) # get the completion weights items.append(Item(p+s,d,wt,wc)) # combine those item data print 'Data loaded!' S,L,completion = generate.initialization(items,n,m) print 'Initialization done!' lateness = generate.late(completion,items) # begin the value initialization tardiness = generate.tard(lateness) item_values = [] for j in xrange(n): item = items[j] wt,wc = item.wt,item.wc t,c = tardiness[j],completion[j] value = h(t,c,wt,wc,lambda1,lambda2) item_values.append(value) G = generate.H(item_values,L) line_values = [] for s in S: value = generate.H(item_values,s) line_values.append(value) print 'Initial values done!' for k in xrange(NR): l_p,l_m = generate.reorder(items,S,line_values,item_values) S[l_p],c_p = ATC(items,S[l_p]) S[l_m],c_m = ATC(items,S[l_m]) for j in S[l_p]: completion[j] = c_p.pop(0) c = completion[j] item = items[j] wt,wc = item.wt,item.wc late = completion[j] - item.due t = generate.tard(late) item_values[j] = h(t[0],c,wt,wc,lambda1,lambda2) for j in S[l_m]: completion[j] = c_m.pop(0) c = completion[j] item = items[j] wt,wc = item.wt,item.wc late = completion[j] - item.due t = generate.tard(late) item_values[j] = h(t[0],c,wt,wc,lambda1,lambda2) delta_p = generate.H(item_values,S[l_p]) - line_values[l_p] delta_m = generate.H(item_values,S[l_m]) - line_values[l_m] line_values[l_p] += delta_p line_values[l_m] += delta_m G = G + delta_m + delta_p lateness = generate.late(completion,items) tardiness = generate.tard(lateness) u = tardiness.count(0) cv = u/len(tardiness) return G,cv,S
def solve(input_data,m,lambda1,N,NL,NR): lambda2 = 1- lambda1 Data = input_data.split('\n') # load data n = len(Data) -1 # get the amount of items items = [] for j in xrange(n): data = Data[j] parts = data.split() p = int(parts[0]) # get the process time s = int(parts[2]) # get the setup time d = int(parts[3]) # get the due date wt = int(parts[4]) # get the tardiness weights wc = int(parts[5]) # get the completion weights items.append(Item(p+s,d,wt,wc)) # combine those item data print 'Data loaded!' S,L,completion = generate.initialization(items,n,m) print 'Initialization done!' completion,tardiness,item_values = value_generator(S,items,lambda1,lambda2) G = generate.H(item_values,L) line_values = [] for s in S: value = generate.H(item_values,s) line_values.append(value) print 'Initial values done!' for l in xrange(m): delta,S[l]= tabu(N,NL,S[l],items,completion,tardiness,lambda1,lambda2) G += delta line_values[l] += delta completion,tardiness,item_values = value_generator(S,items,lambda1,lambda2) print 'Initial Tabu Search done!' value = G S_temp = [None]*m for l in xrange(m): S_temp[l] = S[l][:] line_values_temp = line_values[:] item_values_temp = item_values[:] for k in xrange(NR): l_p,l_m = generate.reorder(items,S_temp,line_values_temp,item_values_temp) completion_temp,tardiness_temp,item_values_temp = value_generator(S_temp,items,lambda1,lambda2) line_values_temp[l_p] = generate.H(item_values_temp,S_temp[l_p]) line_values_temp[l_m] = generate.H(item_values_temp,S_temp[l_m]) delta_p,S_temp[l_p] = tabu(N,NL,S_temp[l_p],items,completion_temp,tardiness_temp,lambda1,lambda2) delta_m,S_temp[l_m] = tabu(N,NL,S_temp[l_m],items,completion_temp,tardiness_temp,lambda1,lambda2) line_values_temp[l_p] += delta_p line_values_temp[l_m] += delta_m value = generate.H(item_values_temp,L) value = value + delta_m + delta_p if value < G: G = value line_values = line_values_temp[:] completion,tardiness,item_values = value_generator(S_temp,items,lambda1,lambda2) for l in xrange(m): S[l] = S_temp[l][:] print G u = tardiness.count(0) cv = u/len(tardiness) print tardiness return G,cv,S
def solve(input_data, m, lambda1, NR): lambda2 = 1 - lambda1 Data = input_data.split('\n') # load data n = len(Data) - 1 # get the amount of items items = [] for j in xrange(n): data = Data[j] parts = data.split() p = int(parts[0]) # get the process time s = int(parts[2]) # get the setup time d = int(parts[3]) # get the due date wt = int(parts[4]) # get the tardiness weights wc = int(parts[5]) # get the completion weights items.append(Item(p + s, d, wt, wc)) # combine those item data print 'Data loaded!' S, L, completion = generate.initialization(items, n, m) print 'Initialization done!' lateness = generate.late(completion, items) # begin the value initialization tardiness = generate.tard(lateness) item_values = [] for j in xrange(n): item = items[j] wt, wc = item.wt, item.wc t, c = tardiness[j], completion[j] value = h(t, c, wt, wc, lambda1, lambda2) item_values.append(value) G = generate.H(item_values, L) line_values = [] for s in S: value = generate.H(item_values, s) line_values.append(value) print 'Initial values done!' for k in xrange(NR): l_p, l_m = generate.reorder(items, S, line_values, item_values) S[l_p], c_p = ATC(items, S[l_p]) S[l_m], c_m = ATC(items, S[l_m]) for j in S[l_p]: completion[j] = c_p.pop(0) c = completion[j] item = items[j] wt, wc = item.wt, item.wc late = completion[j] - item.due t = generate.tard(late) item_values[j] = h(t[0], c, wt, wc, lambda1, lambda2) for j in S[l_m]: completion[j] = c_m.pop(0) c = completion[j] item = items[j] wt, wc = item.wt, item.wc late = completion[j] - item.due t = generate.tard(late) item_values[j] = h(t[0], c, wt, wc, lambda1, lambda2) delta_p = generate.H(item_values, S[l_p]) - line_values[l_p] delta_m = generate.H(item_values, S[l_m]) - line_values[l_m] line_values[l_p] += delta_p line_values[l_m] += delta_m G = G + delta_m + delta_p lateness = generate.late(completion, items) tardiness = generate.tard(lateness) u = tardiness.count(0) cv = u / len(tardiness) return G, cv, S