## 5 Adaptive Core Distribution Optimization Algorithm
### ACTR Algorithm
```
1:An initial solution \(S_{init}\) generated by ACTR;
2:Optimized search solution \(P_{ubest}\)
3:\(P_{init}\coloneqq S_{init}\)
4:max_iterations :=k
5:iteration_count := 0
6:\(P_{ubest}\coloneqq P_{init}\);
7:while iteration_count < max_iterations do
8:\(P_{temp}\coloneqq\mathbf{SDW}(P_{init})\); //Update using SDW based on current solution
9:\(P_{init}\coloneqq P_{temp}\);
10: Perform a forward search with searching order sliding clockwise along the \(y\)-axis;
11: Perform a reverse search with searching order sliding anticlockwise along the \(x\)-axis;
12:if Utility(\(P_{init}\)) < Utility(\(P_{ubest}\)) then //Update only if the new configuration is better
13:\(P_{ubest}\coloneqq P_{init}\); //Update the best solution
14:endif
15:iteration_count := iteration_count + 1;
16:endwhile
17:return\(P_{ubest}\);
```  
**Algorithm 2** ACTR-URC Procedure. Analyzing the time complexity of the above procedures, it can be concluded that the time complexity of the derived algorithm mainly depends on the condition of loop termination and the time complexity of the SDW procedure. Given that the SDW procedure operates with a time complexity of \(O(m\times n)\), where \(m\) and \(n\) are the dimensions of the physical array \(H\), and considering that the main loop executes for a maximum of \(k\) iterations, the overall time complexity of the ACTR-URC procedure can be expressed as \(O(k\times m\times n)\). This reflects the cumulative cost of performing the SDW procedure and the subsequent forward and reverse searches within each iteration. Therefore, if \(k\) is kept within reasonable limits, the algorithm efficiently balances exploration and optimization, making it suitable for practical applications in managing configurations of faulty processing elements. In summary, the derived time complexity of the algorithm is \(O(k\times m\times n)\), indicating linear scalability with respect to both the number of iterations and the size of the input array. The SDW procedure is designed to efficiently address the issue of fault core distribution in a physical topology. The procedure aims to input a physical topology H of size \(m\times n\), including faulty cores D, and ultimately outputs a target array of size \(p\times q\) after optimization. The general steps of the procedure are as follows:  
**Step 1**: Initialize an empty target array \(T_{best}\) to store the optimal configuration and precompute the positions of all non-defective PEs in the physical array \(H\). **Step 2**: Define a sliding window \(F\) of size \(p\times q\) at the top-left corner of the physical array \(H\). **Step 3**: Traverse each possible position of the physical array \(H\) by moving the sliding window \(F\). **Step 4**: For each window position, identify faulty core PEs and replace them with the nearest non-defective core PEs using the precomputed positions. **Step 5**: After replacing the defective PEs, calculate the utility value \(u(F)\) based on the current configuration of the window and update \(T_{best}\) if the current utility exceeds the previous best. **Step 6**: If the target array is square, rotate the window and repeat the traversal to explore potentially better configurations. **Step 7**: Return the optimized \(T_{best}\) as the final result. The pseudo code for this search procedure is shown below (Algorithm 3).