## 3 Two-Individual Based Master-Apprentice Evolutionary Algorithm
### Encoding Scheme Based on Assembly Structure
#### 3.2.2 Encoding Scheme Based on Operation Sequence Constraint Matrix  
Although the assembly level-based encoding method ensures the feasibility of the OS encoding, it has certain limitations. For instance, consider product A, as illustrated in Figure 5: there is no inherent assembly sequence constraint between operation 4 and operation 2. However, under the assembly level-based encoding method, these two operations are assigned to different levels, resulting in the lower-level operation 4 always being processed before the higher-level operation 2. This demonstrates that such an encoding method introduces unnecessary sequential constraints between operations, thereby compromising the completeness of the initial solution space.  
The operation sequence constraint matrix is a real-valued matrix designed to document the processing and assembly precedence relationships among the various operations of a product. For product A, illustrated in Figure 5, the corresponding operation sequence constraint matrix is shown in Table 2. In this matrix, each row represents an operation, while each column sequentially records the identifiers of all directly preceding operations for that particular operation. In this context, \"direct predecessors\" refer to operations with an immediate dependency relationship within the product assembly structure. For instance, considering operation 3, while operations 1, 2, 4, and 5 all serve as predecessor operations, only the adjacent operations 2 and 5 qualify as direct predecessors due to their immediate dependency linkage. It is evident that the status of an operation's direct predecessors determines whether the operation can proceed immediately, a condition commonly referred to as operation readiness.  
This section presents an encoding scheme based on the operation sequence constraint matrix, with the specific process detailed as follows:  
\begin{table}
\begin{tabular}{c c c} \hline \hline
**Operations** & \multicolumn{2}{c}{**Directly Preceding Operations**} \\ \hline
2 & 1 & 0 \\
3 & 2 & 5 \\
5 & 4 & 0 \\
6 & 0 & 0 \\
7 & 3 & 6 \\ \hline \hline \end{tabular}
\end{table}
Table 2: Operation sequence constraint matrix for product A.  
Figure 5: Assembly level of the operations in product A.  
Step 1: Construct an empty set \(Q\) and an empty array \(P\). \(Q\) is utilized to store all currently schedulable operations, while \(P\) is employed to store operations that have already been scheduled.  
Step 2: Traverse all rows of the operation sequence constraint matrix: if a row contains exactly one non-zero element, this indicates that the operation corresponding to that row has no directly preceding operations or that all directly preceding operations have been completed. This operation is then added to the set \(Q\) as a currently schedulable operation.  
Step 3: Randomly select one operation from \(Q\) as the currently scheduled operation, denoted as \(P(1)\). Set all corresponding elements in the matrix for that operation to zero, indicating that the operation has been scheduled.  
Step 4: Traverse all rows of the matrix: if there exists a row that is not entirely composed of zeros, return to Step 1 and repeat the above steps, sequentially recording the scheduled operations in \(P\) until all elements of the matrix are zero. At this point, \(P=[P(1),P(2),P(3),\ldots,P(n)]\) represents a valid operation sequence encoding.