添加 i5 i7
parent
5ed962f9c3
commit
29a651f874
135
tools/t7.py
135
tools/t7.py
|
|
@ -33,6 +33,7 @@ class AutoLayout:
|
||||||
# 芯片barcode
|
# 芯片barcode
|
||||||
self.chip_barcode_recode = defaultdict(set)
|
self.chip_barcode_recode = defaultdict(set)
|
||||||
self.chip_barcodei7_recode = defaultdict(set)
|
self.chip_barcodei7_recode = defaultdict(set)
|
||||||
|
self.chip_barcodei5_recode = defaultdict(set)
|
||||||
# 芯片原始数据读取
|
# 芯片原始数据读取
|
||||||
self.ori_data = self.read_excel()
|
self.ori_data = self.read_excel()
|
||||||
# 当前锚芯片
|
# 当前锚芯片
|
||||||
|
|
@ -64,15 +65,53 @@ class AutoLayout:
|
||||||
self.is_use_balance = is_use_balance
|
self.is_use_balance = is_use_balance
|
||||||
self.is_use_max = is_use_max
|
self.is_use_max = is_use_max
|
||||||
|
|
||||||
def count_barcode_radio(self, data, maxt=False):
|
@staticmethod
|
||||||
|
def read_cols():
|
||||||
|
df = pd.read_excel(os.path.join(basedir, 'rule', 'columns.xlsx'))
|
||||||
|
cols = list(df['cols'].values)
|
||||||
|
return cols
|
||||||
|
|
||||||
|
def read_excel(self):
|
||||||
|
"""
|
||||||
|
原始数据处理
|
||||||
|
:return:
|
||||||
|
"""
|
||||||
|
merge = pd.read_excel(self.path, None)
|
||||||
|
ori_data = dict()
|
||||||
|
for name, sheet in merge.items():
|
||||||
|
sheet.fillna('', inplace=True)
|
||||||
|
ori_data[name] = sheet.to_dict('records')
|
||||||
|
return ori_data
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def read_rule():
|
||||||
|
df = pd.read_excel(os.path.join(basedir, 'rule', 'exclusive_classfication.xlsx'))
|
||||||
|
newdf = pd.DataFrame()
|
||||||
|
newdf['c1'] = df['c2']
|
||||||
|
newdf['c2'] = df['c1']
|
||||||
|
res = pd.concat([df, newdf])
|
||||||
|
return res.reset_index()
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def read_rule_exclusive_customer():
|
||||||
|
df = pd.read_excel(os.path.join(basedir, 'rule', 'exclusive_customer.xlsx'))
|
||||||
|
newdf = pd.DataFrame()
|
||||||
|
newdf['customer1'] = df['customer2']
|
||||||
|
newdf['customer2'] = df['customer1']
|
||||||
|
res = pd.concat([df, newdf])
|
||||||
|
return res.reset_index()
|
||||||
|
|
||||||
|
def count_barcode_radio(self, data, maxt=''):
|
||||||
df = pd.DataFrame(data)
|
df = pd.DataFrame(data)
|
||||||
ratio_sites = dict()
|
ratio_sites = dict()
|
||||||
is_not_balance_list = []
|
is_not_balance_list = []
|
||||||
if df.empty:
|
if df.empty:
|
||||||
return ratio_sites, is_not_balance_list
|
return ratio_sites, is_not_balance_list
|
||||||
s, e = 0, 16
|
s, e = 0, 16
|
||||||
if maxt:
|
if maxt == 'i7':
|
||||||
s, e = 8, 16
|
s, e = 8, 16
|
||||||
|
if maxt == 'i5':
|
||||||
|
s, e = 0, 8
|
||||||
num = e - s
|
num = e - s
|
||||||
df['barcode'] = df['barcode'].str.slice(s, e)
|
df['barcode'] = df['barcode'].str.slice(s, e)
|
||||||
barcode_df = pd.DataFrame(df['barcode'].str.split('', expand=True).iloc[:, 1:-1].values,
|
barcode_df = pd.DataFrame(df['barcode'].str.split('', expand=True).iloc[:, 1:-1].values,
|
||||||
|
|
@ -161,42 +200,6 @@ class AutoLayout:
|
||||||
else:
|
else:
|
||||||
return 100000
|
return 100000
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def read_rule():
|
|
||||||
df = pd.read_excel(os.path.join(basedir, 'rule', 'exclusive_classfication.xlsx'))
|
|
||||||
newdf = pd.DataFrame()
|
|
||||||
newdf['c1'] = df['c2']
|
|
||||||
newdf['c2'] = df['c1']
|
|
||||||
res = pd.concat([df, newdf])
|
|
||||||
return res.reset_index()
|
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def read_rule_exclusive_customer():
|
|
||||||
df = pd.read_excel(os.path.join(basedir, 'rule', 'exclusive_customer.xlsx'))
|
|
||||||
newdf = pd.DataFrame()
|
|
||||||
newdf['customer1'] = df['customer2']
|
|
||||||
newdf['customer2'] = df['customer1']
|
|
||||||
res = pd.concat([df, newdf])
|
|
||||||
return res.reset_index()
|
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def read_cols():
|
|
||||||
df = pd.read_excel(os.path.join(basedir, 'rule', 'columns.xlsx'))
|
|
||||||
cols = list(df['cols'].values)
|
|
||||||
return cols
|
|
||||||
|
|
||||||
def read_excel(self):
|
|
||||||
"""
|
|
||||||
原始数据处理
|
|
||||||
:return:
|
|
||||||
"""
|
|
||||||
merge = pd.read_excel(self.path, None)
|
|
||||||
ori_data = dict()
|
|
||||||
for name, sheet in merge.items():
|
|
||||||
sheet.fillna('', inplace=True)
|
|
||||||
ori_data[name] = sheet.to_dict('records')
|
|
||||||
return ori_data
|
|
||||||
|
|
||||||
def combinations_same_barcode(self):
|
def combinations_same_barcode(self):
|
||||||
"""
|
"""
|
||||||
barcode 有重复的极致样本 进行排列组合,汇集成新的可能性
|
barcode 有重复的极致样本 进行排列组合,汇集成新的可能性
|
||||||
|
|
@ -250,6 +253,8 @@ class AutoLayout:
|
||||||
"""
|
"""
|
||||||
self.index_assignments[chipname].extend(library_data['data'])
|
self.index_assignments[chipname].extend(library_data['data'])
|
||||||
self.chip_barcode_recode[chipname].update({item['barcode'] for item in library_data['data']})
|
self.chip_barcode_recode[chipname].update({item['barcode'] for item in library_data['data']})
|
||||||
|
self.chip_barcodei7_recode[chipname].update({item['i7'] for item in library_data['data']})
|
||||||
|
self.chip_barcodei5_recode[chipname].update({item['i5'] for item in library_data['data']})
|
||||||
|
|
||||||
self.chip_customer[chipname].add(library_data['customer'])
|
self.chip_customer[chipname].add(library_data['customer'])
|
||||||
self.chip_classification[chipname].add(library_data['classification'])
|
self.chip_classification[chipname].add(library_data['classification'])
|
||||||
|
|
@ -280,7 +285,7 @@ class AutoLayout:
|
||||||
if library_data['is_balance_lib'] == '甲基化':
|
if library_data['is_balance_lib'] == '甲基化':
|
||||||
self.chip_methylib_size[chipname] += library_data['size']
|
self.chip_methylib_size[chipname] += library_data['size']
|
||||||
if 'nextera' in library_data['classification'].lower():
|
if 'nextera' in library_data['classification'].lower():
|
||||||
self.chip_speciallib_huada_size[chipname] += library_data['size']
|
self.chip_speciallib_nextera_size[chipname] += library_data['size']
|
||||||
if '华大' in library_data['classification']:
|
if '华大' in library_data['classification']:
|
||||||
self.chip_speciallib_huada_size[chipname] += library_data['size']
|
self.chip_speciallib_huada_size[chipname] += library_data['size']
|
||||||
|
|
||||||
|
|
@ -297,7 +302,7 @@ class AutoLayout:
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def judge_data(self, chipname, library_data, max_barcode=False):
|
def judge_data(self, chipname, library_data, max_barcode='all'):
|
||||||
"""
|
"""
|
||||||
约束条件
|
约束条件
|
||||||
"""
|
"""
|
||||||
|
|
@ -362,17 +367,23 @@ class AutoLayout:
|
||||||
use_huada = False
|
use_huada = False
|
||||||
|
|
||||||
# 开启i5或者i7
|
# 开启i5或者i7
|
||||||
if max_barcode:
|
if max_barcode != 'all':
|
||||||
base_balance = True
|
base_balance = True
|
||||||
# 开启i7:
|
|
||||||
notrepeatbarcode = True
|
notrepeatbarcode = True
|
||||||
if self.chip_barcodei7_recode[chipname].intersection({item['i7'] for item in library_data['data']}):
|
if self.chip_barcodei7_recode[chipname].intersection({item['i7'] for item in library_data['data']}) and max_barcode == 'i7':
|
||||||
|
notrepeatbarcode = False
|
||||||
|
if self.chip_barcodei5_recode[chipname].intersection({item['i5'] for item in library_data['data']}) and max_barcode == 'i5':
|
||||||
|
notrepeatbarcode = False
|
||||||
|
#是个N的取消
|
||||||
|
if ('N' * 8 in {item['i5'] for item in library_data['data']}) and max_barcode == 'i5':
|
||||||
|
notrepeatbarcode = False
|
||||||
|
if ('N' * 8 in {item['i7'] for item in library_data['data']}) and max_barcode == 'i7':
|
||||||
notrepeatbarcode = False
|
notrepeatbarcode = False
|
||||||
if self.chip_size[chipname] > 900:
|
if self.chip_size[chipname] > 900:
|
||||||
current_data = copy.deepcopy(self.index_assignments[chipname])
|
current_data = copy.deepcopy(self.index_assignments[chipname])
|
||||||
new_data = library_data['data']
|
new_data = library_data['data']
|
||||||
current_data.extend(new_data)
|
current_data.extend(new_data)
|
||||||
ratio_sites, is_not_balance_list = self.count_barcode_radio(current_data, maxt=True)
|
ratio_sites, is_not_balance_list = self.count_barcode_radio(current_data, maxt=max_barcode)
|
||||||
if is_not_balance_list:
|
if is_not_balance_list:
|
||||||
base_balance = False
|
base_balance = False
|
||||||
|
|
||||||
|
|
@ -380,12 +391,12 @@ class AutoLayout:
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def add_loc_num(self):
|
def add_loc_num(self, chipname):
|
||||||
"""
|
"""
|
||||||
锚定芯片号增加
|
锚定芯片号增加
|
||||||
"""
|
"""
|
||||||
# 有nextera, 华大文库 必须满足大于50G 到了芯片结算
|
# 有nextera, 华大文库 必须满足大于50G 到了芯片结算
|
||||||
chipname = f'chip{self.loc_chip_num}'
|
# chipname = f'chip{self.loc_chip_num}'
|
||||||
nextera_size = self.chip_speciallib_nextera_size[chipname]
|
nextera_size = self.chip_speciallib_nextera_size[chipname]
|
||||||
huada_size = self.chip_speciallib_huada_size[chipname]
|
huada_size = self.chip_speciallib_huada_size[chipname]
|
||||||
flag = True
|
flag = True
|
||||||
|
|
@ -409,7 +420,7 @@ class AutoLayout:
|
||||||
huada_barcode = set()
|
huada_barcode = set()
|
||||||
no_huada_data = list()
|
no_huada_data = list()
|
||||||
for libdata in self.index_assignments[chipname]:
|
for libdata in self.index_assignments[chipname]:
|
||||||
if libdata['classification'] != '华大':
|
if '华大' not in libdata['classification']:
|
||||||
no_huada_data.append(libdata)
|
no_huada_data.append(libdata)
|
||||||
else:
|
else:
|
||||||
self.no_assign_data.append(libdata)
|
self.no_assign_data.append(libdata)
|
||||||
|
|
@ -538,14 +549,14 @@ class AutoLayout:
|
||||||
break
|
break
|
||||||
j += 1
|
j += 1
|
||||||
else:
|
else:
|
||||||
self.add_loc_num()
|
self.add_loc_num(chipname)
|
||||||
|
|
||||||
if self.chip_size[chipname] > self.data_limit:
|
if self.chip_size[chipname] > self.data_limit:
|
||||||
self.add_loc_num()
|
self.add_loc_num(chipname)
|
||||||
|
|
||||||
def assign_again(self):
|
def assign_again_size(self, max_barcode='all'):
|
||||||
"""
|
"""
|
||||||
剩余的数据,开放i5或者i7再排下
|
剩余的数据
|
||||||
"""
|
"""
|
||||||
left_data = list()
|
left_data = list()
|
||||||
no_need_chipname = list()
|
no_need_chipname = list()
|
||||||
|
|
@ -555,7 +566,6 @@ class AutoLayout:
|
||||||
df = pd.DataFrame(chip_assignments)
|
df = pd.DataFrame(chip_assignments)
|
||||||
if df['data_needed'].sum() < 1700:
|
if df['data_needed'].sum() < 1700:
|
||||||
left_data.extend(chip_assignments)
|
left_data.extend(chip_assignments)
|
||||||
# del self.index_assignments[chip_idx]
|
|
||||||
no_need_chipname.append(chip_idx)
|
no_need_chipname.append(chip_idx)
|
||||||
for chip_idx in no_need_chipname:
|
for chip_idx in no_need_chipname:
|
||||||
del self.index_assignments[chip_idx]
|
del self.index_assignments[chip_idx]
|
||||||
|
|
@ -576,11 +586,11 @@ class AutoLayout:
|
||||||
data=library_df[self.need_cols].to_dict('records')
|
data=library_df[self.need_cols].to_dict('records')
|
||||||
))
|
))
|
||||||
|
|
||||||
ori_lib_data = sorted(ori_lib_data, key=lambda x: (x['level'], -x['size']))
|
ori_lib_data = sorted(ori_lib_data, key=lambda x: (x['level'], x['time'], -x['size']))
|
||||||
self.loc_chip_num = 100
|
self.loc_chip_num = 100
|
||||||
while ori_lib_data:
|
while ori_lib_data:
|
||||||
library_data = ori_lib_data[0]
|
library_data = ori_lib_data[0]
|
||||||
chipname = f'chipB{self.loc_chip_num}'
|
chipname = f'chipB{self.loc_chip_num}_{max_barcode}' if max_barcode != 'all' else f'chipB{self.loc_chip_num}'
|
||||||
|
|
||||||
# 空白芯片直接添加
|
# 空白芯片直接添加
|
||||||
if chipname not in self.index_assignments:
|
if chipname not in self.index_assignments:
|
||||||
|
|
@ -589,22 +599,22 @@ class AutoLayout:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
# 判断条件
|
# 判断条件
|
||||||
if self.judge_data(chipname, library_data, max_barcode=True):
|
if self.judge_data(chipname, library_data, max_barcode=max_barcode):
|
||||||
self.add_new_data(chipname, library_data, newer=False)
|
self.add_new_data(chipname, library_data, newer=False)
|
||||||
ori_lib_data.remove(library_data)
|
ori_lib_data.remove(library_data)
|
||||||
else:
|
else:
|
||||||
for j in range(len(ori_lib_data)):
|
for j in range(len(ori_lib_data)):
|
||||||
newlibrary_data = ori_lib_data[j]
|
newlibrary_data = ori_lib_data[j]
|
||||||
if self.judge_data(chipname, newlibrary_data, max_barcode=True):
|
if self.judge_data(chipname, newlibrary_data, max_barcode=max_barcode):
|
||||||
ori_lib_data.remove(newlibrary_data)
|
ori_lib_data.remove(newlibrary_data)
|
||||||
self.add_new_data(chipname, newlibrary_data, newer=False)
|
self.add_new_data(chipname, newlibrary_data, newer=False)
|
||||||
break
|
break
|
||||||
j += 1
|
j += 1
|
||||||
else:
|
else:
|
||||||
self.loc_chip_num += 1
|
self.add_loc_num(chipname)
|
||||||
|
|
||||||
if self.chip_size[chipname] > self.data_limit:
|
if self.chip_size[chipname] > self.data_limit:
|
||||||
self.loc_chip_num += 1
|
self.add_loc_num(chipname)
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
# print('# 测试代码')
|
# print('# 测试代码')
|
||||||
|
|
@ -612,7 +622,10 @@ class AutoLayout:
|
||||||
# self.assign_again()
|
# self.assign_again()
|
||||||
try:
|
try:
|
||||||
self.assign_samples()
|
self.assign_samples()
|
||||||
self.assign_again()
|
self.assign_again_size()
|
||||||
|
# self.assign_again_size(max_barcode='i7')
|
||||||
|
# self.assign_again_size(max_barcode='i5')
|
||||||
|
# self.assign_again_size()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
self.return_log.append(f'T7排样出错, 请联系!{e}')
|
self.return_log.append(f'T7排样出错, 请联系!{e}')
|
||||||
self.index_assignments = {}
|
self.index_assignments = {}
|
||||||
|
|
@ -633,8 +646,8 @@ class AutoLayout:
|
||||||
else:
|
else:
|
||||||
addname = ''
|
addname = ''
|
||||||
other_name = ''
|
other_name = ''
|
||||||
if 'chipB' in chip_idx and df['barcode'].duplicated().any():
|
# if 'chipB' in chip_idx and df['barcode'].duplicated().any():
|
||||||
other_name = '_i7'
|
# other_name = '_i7'
|
||||||
|
|
||||||
if df['data_needed'].sum() < 1600 and not addname:
|
if df['data_needed'].sum() < 1600 and not addname:
|
||||||
df['note'] = '排样数据量不足1600G'
|
df['note'] = '排样数据量不足1600G'
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue