#path=1 if ((i%2==0 and j%2==0) or (i%2==1 and j%2==1) ) else 2 with open("../LKH/s1path"+str(path)+"/ans"+problem+".csv","rb") as f: add=[k for k in csv.reader(f)] add.reverse() ###########REMOVE THIS?? fans2+=add print len(fans2) fans1i=[int(i[0]) for i in fans] fans2i=[int(i[0]) for i in fans2] fans1ip1=[int(i[0])+1 for i in fans] fans2ip1=[int(i[0])+1 for i in fans2] #for i in fans1i: # print i print dist(fans1ip1) print dist(fans2ip1) #print validate(fans1i) #print validate(fans2i) #print fans1i[:5] fans1iw=[[i] for i in fans1i] fans2iw=[[i] for i in fans2i] with open("../LKH/results/mingle10/mingle1.csv","wb") as f: csv.writer(f).writerow(["path1"]) csv.writer(f).writerows(fans1iw) with open("../LKH/results/mingle10/mingle2.csv","wb") as f: csv.writer(f).writerow(["path2"]) csv.writer(f).writerows(fans2iw)
add=[int(k[0]) for k in csv.reader(f)] add.reverse() fans2.append(add) combs=[] for i in xrange(2**35,2**36): a=bin(i) #print a[2:] if str(a[2:]).count('1')==8: combs.append(a[2:]) cnt=0 print len(fans1) for i in combs: mingle1=[] mingle2=[] print i for j in i: if j=='0': mingle1+=fans1[cnt] mingle2+=fans2[cnt] else: mingle1+=fans2[cnt] mingle2+=fans1[cnt] cnt+=1 print len(mingle1) print dist(mingle1),dist(mingle2) exit() with csv.writer(open("mingle/mingle1.csv","wb")) as f: f.writerows(mingle1) with csv.writer(open("mingle/mingle2.csv","wb")) as f: f.writerows(mingle2)