修改数据格式和双面板优化

This commit is contained in:
2025-12-09 09:29:10 +08:00
parent 96e4b3d856
commit d627cf9f6e
8 changed files with 125 additions and 118 deletions

View File

@@ -49,15 +49,18 @@ def load_data(filename: str):
except: except:
part_data = pd.DataFrame(columns=part_col) part_data = pd.DataFrame(columns=part_col)
for _, data in step_data.iterrows(): for _, data in step_data.iterrows():
if data.part not in part_data.part.values: if data.part not in part_data.part.values:
raise Exception("unregistered component: " + data.part) raise Exception("unregistered component: " + data.part)
if coordinate == "UPPER RIGHT" or coordinate == "LOWER RIGHT": if coordinate == "UPPER RIGHT" or coordinate == "LOWER RIGHT":
data.x = -data.x step_data['x'] = -step_data['x']
if coordinate == "UPPER LEFT" or coordinate == "UPPER RIGHT": if coordinate == "UPPER LEFT" or coordinate == "UPPER RIGHT":
data.y = data.y step_data['y'] = -step_data['y']
data.x, data.y = data.x + origin.x, data.y + origin.y
step_data['x'] += origin.x
step_data['y'] += origin.y
return part_data, step_data return part_data, step_data

View File

@@ -28,6 +28,7 @@ class MachineConfig:
class OptResult: class OptResult:
def __init__(self): def __init__(self):
self.part = [] self.part = []
self.layer = []
self.cycle = [] self.cycle = []
self.slot = [] self.slot = []
self.point = [] self.point = []
@@ -35,6 +36,7 @@ class OptResult:
def __add__(self, other): def __add__(self, other):
self.part.extend(other.part) self.part.extend(other.part)
self.layer.extend(other.layer)
self.cycle.extend(other.cycle) self.cycle.extend(other.cycle)
self.slot.extend(other.slot) self.slot.extend(other.slot)
self.point.extend(other.point) self.point.extend(other.point)

View File

@@ -58,8 +58,8 @@ Registered Place Count : 2594
0603-822 SME8 CN065 1 0603-822 SME8 CN065 1
0603-823 SME8 CN065 1 0603-823 SME8 CN065 1
0603-911 SME8 CN065 1 0603-911 SME8 CN065 1
201R-2<EFBFBD><EFBFBD>04PG-6.0/3.0 SME8 CN065 1 201R-2x04PG-6.0/3.0 SME8 CN065 1
201R-2<EFBFBD><EFBFBD>7PG-6.0/3.0 SME8 CN065 1 201R-2x7PG-6.0/3.0 SME8 CN065 1
201R-3*02PG-6.2/3.3 SME8 CN065 1 201R-3*02PG-6.2/3.3 SME8 CN065 1
21E6-278-337-B1 SME8 CN140 1 21E6-278-337-B1 SME8 CN140 1
2512-1W-R005F SME12 CN140 1 2512-1W-R005F SME12 CN140 1
@@ -98,7 +98,7 @@ CT41-1210-2R2-6.3V-107 SME8 CN140 1
EFM25F128A Tray Feeder CN220 1 EFM25F128A Tray Feeder CN220 1
EFM25QU256-E8 Tray Feeder CN220 1 EFM25QU256-E8 Tray Feeder CN220 1
FT-M6678N Tray Feeder ML150 1 FT-M6678N Tray Feeder ML150 1
GCA45-D-6.3V-470<EFBFBD><EFBFBD>F-K SME12 CN220 1 GCA45-D-6.3V-470uF-K SME12 CN220 1
GCT41L-0805-2C1-50V-334K SME8 CN065 1 GCT41L-0805-2C1-50V-334K SME8 CN065 1
GD32F450VKT6 Tray Feeder CN750 1 GD32F450VKT6 Tray Feeder CN750 1
GX21M15 SME12 CN220 1 GX21M15 SME12 CN220 1
@@ -544,18 +544,18 @@ H7 -220.425 50.000 0.000 0.0 S 1
H8 -220.425 80.000 0.000 0.0 S 1 H8 -220.425 80.000 0.000 0.0 S 1
H15 -220.425 110.000 0.000 0.0 S 1 H15 -220.425 110.000 0.000 0.0 S 1
H16 -220.425 140.000 0.000 0.0 S 1 H16 -220.425 140.000 0.000 0.0 S 1
C1784 -211.989 47.473 0.000 90.0 GCA45-D-6.3V-470<EFBFBD><EFBFBD>F-K 1 C1784 -211.989 47.473 0.000 90.0 GCA45-D-6.3V-470uF-K 1
C1786 -211.201 69.621 0.000 0.0 GCA45-D-6.3V-470<EFBFBD><EFBFBD>F-K 1 C1786 -211.201 69.621 0.000 0.0 GCA45-D-6.3V-470uF-K 1
C1783 -210.795 136.246 0.000 0.0 GCA45-D-6.3V-470<EFBFBD><EFBFBD>F-K 1 C1783 -210.795 136.246 0.000 0.0 GCA45-D-6.3V-470uF-K 1
C1785 -210.388 120.777 0.000 0.0 GCA45-D-6.3V-470<EFBFBD><EFBFBD>F-K 1 C1785 -210.388 120.777 0.000 0.0 GCA45-D-6.3V-470uF-K 1
C1782 -208.814 80.721 0.000 0.0 GCA45-D-6.3V-470<EFBFBD><EFBFBD>F-K 1 C1782 -208.814 80.721 0.000 0.0 GCA45-D-6.3V-470uF-K 1
TP31 -206.274 45.390 0.000 90.0 S 1 TP31 -206.274 45.390 0.000 90.0 S 1
TP32 -206.147 48.209 0.000 90.0 S 1 TP32 -206.147 48.209 0.000 90.0 S 1
TP33 -205.613 127.762 0.000 90.0 S 1 TP33 -205.613 127.762 0.000 90.0 S 1
TP34 -205.410 131.445 0.000 90.0 S 1 TP34 -205.410 131.445 0.000 90.0 S 1
H18 -204.175 157.500 0.000 0.0 S 1 H18 -204.175 157.500 0.000 0.0 S 1
L18 -203.085 140.838 0.000 180.0 PZ1608U221-1R4 1 L18 -203.085 140.838 0.000 180.0 PZ1608U221-1R4 1
C1788 -202.591 19.660 0.000 90.0 GCA45-D-6.3V-470<EFBFBD><EFBFBD>F-K 1 C1788 -202.591 19.660 0.000 90.0 GCA45-D-6.3V-470uF-K 1
V10 -193.503 149.568 0.000 180.0 2SC3052 1 V10 -193.503 149.568 0.000 180.0 2SC3052 1
V22 -193.503 153.149 0.000 180.0 2SC3052 1 V22 -193.503 153.149 0.000 180.0 2SC3052 1
XS7 -181.880 4.800 0.000 0.0 VPX20-1132-0001 1 XS7 -181.880 4.800 0.000 0.0 VPX20-1132-0001 1
@@ -564,7 +564,7 @@ R243 -173.666 148.336 0.000 90.0 0603-000 1
V14 -170.618 152.718 0.000 270.0 YZ-CDR03-2G 1 V14 -170.618 152.718 0.000 270.0 YZ-CDR03-2G 1
V13 -165.538 152.718 0.000 270.0 YZ-CDR03-2G 1 V13 -165.538 152.718 0.000 270.0 YZ-CDR03-2G 1
XS12 -153.504 152.654 0.000 0.0 302-2R-14P 1 XS12 -153.504 152.654 0.000 0.0 302-2R-14P 1
C1787 -153.213 17.577 0.000 90.0 GCA45-D-6.3V-470<EFBFBD><EFBFBD>F-K 1 C1787 -153.213 17.577 0.000 90.0 GCA45-D-6.3V-470uF-K 1
XS6 -153.080 4.800 0.000 0.0 VPX20-1132-0001 1 XS6 -153.080 4.800 0.000 0.0 VPX20-1132-0001 1
TP29 -152.197 75.565 0.000 90.0 S 1 TP29 -152.197 75.565 0.000 90.0 S 1
R242 -151.441 148.336 0.000 90.0 0603-000 1 R242 -151.441 148.336 0.000 90.0 0603-000 1
@@ -617,7 +617,7 @@ R347 -105.906 40.711 0.000 180.0 0402-101 1
TP4 -105.842 80.010 0.000 0.0 S 1 TP4 -105.842 80.010 0.000 0.0 S 1
V12 -105.188 152.718 0.000 270.0 YZ-CDR03-2G 1 V12 -105.188 152.718 0.000 270.0 YZ-CDR03-2G 1
TP10 -102.286 143.002 0.000 90.0 S 1 TP10 -102.286 143.002 0.000 90.0 S 1
XS10 -102.184 154.654 0.000 0.0 201R-2<EFBFBD><EFBFBD>7PG-6.0/3.0 1 XS10 -102.184 154.654 0.000 0.0 201R-2x7PG-6.0/3.0 1
R38 -100.508 83.312 0.000 0.0 0402-101 1 R38 -100.508 83.312 0.000 0.0 0402-101 1
H9 -98.730 22.860 0.000 0.0 S 1 H9 -98.730 22.860 0.000 0.0 S 1
L24 -98.716 33.020 0.000 180.0 PB3216-600/6A 1 L24 -98.716 33.020 0.000 180.0 PB3216-600/6A 1
@@ -664,9 +664,9 @@ U5 -79.025 147.681 0.000 0.0 S 1
L21 -77.008 73.787 0.000 0.0 PB3216-600/6A 1 L21 -77.008 73.787 0.000 0.0 PB3216-600/6A 1
U4 -74.910 147.681 0.000 0.0 S 1 U4 -74.910 147.681 0.000 0.0 S 1
D18 -73.761 21.403 0.000 -90.0 NLC5304-DSPR 1 D18 -73.761 21.403 0.000 -90.0 NLC5304-DSPR 1
C1757 -73.076 135.001 0.000 0.0 GCA45-D-6.3V-470<EFBFBD><EFBFBD>F-K 1 C1757 -73.076 135.001 0.000 0.0 GCA45-D-6.3V-470uF-K 1
TP20 -73.076 143.764 0.000 0.0 S 1 TP20 -73.076 143.764 0.000 0.0 S 1
C1756 -72.873 125.501 0.000 90.0 GCA45-D-6.3V-470<EFBFBD><EFBFBD>F-K 1 C1756 -72.873 125.501 0.000 90.0 GCA45-D-6.3V-470uF-K 1
G2 -72.314 87.550 0.000 -90.0 V9P3CN160WS-156.25MHz 1 G2 -72.314 87.550 0.000 -90.0 V9P3CN160WS-156.25MHz 1
L33 -72.067 78.852 0.000 0.0 S 1 L33 -72.067 78.852 0.000 0.0 S 1
TP3 -71.425 116.078 0.000 0.0 S 1 TP3 -71.425 116.078 0.000 0.0 S 1
@@ -695,7 +695,7 @@ H14 -60.630 73.025 0.000 0.0 S 1
L28 -59.868 89.027 0.000 180.0 XECJUPZ1608E600-3R5 1 L28 -59.868 89.027 0.000 180.0 XECJUPZ1608E600-3R5 1
R261 -59.614 113.792 0.000 90.0 S 1 R261 -59.614 113.792 0.000 90.0 S 1
R111 -59.360 27.686 0.000 0.0 0603-000 1 R111 -59.360 27.686 0.000 0.0 0603-000 1
XS17 -59.106 154.654 0.000 0.0 201R-2<EFBFBD><EFBFBD>04PG-6.0/3.0 1 XS17 -59.106 154.654 0.000 0.0 201R-2x04PG-6.0/3.0 1
R80 -58.725 113.792 0.000 90.0 0402-472 1 R80 -58.725 113.792 0.000 90.0 0402-472 1
C1594 -58.344 93.472 0.000 180.0 CA45-B-16V-226 1 C1594 -58.344 93.472 0.000 180.0 CA45-B-16V-226 1
C1596 -58.344 97.028 0.000 180.0 CA45-B-16V-226 1 C1596 -58.344 97.028 0.000 180.0 CA45-B-16V-226 1
@@ -723,23 +723,23 @@ R313 -51.207 130.861 0.000 270.0 0603-101 1
R333 -50.846 15.666 0.000 90.0 0603-103 1 R333 -50.846 15.666 0.000 90.0 0603-103 1
D41 -50.714 126.738 0.000 -90.0 MM3Z5V1 1 D41 -50.714 126.738 0.000 -90.0 MM3Z5V1 1
R93 -49.975 32.763 0.000 270.0 0402-472 1 R93 -49.975 32.763 0.000 270.0 0402-472 1
C1586 -49.022 121.463 0.000 0.0 GCA45-D-6.3V-470<EFBFBD><EFBFBD>F-K 1 C1586 -49.022 121.463 0.000 0.0 GCA45-D-6.3V-470uF-K 1
C1588 -47.879 109.423 0.000 270.0 GCA45-D-6.3V-470<EFBFBD><EFBFBD>F-K 1 C1588 -47.879 109.423 0.000 270.0 GCA45-D-6.3V-470uF-K 1
C1590 -47.701 95.377 0.000 90.0 GCA45-D-6.3V-470<EFBFBD><EFBFBD>F-K 1 C1590 -47.701 95.377 0.000 90.0 GCA45-D-6.3V-470uF-K 1
C1589 -47.676 85.217 0.000 270.0 GCA45-D-6.3V-470<EFBFBD><EFBFBD>F-K 1 C1589 -47.676 85.217 0.000 270.0 GCA45-D-6.3V-470uF-K 1
C1593 -47.193 131.648 0.000 270.0 GCA45-D-6.3V-470<EFBFBD><EFBFBD>F-K 1 C1593 -47.193 131.648 0.000 270.0 GCA45-D-6.3V-470uF-K 1
C270 -46.736 116.713 0.000 0.0 GCA45-D-6.3V-470<EFBFBD><EFBFBD>F-K 1 C270 -46.736 116.713 0.000 0.0 GCA45-D-6.3V-470uF-K 1
C1592 -45.822 142.977 0.000 0.0 GCA45-D-6.3V-470<EFBFBD><EFBFBD>F-K 1 C1592 -45.822 142.977 0.000 0.0 GCA45-D-6.3V-470uF-K 1
C1611 -45.812 147.693 0.000 0.0 GCA45-D-6.3V-470<EFBFBD><EFBFBD>F-K 1 C1611 -45.812 147.693 0.000 0.0 GCA45-D-6.3V-470uF-K 1
C271 -43.165 106.045 0.000 270.0 GCA45-D-6.3V-470<EFBFBD><EFBFBD>F-K 1 C271 -43.165 106.045 0.000 270.0 GCA45-D-6.3V-470uF-K 1
C1614 -42.952 51.003 0.000 90.0 GCA45-D-6.3V-470<EFBFBD><EFBFBD>F-K 1 C1614 -42.952 51.003 0.000 90.0 GCA45-D-6.3V-470uF-K 1
C1613 -42.926 41.072 0.000 270.0 GCA45-D-6.3V-470<EFBFBD><EFBFBD>F-K 1 C1613 -42.926 41.072 0.000 270.0 GCA45-D-6.3V-470uF-K 1
C1616 -42.911 74.376 0.000 90.0 GCA45-D-6.3V-470<EFBFBD><EFBFBD>F-K 1 C1616 -42.911 74.376 0.000 90.0 GCA45-D-6.3V-470uF-K 1
C1599 -42.911 85.217 0.000 270.0 GCA45-D-6.3V-470<EFBFBD><EFBFBD>F-K 1 C1599 -42.911 85.217 0.000 270.0 GCA45-D-6.3V-470uF-K 1
C1591 -42.911 95.377 0.000 90.0 GCA45-D-6.3V-470<EFBFBD><EFBFBD>F-K 1 C1591 -42.911 95.377 0.000 90.0 GCA45-D-6.3V-470uF-K 1
C1615 -42.901 64.465 0.000 270.0 GCA45-D-6.3V-470<EFBFBD><EFBFBD>F-K 1 C1615 -42.901 64.465 0.000 270.0 GCA45-D-6.3V-470uF-K 1
C1612 -42.571 131.648 0.000 270.0 GCA45-D-6.3V-470<EFBFBD><EFBFBD>F-K 1 C1612 -42.571 131.648 0.000 270.0 GCA45-D-6.3V-470uF-K 1
C1761 -41.732 29.591 0.000 90.0 GCA45-D-6.3V-470<EFBFBD><EFBFBD>F-K 1 C1761 -41.732 29.591 0.000 90.0 GCA45-D-6.3V-470uF-K 1
TP37 -41.351 22.758 0.000 0.0 S 1 TP37 -41.351 22.758 0.000 0.0 S 1
TP18 -39.675 100.965 0.000 270.0 S 1 TP18 -39.675 100.965 0.000 270.0 S 1
TP23 -39.101 147.955 0.000 270.0 S 1 TP23 -39.101 147.955 0.000 270.0 S 1
@@ -747,12 +747,12 @@ TP24 -38.339 122.555 0.000 270.0 S 1
TP17 -38.085 126.365 0.000 270.0 S 1 TP17 -38.085 126.365 0.000 270.0 S 1
R127 -37.690 21.077 0.000 180.0 0603-102 1 R127 -37.690 21.077 0.000 180.0 0603-102 1
TP12 -37.400 36.491 0.000 270.0 S 1 TP12 -37.400 36.491 0.000 270.0 S 1
C1759 -36.983 29.591 0.000 90.0 GCA45-D-6.3V-470<EFBFBD><EFBFBD>F-K 1 C1759 -36.983 29.591 0.000 90.0 GCA45-D-6.3V-470uF-K 1
TP16 -33.223 31.344 0.000 0.0 S 1 TP16 -33.223 31.344 0.000 0.0 S 1
D38 -31.749 122.047 0.000 180.0 MM3Z5V1 1 D38 -31.749 122.047 0.000 180.0 MM3Z5V1 1
C1760 -31.522 58.522 0.000 180.0 GCA45-D-6.3V-470<EFBFBD><EFBFBD>F-K 1 C1760 -31.522 58.522 0.000 180.0 GCA45-D-6.3V-470uF-K 1
D33 -30.995 101.321 0.000 0.0 MM3Z5V1 1 D33 -30.995 101.321 0.000 0.0 MM3Z5V1 1
C1758 -29.947 35.255 0.000 180.0 GCA45-D-6.3V-470<EFBFBD><EFBFBD>F-K 1 C1758 -29.947 35.255 0.000 180.0 GCA45-D-6.3V-470uF-K 1
R367 -29.830 126.365 0.000 270.0 0603-103 1 R367 -29.830 126.365 0.000 270.0 0603-103 1
H20 -29.175 157.500 0.000 0.0 S 1 H20 -29.175 157.500 0.000 0.0 S 1
R180 -28.524 122.834 0.000 90.0 0603-103 1 R180 -28.524 122.834 0.000 90.0 0603-103 1

View File

@@ -28,7 +28,7 @@ Registered Place Count : 1116
1132S-10P SME8 CN140 1 1132S-10P SME8 CN140 1
1132S-15P SME8 CN140 1 1132S-15P SME8 CN140 1
1206-NC SME8 CN065 1 1206-NC SME8 CN065 1
201S-2。チ03PG-6.0/3.0 SME8 CN065 1 201S-2x03PG-6.0/3.0 SME8 CN065 1
21E6-278-337-B1 SME8 CN140 1 21E6-278-337-B1 SME8 CN140 1
AiP74ALVC164245 Tray Feeder CN220 1 AiP74ALVC164245 Tray Feeder CN220 1
AiP74LVC8T245TA Tray Feeder CN220 1 AiP74LVC8T245TA Tray Feeder CN220 1
@@ -830,8 +830,8 @@ C18 -136.304 -123.365 0.000 0.0 CT41-0603-2X1-100V-104 1
C18 -136.304 -56.365 0.000 0.0 CT41-0603-2X1-100V-104 1 C18 -136.304 -56.365 0.000 0.0 CT41-0603-2X1-100V-104 1
C190 -136.226 -93.380 0.000 0.0 CT41-0402-2X1-16V-104 2 C190 -136.226 -93.380 0.000 0.0 CT41-0402-2X1-16V-104 2
C190 -136.226 -26.380 0.000 0.0 CT41-0402-2X1-16V-104 2 C190 -136.226 -26.380 0.000 0.0 CT41-0402-2X1-16V-104 2
XS1 -135.833 -73.961 0.000 0.0 201S-2。チ03PG-6.0/3.0 1 XS1 -135.833 -73.961 0.000 0.0 201S-2x03PG-6.0/3.0 1
XS1 -135.833 -6.961 0.000 0.0 201S-2。チ03PG-6.0/3.0 1 XS1 -135.833 -6.961 0.000 0.0 201S-2x03PG-6.0/3.0 1
D9 -134.316 -79.745 0.000 270.0 AiP74ALVC164245 2 D9 -134.316 -79.745 0.000 270.0 AiP74ALVC164245 2
D9 -134.316 -12.745 0.000 270.0 AiP74ALVC164245 2 D9 -134.316 -12.745 0.000 270.0 AiP74ALVC164245 2
C81 -133.283 -78.724 0.000 270.0 CT41-0402-2X1-16V-104 1 C81 -133.283 -78.724 0.000 270.0 CT41-0402-2X1-16V-104 1
@@ -1088,8 +1088,8 @@ C18 -34.304 -123.365 0.000 0.0 CT41-0603-2X1-100V-104 1
C18 -34.304 -56.365 0.000 0.0 CT41-0603-2X1-100V-104 1 C18 -34.304 -56.365 0.000 0.0 CT41-0603-2X1-100V-104 1
C190 -34.226 -93.380 0.000 0.0 CT41-0402-2X1-16V-104 2 C190 -34.226 -93.380 0.000 0.0 CT41-0402-2X1-16V-104 2
C190 -34.226 -26.380 0.000 0.0 CT41-0402-2X1-16V-104 2 C190 -34.226 -26.380 0.000 0.0 CT41-0402-2X1-16V-104 2
XS1 -33.833 -73.961 0.000 0.0 201S-2。チ03PG-6.0/3.0 1 XS1 -33.833 -73.961 0.000 0.0 201S-2x03PG-6.0/3.0 1
XS1 -33.833 -6.961 0.000 0.0 201S-2。チ03PG-6.0/3.0 1 XS1 -33.833 -6.961 0.000 0.0 201S-2x03PG-6.0/3.0 1
D9 -32.316 -79.745 0.000 270.0 AiP74ALVC164245 2 D9 -32.316 -79.745 0.000 270.0 AiP74ALVC164245 2
D9 -32.316 -12.745 0.000 270.0 AiP74ALVC164245 2 D9 -32.316 -12.745 0.000 270.0 AiP74ALVC164245 2
C81 -31.283 -78.724 0.000 270.0 CT41-0402-2X1-16V-104 1 C81 -31.283 -78.724 0.000 270.0 CT41-0402-2X1-16V-104 1

View File

@@ -3,9 +3,9 @@ from opt.utils import *
class FeederPriorityOpt(BaseOpt): class FeederPriorityOpt(BaseOpt):
def __init__(self, config, part_data, step_data, feeder_data=pd.DataFrame(columns=['slot', 'part'])): def __init__(self, config, part_data, step_data, feeder_data=pd.DataFrame(columns=['slot', 'part']), layer=1):
super().__init__(config, part_data, step_data, feeder_data) super().__init__(config, part_data, step_data, feeder_data)
self.layer = layer
self.e_gang_pick = 0.6 self.e_gang_pick = 0.6
self.e_nz_change = 4 self.e_nz_change = 4
@@ -28,6 +28,7 @@ class FeederPriorityOpt(BaseOpt):
# 第3步扫描供料器基座确定元件拾取的先后顺序 # 第3步扫描供料器基座确定元件拾取的先后顺序
result = OptResult() result = OptResult()
result.part, result.cycle, result.slot = self.feeder_base_scan(feeder_data) result.part, result.cycle, result.slot = self.feeder_base_scan(feeder_data)
result.layer = [self.layer] * len(result.part)
info = evaluation(self.config, self.part_data, self.step_data, result) info = evaluation(self.config, self.part_data, self.step_data, result)
val = self.cycle_weight * info.cycle_counter + self.nozzle_change_weight * info.nozzle_change_counter + \ val = self.cycle_weight * info.cycle_counter + self.nozzle_change_weight * info.nozzle_change_counter + \
self.pickup_weight * info.pickup_counter + self.move_weight * info.pickup_distance self.pickup_weight * info.pickup_counter + self.move_weight * info.pickup_distance

View File

@@ -1,4 +1,5 @@
import copy import copy
import math
import numpy as np import numpy as np
@@ -91,86 +92,80 @@ class PathPlanOpt:
head_sequence = list(reversed(head_sequence)) head_sequence = list(reversed(head_sequence))
return ans_dist, head_sequence return ans_dist, head_sequence
def scan_based(self, part_result, cycle_result, slot_result): def scan_based(self, part_result, cycle_result, slot_result, hinter=True):
point_result, sequence_result = [], [] point_result, sequence_result = [], []
class Mount: class Mount:
def __init__(self): def __init__(self):
self.pos = [] self.pos = []
self.angle = []
self.part = [] self.part = []
self.step = [] self.step = []
def pop(self, index): def pop(self, index):
self.pos.pop(index) self.pos.pop(index)
self.angle.pop(index)
self.part.pop(index) self.part.pop(index)
self.step.pop(index) self.step.pop(index)
all_points = Mount() all_points = Mount()
for step_index, data in self.step_data.iterrows(): for step_index, data in self.step_data.iterrows():
part_index = self.part_data[self.part_data.part == data.part].index.tolist()[0] part_index = self.part_data[self.part_data.part == data.part].index.tolist()[0]
# <20><>¼<EFBFBD><C2BC>װ<EFBFBD><D7B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ͷ<EFBFBD>Ӧ<EFBFBD><D3A6>λ<EFBFBD><CEBB><EFBFBD><EFBFBD><EFBFBD><EFBFBD> # <20><>¼<EFBFBD><C2BC>װ<EFBFBD><D7B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ͷ<EFBFBD>Ӧ<EFBFBD><D3A6>λ<EFBFBD><CEBB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
all_points.pos.append(Point(data.x + self.config.stopper_pos.x, data.y + self.config.stopper_pos.y)) all_points.pos.append(Point(data.x + self.config.stopper_pos.x, data.y + self.config.stopper_pos.y, data.r))
all_points.angle.append(data.r)
all_points.part.append(part_index) all_points.part.append(part_index)
all_points.step.append(step_index) all_points.step.append(step_index)
point_list = list(range(0, self.step_data.shape[0]))
head_num = self.config.head_num head_num = self.config.head_num
left_boundary, right_boundary = min(all_points.pos, key=lambda p: p.x).x, \ left_boundary, right_boundary = min(all_points.pos, key=lambda p: p.x).x, \
max(all_points.pos, key=lambda p: p.x).x max(all_points.pos, key=lambda p: p.x).x
search_step = max((right_boundary - left_boundary) / head_num / 2, 0) search_step = max((right_boundary - left_boundary) / head_num / 2, 0)
search_points, head_range = defaultdict(lambda: np.array([])), defaultdict(list)
search_points[0] = np.arange(left_boundary, (left_boundary + right_boundary) / 2, search_step)
head_range[0] = list(range(head_num))
search_points[1] = np.arange(right_boundary + 1e-3, (left_boundary + right_boundary) / 2, -search_step)
head_range[1] = list(range(head_num - 1, -1, -1))
search_points[2] = np.arange(left_boundary, right_boundary, search_step)
head_range[2], head_index = [], (head_num - 1) // 2
while head_index >= 0:
if 2 * head_index != head_num - 1:
head_range[2].append(head_num - 1 - head_index)
head_range[2].append(head_index)
head_index -= 1
pbar = tqdm(total=sum(cycle_result), desc='scan-based path plan process') if hinter else None
ref_pos_y = min(all_points.pos, key=lambda p: p.y).y ref_pos_y = min(all_points.pos, key=lambda p: p.y).y
for cycle_index, component_cycle in enumerate(part_result): for cycle_index, component_cycle in enumerate(part_result):
for _ in range(cycle_result[cycle_index]): for _ in range(cycle_result[cycle_index]):
min_dist = np.inf min_dist = np.inf
tmp_assigned_point, tmp_assigned_head_seq = [], [] best_head_point, best_head_seq, best_point_list = [], [], []
for dir in range(3): # <20><>ͬ<EFBFBD><CDAC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>װͷ<D7B0><CDB7><EFBFBD><EFBFBD>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD>ѡȡ<D1A1><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͬ
for start_points in search_points[dir]:
cur_point_list = point_list.copy()
tmp_all_points = Mount() head_point = [-1] * head_num
for search_dir in range(3): # <20><>ͬ<EFBFBD><CDAC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>װͷ<D7B0><CDB7><EFBFBD><EFBFBD>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD>ѡȡ<D1A1><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͬ assigned_point = [Point(0, 0)] * head_num
if search_dir == 0:
# <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
search_points = np.arange(left_boundary, (left_boundary + right_boundary) / 2, search_step)
head_range = list(range(head_num))
elif search_dir == 1:
# <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
search_points = np.arange(right_boundary + 1e-3, (left_boundary + right_boundary) / 2, -search_step)
head_range = list(range(head_num - 1, -1, -1))
else:
# <20><><EFBFBD>м<EFBFBD><D0BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
search_points = np.arange(left_boundary, right_boundary, search_step / 2)
head_range, head_index = [], (head_num - 1) // 2
while head_index >= 0:
if 2 * head_index != head_num - 1:
head_range.append(head_num - 1 - head_index)
head_range.append(head_index)
head_index -= 1
for start_points in search_points:
cur_all_points = copy.deepcopy(all_points)
assigned_point = [-1] * head_num
assigned_mount_point, assigned_mount_angle = [Point(0, 0)] * head_num, [0] * head_num
head_counter, point_index = 0, -1 head_counter, point_index = 0, -1
for head_index in head_range: for head_index in head_range[dir]:
if head_counter == 0: if head_counter == 0:
part_index = part_result[cycle_index][head_index] if part_result[cycle_index][head_index] == -1:
if part_index == -1:
continue continue
min_horizontal_distance = np.inf min_horizontal_distance = np.inf
for index, part in enumerate(cur_all_points.part): for index, point in enumerate(cur_point_list):
if part != part_result[cycle_index][head_index]: if all_points.part[point] != part_result[cycle_index][head_index]:
continue continue
horizontal_distance = abs(cur_all_points.pos[index].x - start_points) + 0 * abs( horizontal_distance = abs(all_points.pos[point].x - start_points) + 0 * abs(
cur_all_points.pos[index].y - ref_pos_y) all_points.pos[point].y - ref_pos_y)
if horizontal_distance < min_horizontal_distance: if horizontal_distance < min_horizontal_distance:
min_horizontal_distance = horizontal_distance min_horizontal_distance = horizontal_distance
@@ -179,18 +174,18 @@ class PathPlanOpt:
point_index = -1 point_index = -1
min_cheby_distance = np.inf min_cheby_distance = np.inf
for index, part in enumerate(cur_all_points.part): for index, point in enumerate(cur_point_list):
if part != part_result[cycle_index][head_index]: if all_points.part[point] != part_result[cycle_index][head_index]:
continue continue
point_pos = [Point(cur_all_points.pos[index].x - head_index * self.config.head_intv, point_pos = [Point(all_points.pos[point].x - head_index * self.config.head_intv,
cur_all_points.pos[index].y)] all_points.pos[point].y)]
cheby_distance, euler_distance = 0, 0 cheby_distance, euler_distance = 0, 0
for next_head in range(head_num): for next_head in range(head_num):
if assigned_point[next_head] == -1: if head_point[next_head] == -1:
continue continue
point_pos.append(Point(assigned_mount_point[next_head].x - next_head * head_num, point_pos.append(Point(assigned_point[next_head].x - next_head * head_num,
assigned_mount_point[next_head].y)) assigned_point[next_head].y))
point_pos = sorted(point_pos, key=lambda p: p.x) point_pos = sorted(point_pos, key=lambda p: p.x)
for mount_seq in range(len(point_pos) - 1): for mount_seq in range(len(point_pos) - 1):
@@ -211,22 +206,22 @@ class PathPlanOpt:
head_counter += 1 head_counter += 1
assigned_point[head_index] = all_points.step[point_index] step_index = cur_point_list[point_index]
assigned_mount_point[head_index] = all_points.pos[point_index] head_point[head_index] = all_points.step[step_index]
assigned_mount_angle[head_index] = all_points.angle[point_index] assigned_point[head_index] = all_points.pos[step_index]
cur_all_points.pop(point_index) cur_point_list.pop(point_index)
dist, head_seq = self.dynamic_programming_cycle_path(assigned_point, slot_result[cycle_index]) dist, head_seq = self.dynamic_programming_cycle_path(head_point, slot_result[cycle_index])
if min_dist is None or dist < min_dist: if dist < min_dist:
tmp_all_points = cur_all_points best_head_point, best_head_seq, best_point_list = head_point, head_seq, cur_point_list
tmp_assigned_point, tmp_assigned_head_seq = assigned_point, head_seq
min_dist = dist min_dist = dist
if pbar:
all_points = tmp_all_points pbar.update(1)
point_result.append(tmp_assigned_point) point_list = best_point_list
sequence_result.append(tmp_assigned_head_seq) point_result.append(best_head_point)
sequence_result.append(best_head_seq)
return point_result, sequence_result return point_result, sequence_result

View File

@@ -160,15 +160,19 @@ def evaluation(config: MachineConfig, part_data, step_data, opt_res: OptResult,
# <20><>ʼ<EFBFBD><CABC><EFBFBD>׸<EFBFBD><D7B8><EFBFBD><EFBFBD>ڵ<EFBFBD><DAB5><EFBFBD><EFBFBD><EFBFBD>װ<EFBFBD><D7B0><EFBFBD><EFBFBD>Ϣ # <20><>ʼ<EFBFBD><CABC><EFBFBD>׸<EFBFBD><D7B8><EFBFBD><EFBFBD>ڵ<EFBFBD><DAB5><EFBFBD><EFBFBD><EFBFBD>װ<EFBFBD><D7B0><EFBFBD><EFBFBD>Ϣ
nozzle_assigned = ['Empty' for _ in range(config.head_num)] nozzle_assigned = ['Empty' for _ in range(config.head_num)]
for head in range(config.head_num):
for cycle in range(len(opt_res.part)):
idx = opt_res.part[cycle][head]
if idx == -1:
continue
else:
nozzle_assigned[head] = part_data.loc[idx]['nz']
cur_layer = -1
for cycle_set, _ in enumerate(opt_res.part): for cycle_set, _ in enumerate(opt_res.part):
if opt_res.layer[cycle_set] != cur_layer:
cur_layer = opt_res.layer[cycle_set]
for head in range(config.head_num):
for cycle in range(len(opt_res.part)):
idx = opt_res.part[cycle][head]
if idx == -1 or opt_res.layer[cycle] != cur_layer:
break
else:
nozzle_assigned[head] = part_data.loc[idx]['nz']
floor_cycle, ceil_cycle = sum(opt_res.cycle[:cycle_set]), sum(opt_res.cycle[:(cycle_set + 1)]) floor_cycle, ceil_cycle = sum(opt_res.cycle[:cycle_set]), sum(opt_res.cycle[:(cycle_set + 1)])
for cycle in range(floor_cycle, ceil_cycle): for cycle in range(floor_cycle, ceil_cycle):
if sum(opt_res.part[cycle_set]) == -config.head_num: if sum(opt_res.part[cycle_set]) == -config.head_num:

View File

@@ -32,15 +32,17 @@ class TopBtmOpt(BaseOpt):
points_stat.loc[len(points_stat)] = [part, part_top_points[part], points - part_top_points[part], points] points_stat.loc[len(points_stat)] = [part, part_top_points[part], points - part_top_points[part], points]
for r, data in self.step_data.iterrows(): for r, data in self.step_data.iterrows():
rows[r] = True if data.part in top_part and data.part in btm_part and part_points[data.part] > 7 else False rows[r] = True if data.part in top_part and data.part in btm_part and part_points[data.part] >= 20 else False
dblayer_step_data = self.step_data[rows] dblayer_step_data = self.step_data[rows]
opt = self.optimizer(self.config, self.part_data, dblayer_step_data, self.feeder_data) opt = self.optimizer(self.config, self.part_data, dblayer_step_data, self.feeder_data)
opt.optimize() opt.optimize()
self.feeder_data = opt.feeder_data self.feeder_data = opt.feeder_data
for _, layer_step in self.step_data.groupby('layer'): for layer, layer_step in self.step_data.groupby('layer'):
opt = self.optimizer(self.config, self.part_data, layer_step, self.feeder_data) # if layer == 1:
# continue
opt = self.optimizer(self.config, self.part_data, layer_step, self.feeder_data, layer)
opt.optimize(hinter=hinter) opt.optimize(hinter=hinter)
self.result = self.result + opt.result self.result = self.result + opt.result
@@ -51,8 +53,8 @@ class TopBtmOpt(BaseOpt):
def main(): def main():
# 参数解析 # 参数解析
parser = argparse.ArgumentParser(description='assembly line optimizer implementation') parser = argparse.ArgumentParser(description='assembly line optimizer implementation')
# parser.add_argument('--filename', default='PCB-1.txt', type=str, help='pcb data') parser.add_argument('--filename', default='US2.659.1591-US7.820.48684-C2-G2-624T.txt', type=str, help='pcb data')
parser.add_argument('--filename', default='US2.259.0600-US7.820.51964-A1-B3-64T.txt', type=str, help='pcb data') # parser.add_argument('--filename', default='US2.259.0600-US7.820.51964-A1-B3-64T.txt', type=str, help='pcb data')
params = parser.parse_args() params = parser.parse_args()
# 结果输出显示所有行和列 # 结果输出显示所有行和列
@@ -66,7 +68,7 @@ def main():
# opt = HyperHeuristicOpt(2, part_data, step_data) # opt = HyperHeuristicOpt(2, part_data, step_data)
# opt.optimize() # opt.optimize()
# for machine_index, result in enumerate(opt.result): # for machine_index, result in enumerate(opt.result):
# print('-------- Machine: ' + str(machine_index) + '--------') # print('-------- Machine: ' +ddd str(machine_index) + '--------')
# evaluation(config, part_data, step_data, result, hinter=True) # 估算贴装用时 # evaluation(config, part_data, step_data, result, hinter=True) # 估算贴装用时
# === 单机 === # === 单机 ===