## 4 Application of a Multi-Adaptive Genetic Algorithm to the Problem of Human-Robot Cooperation
### Designing a Multi-Adaptive Genetic Algorithm
#### 4.2.1 Chromosome Structure  
'N' is the number of light bulbs that need to be assembled. The number of genes in a chromosome is twice the number of bulbs to be assembled, which is \(2n\). Each gene corresponds to a time slot of 30 s, which is the completion time of assembling a single light bulb. For instance, if we need to assemble 100 light bulbs, the chromosome consists of 200 genes, each of which corresponds to a 30 s time slot. The first half of the chromosome indicates whether the worker is stationary or moving. The value '0' means that the worker is stationary at the Home position, while the value '1' means that the worker is moving to either Position 1 (socket providing) or Position 2 (bulb providing). The second half of the chromosome represents the direction of the worker's movement. The value '1' corresponds to the worker moving to Position 1, and the value '0' corresponds to the worker moving to Position 2. The first gene in the chromosome decides whether the worker moves from the Home position or not, and the (1 + \(n\))th gene determines the direction of movement at the beginning of the first 30 s. Therefore, the pair of genes (\(i\))th and (\(i+n\))th determines  
Figure 4: Genetic algorithm diagram. whether the worker moves and which direction to move at the beginning of the (30 \(\times\)\(i\))th seconds. Chromosomes are paired as shown in Figure 5.  
The evaluation of the optimization criteria is based on the following parameters:  
Es: this parameter assesses the level of available sockets on the pallet;  
Eb: this parameter evaluates the level of available bulbs on the conveyor belt;  
M: this parameter represents the optimal rating for the number of worker movements. The formula for determining the Es index is:  
\[\text{Es}=\sum_{k=1}^{n}s_{k} \tag{3}\]  
For each gene index \(k\) (\(1\leq k\leq n\)) on the chromosome, the value \(s_{k}\) is calculated as follows:  
If the left gene at position \(k\) has a value of 0 (the worker is not moving), or both left genes at positions \(k\) have a value of 1 and the corresponding right gene at position \(k+n\) has a value of 0 (the worker is moving and goes to Position 2 to provide bulbs), then \(s_{k}\) is set to 0. If the left gene at position \(k\) and the corresponding right gene at position \(k+n\) both have a value of 1 (the worker moves to provide sockets), then \(s_{k}\) is calculated. \[s_{k}=\left\{ \begin{array}{ll}r_{s},&r_{s}\leq S\\ 1/r_{s}>S\end{array} \right. \tag{4}\]  
The time interval between the worker's movement to Position 1 (to provide sockets) at the (\(k-1\))th and \(k\)th times is denoted by \(r_{s}\). The condition for avoiding a lack of sockets on the pallet is that the interval time between these two moves \(r_{s}\) cannot be less than the time interval it takes the robot to assemble a number of bulbs equal to the maximum number of sockets on the pallet \(S\). For instance, if the pallet can hold up to nine sockets, then \(S=9\). Therefore, \(r_{s}\) is equal to the distance between the two genes responsible for moving to the pallet. If there are more than nine genes responsible for moving to the pallet, the robot is considered to be in a situation of material shortage and stops working. In this case, the \(s_{k}\) parameter decreases and receives the inverse value of the \(r_{s}\) parameter. The index for assessing whether there are enough bulbs on the conveyor belt (Eb) has the same role as Es, and the formula for determining it is similar. The formula for determining the Eb parameter is:  
\[\text{Eb}=\sum_{k=1}^{n}b_{k} \tag{5}\]  
where:  
\[b_{k}=\left\{ \begin{array}{ll}r_{b},&r_{b}\leq B\\ 1/r_{b},&r_{b}>B\end{array} \right. \tag{6}\]  
The time it takes for the worker to move between the (\(k-1\))th and \(k\)th positions for providing bulbs is denoted as \(r_{b}\). The maximum number of bulbs on the conveyor belt is \(B\), and the value of \(r_{b}\) is determined in a similar manner to \(r_{s}\).