# An Improved Adaptive Genetic Algorithm for Two-Dimensional Rectangular Packing Problem
## 3 Improved Adaptive Genetic Algorithm
### Termination Rules  
The improved adaptive genetic algorithm we proposed shows a convergence trend in the process of searching and optimizing the solution space. For the iterative optimization calculation of 2 DRP problem, there are the following termination rules:  
(1) After the iterative calculation reaches a certain level, the optimal fitness value has no obvious change in the continuous \(T\) iterations, and the calculation can be stopped in advance. For example, the \(T\) is set to 150 in this paper, which means the calculation is terminated if the optimal fitness value does not change through 150 continuous iterations;  
(2) Set the desired packing rate in advance. In the process of calculating, the pre-set filling rate is reached, and the calculation can be terminated early. For the expected filling  
Figure 5: Exchange mutation and two-point basic position mutation (\(n=8,r_{1}=2,r_{2}=6\), \(r_{3}=11,r_{4}=15\)).  
rate, if the theoretical filling rate is known before the experiment, e.g., the theoretical filling rate of the \(C\) benchmark instances proposed by [PERSON] is 100% [18], it can be set to the theoretical value; otherwise, the user's expected value can be set according to actual needs;  
(3) Set the maximum number of iterations in advance. If the algorithm does not terminate prematurely, when the genetic algebra reaches the maximum number of iterations, the calculation is terminated, and the packing solution and filling rate are obtained.  
The combination of the above three termination rules can not only fully optimize within the maximum number of iterations but also terminate the iterative optimization of the algorithm early when the expected value or fitness value is reached and there is no obvious change, which is beneficial to reduce the calculation time of the algorithm. When the iterative optimization of the algorithm is terminated, the packing solution corresponding to the chromosome with the largest fitness value is the optimal packing solution, and the corresponding filling rate is calculated.  
```
\(\text{HAMA}(t,P,PS)\):
1 Initialize the parameter \(P_{m1},P_{m2},c,\lambda\)
2 Copy population \(P^{\prime}\) from the population \(P\) with \(PS\) individuals
3 Compute \(P_{m}(t)\) with formula (5)
4 Compute \(f_{\text{max}},f_{\text{arg}}\) for \(P\)
5 for\(i\)in\(\text{range}(PS)\):
6 Get parent \(E_{1}\) from \(P\) and compute its fitness \(f\)
7 Compute \(P_{m}(f)\) with formula (6) and \(P_{m}\) with formula (7)
8 Generate a random number \(r\) between \([0,1]\) with rand() function
9 if\(r<P_{m}\):
10 Generate different random numbers \(r_{1},r_{2}\) within \([1,n]\) and \(r_{3},r_{4}\) within \([n+1,2n]\)
11 Get mutated child using the same method of Figure 5
12 Put mutated child with Heuristic Packing Procedure
13 Update \(P^{\prime}[i]\) using mutated child
14 Add \(P^{\prime}\) to \(P\), Sort them in decreasing order of fitness
15 Delete \(PS\) individuals with small fitness and get mutated population \(P\)
16 return mutated population \(P\)
```  
**Algorithm 3** Hybrid adaptive mutation algorithm