增加了HSMO整线优化方法,读取数据增加了供料器部分
This commit is contained in:
@@ -1,12 +1,12 @@
|
||||
from base_optimizer.optimizer_common import *
|
||||
|
||||
from base_optimizer.smtopt_route import *
|
||||
|
||||
def list_range(start, end=None):
|
||||
return list(range(start)) if end is None else list(range(start, end))
|
||||
|
||||
|
||||
@timer_wrapper
|
||||
def optimizer_aggregation(component_data, pcb_data):
|
||||
def optimizer_aggregation(component_data, pcb_data, hinter=True):
|
||||
# === phase 0: data preparation ===
|
||||
M = 1000 # a sufficient large number
|
||||
a, b = 1, 6 # coefficient
|
||||
@@ -43,7 +43,7 @@ def optimizer_aggregation(component_data, pcb_data):
|
||||
|
||||
# === phase 1: mathematical model solver ===
|
||||
mdl = Model('SMT')
|
||||
mdl.setParam('OutputFlag', 0)
|
||||
mdl.setParam('OutputFlag', hinter)
|
||||
|
||||
# === Decision Variables ===
|
||||
# the number of components of type i that are placed by nozzle type j on placement head k
|
||||
@@ -104,8 +104,7 @@ def optimizer_aggregation(component_data, pcb_data):
|
||||
mdl.setParam("TimeLimit", 100)
|
||||
|
||||
mdl.optimize()
|
||||
|
||||
if mdl.Status == GRB.OPTIMAL:
|
||||
if mdl.Status == GRB.OPTIMAL or mdl.Status == GRB.TIME_LIMIT:
|
||||
print('total cost = {}'.format(mdl.objval))
|
||||
|
||||
# convert cp model solution to standard output
|
||||
@@ -160,25 +159,9 @@ def optimizer_aggregation(component_data, pcb_data):
|
||||
feeder_slot_result = feeder_assignment(component_data, pcb_data, component_result, cycle_result)
|
||||
|
||||
# === phase 2: heuristic method ===
|
||||
mount_point_pos = defaultdict(list)
|
||||
for pcb_idx, data in pcb_data.iterrows():
|
||||
part = data['part']
|
||||
part_index = component_data[component_data['part'] == part].index.tolist()[0]
|
||||
mount_point_pos[part_index].append([data['x'], data['y'], pcb_idx])
|
||||
|
||||
for index_ in mount_point_pos.keys():
|
||||
mount_point_pos[index_].sort(key=lambda x: (x[1], x[0]))
|
||||
|
||||
for cycle_idx, _ in enumerate(cycle_result):
|
||||
for _ in range(cycle_result[cycle_idx]):
|
||||
placement_result.append([-1 for _ in range(max_head_index)])
|
||||
for head in range(max_head_index):
|
||||
if component_result[cycle_idx][head] == -1:
|
||||
continue
|
||||
index_ = component_result[cycle_idx][head]
|
||||
placement_result[-1][head] = mount_point_pos[index_][-1][2]
|
||||
mount_point_pos[index_].pop()
|
||||
head_sequence.append(dynamic_programming_cycle_path(pcb_data, placement_result[-1], feeder_slot_result[cycle_idx]))
|
||||
placement_result, head_sequence = greedy_level_placing_route_generation(component_data, pcb_data,
|
||||
component_result, cycle_result,
|
||||
feeder_slot_result)
|
||||
|
||||
else:
|
||||
warnings.warn('No solution found!', UserWarning)
|
||||
|
Reference in New Issue
Block a user