# Assembly Line Optimizer

This project called ALO is designed for PCB Assembly line optimization which contains the algorithm implementation of the author and other works. The algorithm provided by ALO is applicable to the optimization of the assembly process of linear-aligned surface mount machine (SMM), such as SM482, and the production lines they form. 
The built-in optimization results provided by Hanwha Corporation can also be analyzed through ALO.
The main algorithms were all designed and completed by the Assembly Process Optimization Research Group of the Institute of Intelligent Control and System, Harbin Institute of Technology. The implementation of the algorithms can be found in the papers in the [5 References] section.

## 1 File Structure

+ ***base_optimizer*** : *optimizer of single surface mounter*
    - ***optimizer_common.py*** : *basic common file for optimizer*
    - ***optimizer_interface.py*** : *interface for all base optimizer*
    - ***result_analysis.py*** : *result analysis of assembly process drawing and time calculation*
    - ***smt_aggregation.py*** : *aggregation algorithm*
    - ***smt_celldivision.py*** : *cell division algorithm*
    - ***smt_feederpriority.py*** : *feeder priority algorithm*
    - ***smt_hybridgenetic.py*** : *hybrid genetic algorithm*
    - ***smt_mathmodel.py*** : *math model solver*
    - ***smt_scanbased.py*** : *scan based algorithm*
    - ***smt_twophase.py*** : *two phase algorithm*
    - ***smt_route.py*** : *route schedule algorithm*
+ ***data*** : *pcb file directory* 
+ ***opt*** : *training and test data for estimator directory* 
+ ***model*** : *model parameter file* 
+ ***result*** : *optimization result file* 
+ ***dataloader.py*** :  *load pcb file from \*.txt*
+ ***estimator.py*** : *assembly time estimator including heuristic-based/neural-based/re-configuration-based/svr-based/metric-based estimator*
+ ***generator.py*** : *generate data for training the time estimator*
+ ***lineopt_genetic.py*** : *genetic algorithm*
+ ***lineopt_model.py*** : *math model*
+ ***lineopt_hypergenetic.py*** : *hyper-heuristic algorithm*
+ ***lineopt_reconfiguration.py*** : *reconfiguration algorithm*
+ ***optimizer.py*** : *main file*
+ ***ReadMe.md*** : *this file*

## 2 Package Requirement ##

+ tqdm
+ gurobipy (license requirement)
+ sklearn（scikit-learn）
+ torch（PyTorch）
+ joblib
+ numpy
+ pandas
+ matplotlib
+ openpyxl


## 3 File Form

### 3.1 Part Section
+ *part* : *part name* 
+ *fdr* : *feeder type*
+ *nz* : *nozzle type*
+ *fdn* : *upper limit of feeder*
+ *points* : *number of feeders in step list*

### 3.2 Step Section
+ *machine* : *assigned index of machine*
+ *x* : *x position*
+ *y* : *y position*
+ *r* : *angle*
+ *part* : *part name*
+ *fdr* : *feeder slot & part name*
+ *nz* : *anc hole & nozzle tpye*
+ *hd* : *head index*
+ *cy* : *cycle index*
+ *others are not used*

## 4 Parameter
+ *mode* ： *run mode - 0: read optimized result, 1: run optimization, 2: batch optimize all PCB files in \data directory*
+ *filename* : *PCB file (default in \data directory)*
+ *comp_register* : *whether auto-register components from step data when missing*
+ *machine_number* : *Number of machines in production line (set to 1 for single machine optimization)*
+ *machine_optimizer* : *single machine optimizer (options: cell-division, feeder-priority, hybrid-genetic, aggregation, genetic-scanning, mip-model, two-phase)*
+ *line_optimizer* : *line optimizer (options: hyper-heuristic, genetic, reconfiguration)*
+ *feeder_limit* :  *available feeders for auto-registration*
+ *save* : *wheter save optimization results*
+ *save_suffix* :  *suffix for saved results (used in batch optimization)*




## 5 Reference
### 5.1 SMM Optimizer
+ ***Aggregation Algorithm*** : ASHAYERI J, MA N, SOTIROV R. An aggregated optimization model for multihead SMD placements[J]. *Computers & Industrial Engineering*, 2011, 60(1): 99-105.
+ ***Cell Division Algorithm*** : LI Z, YU X, QIU J, et al. Cell division genetic algorithm for component allocation optimization in multi-functional placers[J]. *IEEE Transactions on Industrial Informatics*, 2022, 18(1): 559-570.
+ ***Math Model & Feeder Priority Algorithm*** : LU G, YU X, SUN H, et al. A Scan-Based Hierarchical Heuristic Optimization Algorithm for PCB Assembly Process[J]. *IEEE Transactions on Industrial Informatics*. 2024, 20(3): 3609-3618.
+ ***Hybrid Genetic Algorithm*** : GUO S, GENG F, TAKAHASHI K, et al. A MCVRP-based model for PCB assembly optimisation on the beam-type placement machine[J]. *International Journal of
Production Research*, 2018, 57(18): 5874-5891.
+ ***Scan-Based Algorithm*** : SUN D S, LEE T E, KIM K H. Component allocation and feeder arrangement for a dual-gantry multi-head surface mounting placement tool[J]. *International Journal of Production Economics*, 2005, 95(2): 245-264.
+ ***Two Phase Algorithm*** : LU G, LI Z, SUN H, et al. A Two-Phase PCBA Optimization with ILP Model and Heuristic for a Beam Head Placement Machine[J]. *IEEE Transactions on Industrial Informatics*, 2024, 20(12):13612-13621.
+ ***Route Schedule Algorithm*** : From all above



### 5.2 Line Optimizer
+ ***Genetic Line Algorithm*** : GUO S, TAKAHASHI K, MORIKAWA K, et al. An integrated allocation method for the PCB assembly line balancing problem with nozzle changes[J]. *International Journal of Advanced Manufacturing Technology*, 2012, 62(1): 351-369.
+ ***Math Model & Hyper-Heuristic Line algorithm*** : LU G, GAO H, LI Z, et al. Hyper-Heuristic Optimization Using Multifeature Fusion Estimator for PCB Assembly Lines with Linear-Aligned-Heads Surface Mounters[J]. *IEEE Transactions on Cybernetics*. DOI:10.1109/TCYB.2025.3556512.
+ ***Re-Configuration Line algorithm*** : TÓTH A, KNUUTILA T, NEVALAINEN O S. Reconfiguring flexible machine modules of a PCB assembly line[J]. *Production Engineering*, 2010, 4(1): 85-94.

### 5.3 Estimator
+ ***Neural Estimator*** : VAINIO F, MAIER M, KNUUTILA T, et al. Estimating printed circuit board assembly times using neural networks[J]. *International Journal of Production Research*,
2010, 48(8): 2201-2218.
+ ***Re-Configuration Estimator*** : TÓTH A, KNUUTILA T, NEVALAINEN O S. Reconfiguring flexible machine modules of a PCB assembly line[J]. *Production Engineering*, 2010, 4(1): 85-94.
+ ***SVR Estimator*** : LI D, CHEN S, CHIONG R, et al. Predicting the printed circuit board cycle time of surface-mount-technology production lines using a symbiotic organism searchbased support vector regression ensemble[J]. *International Journal of Production Research*, 2020, 59(23): 7246-7265.
+ ***Heuristic Estimator & Metric Estimator*** : No reference


## 6 Copyright
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so. The original algorithm concept is the work of the cited authors.