## 3 Resource Scheduling Process Based on a Genetic Algorithm
### Detailed Design of the Genetic Algorithm  
Due to the applicability of genetic algorithms to solving large-scale optimization problems, this article adopts genetic algorithms to solve the above problems. In this paper, the decision variable is the allocation matrix \(T\) in the E-CARGO model, which represents an allocation scheme. In our method, individuals are selected by calculating comprehensive satisfaction. For a population, the higher the fitness, the greater the likelihood of being  
Figure 3: Flowchart of a genetic algorithm for solving the distribution matrix. selected. Equation (19) is used as a fitness function, while the roulette wheel algorithm is used to select contemporary populations. In order to implement genetic algorithms, the population needs to be initialized first, and the allocation scheme needs to be encoded. Based on Equations (9)-(11), we use natural number coding to divide agents into numbers. Obviously, a feasible allocation scheme needs to meet Equation (11). Resource groups must satisfy both the constraint of total allocation and the constraint of unique allocation. The gene coding in this paper is expressed using Equation (20):  
\[g\ =\ \left\{g_{1}\ =\ \left[h_{11},h_{12}\ldots,h_{1I_{1}}\right],g_{1}\ =\ \left[h_{21},h_{22}\ldots,h_{2I_{2}}\right],\ldots,g_{m}\ =\ \left[h_{m1},h_{m2}\ldots,h_{ml_{m}}\right]\right\}, \tag{20}\]  
where the assignment matrix of each task \(r_{j}\) is represented by \(g_{j}\) (as there are \(m\) tasks, the value of \(j\) in \(g_{j}\) is 1-\(m\)); \(l_{j}\) = \(L[j]\) is the resource group demand vector, where \(l_{j}\) indicates that the \(j\)th task requires \(l_{j}\) resources; and \(h_{jl}\) indicates the \(l\)th resource group allocated by task \(r_{j}\). Then, \(g\) can be represented by an array of natural numbers with length \(L_{m}\), as shown in Equation (21):  
\[g\ =\ \left\{h_{11},h_{12}\ldots,h_{1I_{1}},h_{21},h_{22}\ldots,h_{2I_{2}}, \ldots,h_{m1},h_{m2}\ldots,h_{ml_{m}}\right\}, \tag{21}\]  
where \(h\in\left\{1,2,\ldots,n\right\}\) is the specific resource group number. According to the uniqueness of the resource group assigned to the task, the values of \(h\) in \(g\) do not duplicate each other. Assuming a total of \(s\) chromosomes \(G\ =\ \left\{g_{1},g_{2},\ldots,g_{S}\right\}\), a crossover algorithm and mutation algorithm need to be designed for applying the genetic algorithm. Definition 10: Define the set used as \(Hs\), assuming that any gene \(g_{S}\) is an ordered set of \(h\). Assuming that \(n\) is the set of all natural numbers 1-\(n\), \(Hs\) is the used number set of \(g_{S}\), and \(NH\)s is the unused number set. \(Hs1\), \(Hs2\), \(NH\)s1, and \(NH\)s2 can be obtained by any two genes: \(g_{SI}\) and \(g_{S2}\). The idea of the cross operation is to exchange some genes between the two chromosomes; however, they cannot be exchanged arbitrarily, based on Constraints (10) and (11). Therefore, the following cross operation is adopted in this paper. Taking 2 as the number of steps, we select the chromosome to be crossed with the probability \(Pc\) and randomly select the gene to be crossed in the chromosome. We take the gene sequence corresponding to the allocated resource group corresponding to each task \(r_{j}\) as a gene segment and randomly generate the gene segment \(j\) to be crossed. Then, the gene segments corresponding to the two chromosomes to be crossed are \(g_{jl}\) and \(g_{j2}\). The uncrossed fragment of \(g_{SI}\) is \(g_{j1}\ =\ \left\{h_{j11},h_{j12},\ldots,h_{j1I_{j}}\right\}\), and the uncrossed fragment of \(g_{S2}\) is \(g_{j2}\ =\ \left\{h_{j21},h_{j22},\ldots,h_{j2I_{j}}\right\}\). The crossover procedure is carried out as follows:  
1. Traverse \(x=1\) for the allele crossover. 2. If \(x>l_{j}\), the crossing ends; otherwise, go to step 3. 3. If \(h_{j2x}\in NH\)s1, this indicates that \(s1\) does not use this number, and the \(x\) position of \(s1\) is directly assigned as \(h_{j2x}\).