def comparison(f, seed_num): js, qcs, ya, num_yts = ran_example(6, 2, 2, 3) re_fea_sol, re_set_cut = [], [] for qs, ys, ts in search_feasible_sol(js, qcs, ya, num_yts): q = tuple([tuple(x[:])for x in qs]) y = [x[:]for x in ys] t = [x[:]for x in ts] re_fea_sol.append([q, y, t]) jobs, qcs_seq, ycs_seq, yts_seq, planed_jobs, qcs_primary_j, agreeable_yts_of_jobs, handling_v, qcs_num_of_flag, cut = initialize(js, qcs, ya, num_yts) for ys, ts in set_cut_all_enumeration(cut, agreeable_yts_of_jobs, qcs_num_of_flag, qcs_primary_j, planed_jobs, ycs_seq, yts_seq, jobs, qcs_seq, handling_v): re_set_cut.append([qcs_seq, ys, ts]) set_fea_sol = set() for qs, ys, ts in re_fea_sol: qcs_seq = [] for i, s in enumerate(qs): sq = [x.id for x in s] sq.append('QC' + str(i)) qcs_seq.append(tuple(sq)) ycs_seq = [] for i, s in enumerate(ys): sy = [x.id for x in s] sy.append('YC' + str(i)) ycs_seq.append(tuple(sy)) yts_seq = [] for i, s in enumerate(ts): st = [x.id for x in s] st.append('YT' + str(i)) yts_seq.append(tuple(st)) set_fea_sol.add((tuple(qcs_seq), tuple(ycs_seq), tuple(yts_seq))) s1 = (len(set_fea_sol), set_fea_sol) set_set_cut = set() for qs, ys, ts in re_set_cut: qcs_seq = [] for i, q in enumerate(qs): sq = list(q[:]) sq.append('QC' + str(i)) qcs_seq.append(tuple(sq)) ycs_seq = [] for i, y in enumerate(ys): sy = y[:] sy.append('YC' + str(i)) ycs_seq.append(tuple(sy)) yts_seq = [] for i, t in enumerate(ts): st = t[:] st.append('YT' + str(i)) yts_seq.append(tuple(st)) set_set_cut.add((tuple(qcs_seq), tuple(ycs_seq), tuple(yts_seq))) s2 = (len(set_set_cut), set_set_cut) # print len(re_fea_sol), re_fea_sol # print len(re_set_cut), re_set_cut # print len(set_fea_sol), set_fea_sol # print len(set_set_cut), set_set_cut # print set_set_cut == set_fea_sol r1_size, r1_content = s1 r2_size, r2_content = s2 if r1_size != r2_size: f.write('seed number : '+ str(seed_num)) f.write('\n') f.write('r1_size : ' + str(r1_size) + ' r2_size : ' + str(r2_size)) f.write('\n') for i, x in enumerate(r2_content): if x not in r1_content: f.write(str(i) + ' : ' + str(x)) f.write('\n') f.write('\n') if set_set_cut == set_fea_sol: return True
def comparison(f, seed_num, is_there_pickle = False): re_fea_sol, re_set_cut = [], [] if is_there_pickle : pb, re_fea_sol = load_schedules('all_enumeration.pkl') js, qcs, ya, num_yts = pb # print pb, re_fea_sol else: seed(seed_num) pb = js, qcs, ya, num_yts = ran_example(6, 2, 2, 3) print 'search_feasible start!!' count = 0 start_t = time() for qs, ys, ts in search_feasible_sol(js, qcs, ya, num_yts): count += 1 if count % 1000 == 0: print 'time : ', str(time() - start_t), ' doing search_feasible_sol... count : ', count q = tuple([tuple(x[:])for x in qs]) y = [x[:]for x in ys] t = [x[:]for x in ts] re_fea_sol.append([q, y, t]) save_schedules(pb, re_fea_sol, 'all_enumeration.pkl') print 'total : ', count print 'search_feasible end!!' f.write('job info : ' + str(js)) f.write('\n') print 'set_cut_all_enumeration start' start_t = time() jobs, qcs_seq, ycs_seq, yts_seq, planed_jobs, qcs_primary_j, agreeable_yts_of_jobs, handling_v, qcs_num_of_flag, cut = initialize(js, qcs, ya, num_yts) for ys, ts in set_cut_all_enumeration(cut, agreeable_yts_of_jobs, qcs_num_of_flag, qcs_primary_j, planed_jobs, ycs_seq, yts_seq, jobs, qcs_seq, handling_v): re_set_cut.append([qcs_seq, ys, ts]) print 'processing time : ', str(time() - start_t) print 'set_cut_all_enumeration end!!' set_fea_sol = set() for qs, ys, ts in re_fea_sol: qcs_seq = [] for i, s in enumerate(qs): sq = [x.id for x in s] sq.append('QC' + str(i)) qcs_seq.append(tuple(sq)) ycs_seq = [] for i, s in enumerate(ys): sy = [x.id for x in s] sy.append('YC' + str(i)) ycs_seq.append(tuple(sy)) yts_seq = [] for i, s in enumerate(ts): st = [x.id for x in s] st.append('YT' + str(i)) yts_seq.append(tuple(st)) set_fea_sol.add((tuple(qcs_seq), tuple(ycs_seq), tuple(yts_seq))) s1 = (len(set_fea_sol), set_fea_sol) set_set_cut = set() for qs, ys, ts in re_set_cut: qcs_seq = [] for i, q in enumerate(qs): sq = list(q[:]) sq.append('QC' + str(i)) qcs_seq.append(tuple(sq)) ycs_seq = [] for i, y in enumerate(ys): sy = y[:] sy.append('YC' + str(i)) ycs_seq.append(tuple(sy)) yts_seq = [] for i, t in enumerate(ts): st = t[:] st.append('YT' + str(i)) yts_seq.append(tuple(st)) set_set_cut.add((tuple(qcs_seq), tuple(ycs_seq), tuple(yts_seq))) s2 = (len(set_set_cut), set_set_cut) all_enumeration_size, all_enumeration_content = s1 set_cut_size, set_cut_content = s2 if all_enumeration_size != set_cut_size: f.write('seed number : ' + str(seed_num)) f.write('\n') f.write('all_enumeration_size : ' + str(all_enumeration_size) + ' set_cut_size : ' + str(set_cut_size)) f.write('\n') for i, x in enumerate(set_cut_content): if x not in all_enumeration_content: f.write(str(i) + ' : ' + str(x)) f.write('\n') f.write('\n') # print len(re_fea_sol), re_fea_sol # print len(re_set_cut), re_set_cut # print len(set_fea_sol), set_fea_sol # print len(set_set_cut), set_set_cut # print set_set_cut == set_fea_sol if set_set_cut == set_fea_sol: return True
def comparison(): # seed(100) # seed(10) seed(99) #1:D ,2:D ,0:D ,3:D # seed(16) #2:D ,0:D ,3:D ,1:D # seed(17) #0:L ,1:L ,2:L ,3:D js, qcs, ya, num_yts = ran_example(4, 1, 2, 2) # re_fea_sol, re_set_cut = set(), set() re_fea_sol, re_set_cut = [],[] for qs, ys, ts in search_feasible_sol(js, qcs, ya, num_yts): q = [x[:]for x in qs] y = [x[:]for x in ys] t = [x[:]for x in ts] re_fea_sol.append([q, y, t]) jobs, qcs_seq, ycs_seq, yts_seq, scheduled_js, qcs_primary_j, agreeable_yt_of_job, handling_v, qcs_num_of_flag, cut = initialize(js, qcs, ya, num_yts) for qs, ys, ts in set_cut_run(jobs, qcs_seq, ycs_seq, yts_seq, scheduled_js, qcs_primary_j, agreeable_yt_of_job, handling_v, qcs_num_of_flag, cut): re_set_cut.append([qs, ys, ts]) print len(re_fea_sol), re_fea_sol print len(re_set_cut), re_set_cut set_fea_sol = set() for qs, ys, ts in re_fea_sol: qcs_seq = [] for i, s in enumerate(qs): sq = [x.id for x in s] sq.append('QC' + str(i)) qcs_seq.append(tuple(sq)) ycs_seq = [] for i, s in enumerate(ys): sy = [x.id for x in s] sy.append('YC' + str(i)) ycs_seq.append(tuple(sy)) yts_seq = [] for i, s in enumerate(ts): st = [x.id for x in s] st.append('YT' + str(i)) yts_seq.append(tuple(st)) set_fea_sol.add((tuple(qcs_seq), tuple(ycs_seq), tuple(yts_seq))) print len(set_fea_sol), set_fea_sol set_set_cut = set() for qs, ys, ts in re_set_cut: qcs_seq = [] for i, q in enumerate(qs): sq = q[:] sq.append('QC' + str(i)) qcs_seq.append(tuple(sq)) ycs_seq = [] for i, y in enumerate(ys): sy = y[:] sy.append('YC' + str(i)) ycs_seq.append(tuple(sy)) yts_seq = [] for i, t in enumerate(ts): st = t[:] st.append('YT' + str(i)) yts_seq.append(tuple(st)) set_set_cut.add((tuple(qcs_seq), tuple(ycs_seq), tuple(yts_seq))) print len(set_set_cut),set_set_cut print set_set_cut == set_fea_sol
def comparison(): seed(100) # seed(99) # seed(10) js, qcs, ya, num_yts = ran_example(4, 1, 2, 2) # re_fea_sol, re_set_cut = set(), set() re_fea_sol, re_set_cut = [],[] for qs, ys, ts in search_feasible_sol(js, qcs, ya, num_yts): q = [x[:]for x in qs] y = [x[:]for x in ys] t = [x[:]for x in ts] re_fea_sol.append([q, y, t]) jobs, qcs_seq, ycs_seq, yts_seq, scheduled_js, qcs_primary_j, agreeable_yt_of_job, handling_v, qcs_num_of_flag, cut = initialize(js, qcs, ya, num_yts) for qs, ys, ts in set_cut_run(jobs, qcs_seq, ycs_seq, yts_seq, scheduled_js, qcs_primary_j, agreeable_yt_of_job, handling_v, qcs_num_of_flag, cut): re_set_cut.append([qs, ys, ts]) print len(re_fea_sol), re_fea_sol print len(re_set_cut), re_set_cut set_fea_sol = set() for qs, ys, ts in re_fea_sol: qcs_seq = [] for i, s in enumerate(qs): sq = [x.id for x in s] sq.append('QC' + str(i)) qcs_seq.append(tuple(sq)) ycs_seq = [] for i, s in enumerate(ys): sy = [x.id for x in s] sy.append('YC' + str(i)) ycs_seq.append(tuple(sy)) yts_seq = [] for i, s in enumerate(ts): st = [x.id for x in s] st.append('YT' + str(i)) yts_seq.append(tuple(st)) set_fea_sol.add((tuple(qcs_seq), tuple(ycs_seq), tuple(yts_seq))) print len(set_fea_sol), set_fea_sol set_set_cut = set() for qs, ys, ts in re_set_cut: qcs_seq = [] for q in qs: sq = list(q.job_seq) sq.append('QC' + str(q.id)) qcs_seq.append(tuple(sq)) # print sq ycs_seq = [] for y in ys: sy = list(y.job_seq) sy.append('YC' + str(y.id)) ycs_seq.append(tuple(sy)) yts_seq = [] for t in ts: st = list(t.job_seq) st.append('YT' + str(t.id)) yts_seq.append(tuple(st)) set_set_cut.add((tuple(qcs_seq), tuple(ycs_seq), tuple(yts_seq))) print len(set_set_cut),set_set_cut