## 4 Two-Stage Algorithm Combining Genetic Algorithm and Quasi-Physical Approach
### Layout Task
#### 4.3.2 Algorithm for the Layout Task
If they take as arguments the orientations of the components, a torque is applied. The forces and torques applied to a component \(i\) are employed to achieve the following:  
* Minimize an objective function: force \(\mathbf{F}_{i}^{objective}\) and torque \(\mathbf{T}_{i}^{objective}\);
* Solve for the overlapping constraints between components \(i\) and \(j\): force \(\mathbf{F}_{ij}^{overlap}\) and torque \(\mathbf{T}_{ij}^{overlap}\);
* Solve for the overlapping constraints between component \(i\) and an exclusion zone (EZ): force \(\mathbf{F}_{i/EZ}^{overlap}\) and torque \(\mathbf{T}_{i/EZ}^{overlap}\);
* Solve for the overlapping constraints between component \(i\) and the container: force \(\mathbf{F}_{i}^{container}\) and torque \(\mathbf{T}_{i}^{container}\);
* Solve for the functional constraints between two components \(i\) and \(j\): force \(\mathbf{F}_{i}^{functional}\) and torque \(\mathbf{T}_{i}^{functional}\);
* Solve for the balancing constraint: force \(\mathbf{F}_{i}^{CG}\) (CG stands for center of gravity);
* Solve for the angle of inertia constraint: force \(\mathbf{F}_{i}^{AI}\) and torque \(\mathbf{T}_{i}^{AI}\);
* More generally, solve for any constraint function: force \(\mathbf{F}_{i}^{constraint}\) and torque \(\mathbf{T}_{i}^{constraint}\). Generally speaking, any force or torque can be added to the VFS in order to address additional constraints or objective functions. This makes the proposed algorithm very generic to other layout problems. The forces and torques of the virtual-force system are detailed and formulated as follows (for a component \(i\)):  
* The overlapping constraint force and torque between two components: If two components \(i\) and \(j\) are overlapping each other, repulsive forces \(\mathbf{F}_{ij}^{overlap}\) and \(\mathbf{F}_{ji}^{overlap}\) are applied to each of them, as illustrated in Figures 4 and 5. The overlap force is expressed as  
\[\mathbf{F}_{ij}^{overlap}= \begin{cases}-\dfrac{\mathbf{p}_{i,j}^{c}-\mathbf{p }_{j,i}^{c}}{\|\mathbf{p}_{i,j}^{c}-\mathbf{p}_{j,i}^{c}\|+\epsilon}v_{max}- \mathbf{v}_{i}&\text{if }\Delta S_{ij}(\mathbf{p}_{i,j}^{c},\mathbf{p}_{i,j}^{c}) \
eq 0,\\ \mathbf{0}&\text{otherwise}.\end{cases}  \tag{35}\]  
where \(v_{max}\) is a hyperparameter corresponding to the maximum value of the norm of the speed vector, \(\epsilon\) ensures numerical stability and \(\mathbf{0}=(0,0)\) is the null vector. \(\Delta S_{ij}\) is the area of intersection between components \(i\) and \(j\). Moreover, similar to [127], additional torques are applied to non-circular components in order to solve the overlapping constraint, as illustrated in Figure 4.  
Figure 4: Definition of the overlapping forces and torques. The overlapping forces are initially applied at the \(O_{int}\) point, which corresponds to the geometrical center of the polygon of intersection between the two components. Then, the resulting torque applied at the point \(O_{i}\) is given by \[\mathbf{T}^{overlap}_{ij}=\mathbf{O_{i}O_{int}}\wedge\mathbf{F}^{overlap}_{ij}\] (36) where \(\mathbf{O_{i}O_{int}}\) is the vector from \(O_{i}\) to \(O_{int}\) and the symbol \(\wedge\) stands for the vector product. * The overlapping constraint force and torque between a component and an exclusion zone: If a component is overlapping an exclusion zone, a repulsive force \(\mathbf{F}^{overlap}_{i/EZ}\) is applied to the component, as illustrated in Figure 5. As the exclusion zone can be seen as a fixed component, the corresponding force and torque expressions are similar to the previous overlapping forces and torques between the two components and written with Equations (35) and (36). * The overlapping constraint force and torque between a component and the container: If a component is not fully overlapping the container, an attractive force \(\mathbf{F}^{container}_{i}\) is applied to the component, as illustrated in Figure 5. The container force is expressed as \[\mathbf{F}^{container}_{i}=