增加了HSMO整线优化方法,读取数据增加了供料器部分
This commit is contained in:
20
estimator.py
20
estimator.py
@@ -6,9 +6,9 @@ def exact_assembly_time(pcb_data, component_data):
|
||||
feeder_data = pd.DataFrame(columns=['slot', 'part'])
|
||||
component_result, cycle_result, feeder_slot_result = feeder_priority_assignment(component_data, pcb_data,
|
||||
feeder_data, hinter=False)
|
||||
placement_result, head_sequence_result = greedy_placement_route_generation(component_data, pcb_data,
|
||||
component_result, cycle_result,
|
||||
feeder_slot_result, hinter=False)
|
||||
placement_result, head_sequence_result = place_allocate_sequence_route_generation(component_data, pcb_data,
|
||||
component_result, cycle_result,
|
||||
feeder_slot_result, hinter=False)
|
||||
opt_res = OptResult(component_result, cycle_result, feeder_slot_result, placement_result, head_sequence_result)
|
||||
info = placement_info_evaluation(component_data, pcb_data, opt_res)
|
||||
# return info.metric()
|
||||
@@ -19,7 +19,7 @@ def error_info(pred_val, real_val, type='train'):
|
||||
absolute_error = np.array([])
|
||||
for idx, (t1, t2) in enumerate(np.nditer([pred_val, real_val])):
|
||||
absolute_error = np.append(absolute_error, abs(t1 - t2) / (t2 + 1e-10) * 100)
|
||||
if absolute_error[-1] > 15:
|
||||
if absolute_error[-1] > 10:
|
||||
print(f'\033[0;31;31midx: {idx + 1: d}, net: {t1: .3f}, real: {t2: .3f}, '
|
||||
f'gap: {absolute_error[-1]: .3f}\033[0m')
|
||||
|
||||
@@ -561,6 +561,8 @@ class MetricEstimator(Estimator):
|
||||
def training(self, params):
|
||||
x_fit, y_fit = data_mgr.metric('opt/' + params.train_file)
|
||||
self.lr.fit(x_fit, y_fit)
|
||||
y_predict = self.lr.predict(x_fit)
|
||||
error_info(y_fit, y_predict, 'train')
|
||||
print(self.lr.coef_)
|
||||
|
||||
def testing(self, params):
|
||||
@@ -578,7 +580,7 @@ if __name__ == '__main__':
|
||||
|
||||
parser = argparse.ArgumentParser(description='network training implementation')
|
||||
# parser.add_argument('--train', default=True, type=bool, help='determine whether training the network')
|
||||
parser.add_argument('--save', default=True, type=bool,
|
||||
parser.add_argument('--save', default=False, type=bool,
|
||||
help='determine whether saving the parameters of network, linear regression model, etc.')
|
||||
parser.add_argument('--overwrite', default=False, type=bool,
|
||||
help='determine whether overwriting the training and testing data')
|
||||
@@ -588,7 +590,7 @@ if __name__ == '__main__':
|
||||
parser.add_argument('--batch_size', default=2000, type=int, help='size of training batch')
|
||||
parser.add_argument('--lr', default=1e-5, type=float, help='learning rate for the network')
|
||||
parser.add_argument('--model', default='neural-network', help='method for assembly time estimation')
|
||||
parser.add_argument('--machine_optimizer', default='feeder-scan', type=str, help='optimizer for single machine')
|
||||
parser.add_argument('--machine_optimizer', default='feeder-priority', type=str, help='optimizer for single machine')
|
||||
params = parser.parse_args()
|
||||
|
||||
data_mgr = DataMgr()
|
||||
@@ -606,13 +608,13 @@ if __name__ == '__main__':
|
||||
# data_mgr.remover() # remove the last saved data
|
||||
# data_mgr.saver('data/' + file_name, pcb_data) # save new data
|
||||
|
||||
info = base_optimizer(1, pcb_data, component_data, pd.DataFrame(columns=['slot', 'part', 'arg']),
|
||||
params, hinter=True)
|
||||
info = base_optimizer(1, pcb_data, component_data, pd.DataFrame(columns=['slot', 'part']), params,
|
||||
hinter=True)
|
||||
|
||||
data_mgr.recorder(f, info, pcb_data, component_data)
|
||||
f.close()
|
||||
|
||||
estimator = MetricEstimator()
|
||||
estimator = NeuralEstimator()
|
||||
|
||||
estimator.training(params)
|
||||
estimator.testing(params)
|
||||
|
Reference in New Issue
Block a user