## 3 Construction Time-Cost Dynamic Optimization
### Genetic Algorithm  
The genetic algorithm simulates the evolution process of genetic variation of biological chromosomes, reflecting the rule of survival of the fittest [21]. Through selection, crossover, variation and other genetic processes, individuals who adapt to the genetic environment are retained to continue inheritance, and those who cannot adapt are eliminated. After screening, the optimal individuals are gradually propagated to the next generation. Repeat the above genetic steps until the termination conditions are met, and find the optimal answer globally. The steps for solving a genetic algorithm based on MATLAB's programming are as follows:  
(1) Determine variables and parameters. The time of each work determines the total cost of the project and is a decision variable that affects the target value. Project parameters include logical relationships, normal time, ultimate time, normal cost, and ultimate cost. Genetic parameters include individual coding string length L, population size P, iteration frequency G, crossover probability P\({}_{c}\), and mutation probability P\({}_{m}\). This project takes the  
\begin{table}
\begin{tabular}{c c c} \hline \hline
**Work Code** & **Limit Time/Day** & **Direct Cost Rate/Yuan Per Day** \\ \hline GZ & 28 & 9300 \\ GL & 12 & 2700 \\ WT & 70 & 3900 \\ ZH & 70 & 5200 \\ \hline \hline \end{tabular} Annotation: GZ represents retaining cost-in-place pile, GL represents crown beam, WT represents excavation, ZH represents foundation pit support.  
\end{table}
Table 1: Limit time and direct cost rate.  
Figure 1: The initial network plan.  
number of jobs as the string length, i.e., L = 27. P, G, P\({}_{\rm C}\), and P\({}_{\rm m}\) are 400, 1200, 0.5, and 0.0003, respectively.  
(2) Parameter coding. In order to facilitate genetic algorithm solving, the actual problem is transformed into a problem represented by parameters. There are 27 works involved in the construction of the foundation pits in this study, with a large capacity. To simplify the encoding and decoding steps, real number encoding is used. Each chromosome has 27 genes, representing 27 works. The attributes of the genes include work name, time, earliest start time of work, and previous work. The chromosome composition is shown in Figure 2.  
(3) Initialize population. This study randomly generates an initial population that satisfies constraint conditions and basic assumptions as the initial solution of the problem. If the population size is too large, it will result in individual optimal solutions not dominating the evolutionary direction of all solution. If the population size is too small, it will cause the genetic algorithm to converge prematurely, leading to inaccurate solution results. This study randomly initializes the population with a population size of 400.  
(4) Fitness evaluation. Fitness reflects the degree to which individuals approach the objective function. In this study, the objective function shown in Equation (6) is the fitness function to calculate the fitness value. The smaller the fitness value, the better the individual, the greater their chances of reproduction, and the greater the probability of being selected for the next genetic operation  
(5) Genetic manipulation. Through selection, crossover, and mutation operations, the reproductive function of organisms is simulated, new individuals are generated, and better populations are formed. This study uses the Monte Carlo selection method and uniform crossover method to randomly select a node for variation of construction status. If the result is satisfactory, the optimal solution is output. Otherwise, steps (4)-(5) will be repeated until the result is satisfactory.