def solve(input_data, N, NL, lambda1, m): 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]) 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 'Initial values done!' for l in xrange(m): G, S, line_values, completion = continuetabu.tabu( N, NL, S, l, items, G, completion, line_values, lambda1, lambda2) G, S = tabu(N, NL, S, L, items, G, lambda1, lambda2) c, v = continueatcs.complete_time(S, items, lambda1, lambda2) Rb, _ = 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,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,N,NL,lambda1,m): 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]) 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 'Initial values done!' for l in xrange(m): G,S,line_values,completion = continuetabu.tabu(N,NL,S,l,items,G,completion,line_values,lambda1,lambda2) G,S = tabu(N,NL,S,L,items,G,lambda1,lambda2) c,v = continueatcs.complete_time(S,items,lambda1,lambda2) Rb,_ = generate.balance_rate(completion,S) return G,Rb
def h(S,completion,items,lambda1,lambda2): # redefine the contribution of one item for the obj function n = len(items) lateness = generate.late(completion,items) value = [None]*n Rb,c_max = generate.balance_rate(completion,S) Ru = generate.idle_rate(items,completion,c_max,S) for s in S: l = S.index(s) for j in s: value[j] = lambda1*(math.fabs(items[j].wt*lateness[j]))/Ru[l] + lambda2*items[j].wc*completion[j]*math.exp(-Rb) return value
def h(S, completion, items, lambda1, lambda2): # redefine the contribution of one item for the obj function n = len(items) lateness = generate.late(completion, items) value = [None] * n Rb, c_max = generate.balance_rate(completion, S) Ru = generate.idle_rate(items, completion, c_max, S) for s in S: l = S.index(s) for j in s: value[j] = lambda1 * (math.fabs(items[j].wt * lateness[j])) / Ru[ l] + lambda2 * items[j].wc * completion[j] * math.exp(-Rb) return value
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