## 4 Dynamic Load Management of Datacenters Based on Forecasting  
### Dynamic Load Adjustment of Datacenters  
An imbalance between load and generation might lead to the failure of the normal operation of the power grid. Therefore, facing the special situation of renewable energy integrated into the grid, we selected datacenters as dynamic loads to maintain the basic stability of the smart grid. However, while maintaining stability, we also need to focus on the efficiency of the grid, which can be reflected by the power losses. In the scenario of multiple datacenters integrated into the smart grid, it will be difficult to solve the problem defined in Section 3. Furthermore, the Loss, as described in Section 3.4, is not an explicit function, which means that we cannot use linear or non-linear programming directly to solve this problem. Thus, a stochastic algorithm is proposed to implement an optimal load allocation strategy in order to obtain the minimum loss value. In computer science and operations research, the genetic algorithm (GA) is a metaheuristic inspired by the process of natural selection that belongs to the larger class of evolutionary algorithms (EA). Genetic algorithms are commonly used to generate high-quality solutions for optimization and search problems by relying on bio-inspired operators such as mutation, crossover and selection [58]. As one of the stochastic algorithms, a genetic algorithm is good at solving global optimization problems and is always used to solve practical problems. In this experiment, we adopt the main concept of the genetic algorithm and use the toolbox _'Deap'_, a novel evolutionary computation framework for rapid prototyping and testing of ideas to get an optimal load allocation strategy, to implement the entire algorithm. The steps of the dynamic load management algorithm can be presented as follows:  
1. randomly initialize the population
2. determine the fitness of the current population
3. repeat. * Select parents from the current population. In this paper, the tournament selection strategy is adopted, i.e., to select a certain number of individuals from the population each time. In our experiment, we selected three individuals and then choose the best one among the three to enter the child population each time. * Perform crossover operations on parents creating the population. In this paper, we adopted the two-point crossover strategy, which was helpful to create more new individuals. Two-point crossover refers to the random setting of two crossover points in the individual coding string and then the partial genes between the two crossover points will be exchanged. An example of a two-point crossover operation is shown as Figure 2, wherein the dotted lines represent the two crossover points. Figure 2: Two-point crossover operation. (**A**) and (**B**) are two randomly selected individuals, and A’ and B’ are the resultant individuals after the crossover operation. * Perform mutation operations of the current population. Here we adopt the gauss mutation strategy, wherein the mean is 0, the standard deviation is 1, and the independent probability for each attribute to be mutated is 0.1 to enter the child population. * Determine the fitness of the population until the best individual is good enough. 4. output the best individual of the final population as the result. When the iteration times of the evolution reach the maximum value, the individual with the maximum fitness obtained in the evolutionary process will be the output as the optimal solution. In this algorithm, we used vectors to represent the individual and the load capacity of each datacenter at every time interval was denoted as a gene. Then, the load capacity values of all datacenters in the grid at each time interval composed the individual (\(x_{1}\), \(x_{2}\)... ) and the dimension of the vector could be determined according to the number of added datacenters.