## 3 Energy Optimization of Intelligent Building by Using Niche Genetic Algorithm  
The model we proposed for intelligent building energy optimization by ensuring the security of IoT devices uses a niche genetic algorithm is shown in Figure 1. We started by defining control variables that directly relate to the energy efficiency and livability of intelligent buildings. The main components of these variables are new energy, which is simply another way of saying renewable energy sources, energy delivery temperature, which is the thermal energy distribution across the building for various purposes, and water supply temperature, which is simply another way of saying the temperature of the water provided for various purposes [31; 32]. On the basis of these defined variables, data is collected from various IoT devices, such as sensors, actuators, and control systems, and it is ensured that the data collected is correct, reliable, and related to the building's energy usage. After the data collection, an objective function is created that computes the energy consumption and IoT devices' security risk of intelligent buildings based on the control parameters. The objective function is built in a way that takes into account the tradeoffs between various levels of energy consumption and lifestyle comfort. The solution space is then expressed in a fashion that the genetic algorithm can work with. This entails encoding the control parameters into a real-valued string that corresponds to the appropriate chromosomal format. The initial population of potential solutions is created to represent IoT devices' security configuration and various sets of control parameter values, such as the integration of renewable energy, optimization of thermal energy distribution, control of water supply temperature, smart heating, ventilation, and air conditioning (HVAC), temperature optimization of energy delivery, and energy monitoring and real-time feedback. The fitness of each solution in the entire population is assessed on the basis of the defined objective function. The fitness value, which simply indicates how well each solution performs in terms of energy consumption reduction and security enhancement, is the output of the fitness evaluation [33].  
The niche technique is employed to promote population variety. This assists in preserving an equilibrium between the two activities and prevents solutions from converging prematurely to local optima. Crossover and mutation operations are applied to the solutions that are chosen as having a greater fitness value. Via the use of the objective function,  
Figure 1: Block diagram of intelligent building optimization.  
the fitness of the recently produced offspring is assessed. This stage makes sure that the energy consumption of the new solutions is accurately calculated. By keeping a specific portion of the finest ideas from the previous generation, elitism is introduced. This makes sure that effective solutions are kept and do not disappear during the process of evolution. The next generation of the population is generated by combining parent solutions, offspring solutions, and elite solutions. Convergence criteria, such as a maximum number of generations or a suitable amount of energy consumption drop are selected to stop the algorithm on a satisfactory solution. The optimal option with the greatest potential for energy savings is found by analyzing the final population of solutions [34].