Energy optimization in smart urban buildings using bio-inspired ant colony optimization

In this paper, a smart home energy management system is proposed to improve the efficiency of the electricity infrastructure of residential buildings. To solve the scheduling problem of a smart building, we propose bacterial foraging ant colony optimization (HB-ACO). The primary objective of scheduling is to shift load from on-peak hours to off-peak hours to reduce electricity cost and peak-to-average ratio. A comparison of these algorithms is also presented in terms of performance parameters, electricity cost, reduction of PAR, and user comfort in terms of waiting time. The proposed techniques are evaluated using two pricing schemes: (1) time of use and (2) critical peak pricing. Moreover, coordination among home appliances is presented for real-time scheduling. We represent this as a knapsack problem and solve it through ant colony optimization algorithm. The HB-ACO shows better performance than ACO and BFA in reducing electricity cost, PAR, and increased user comfort, which is evident from the simulation results.


Introduction
The non-commercial sector consumes a large scale of world electricity globally. As the population increases, the electricity demand will increase. Research shows that the residential sector consumes a significant portion of world electricity, about 30-40% (Gul and Patidar 2015). This is challenging to reduce the consumption of electricity. The existing grid has a lot of challenges like maintenance, reliability, and system losses. Researchers have improved the current technology of the conventional grid, thus becoming intelligent and dynamic. Smart grid and end-user can communicate with improved reliability, efficiency, and cost-effectiveness.
The primary strategy in the smart grid is demand-side management (DSM), which maintains grid stability by developing flexible and diverse systems. Initially, the utility companies used the early load shifting technique via DSM's direct load control (Abdollahi et al. 2012). The utility companies would disconnect a specific load of consumers at short notice. This system is not frequent and unsuitable for buildings containing many appliances with relatively low power consumption. The literature's most frequent technique for load shifting management is demand response (DR) (Davito et al. 2010). In the demand response strategy, the power consumption is regulated using the current pricing scheme, i.e., when the price per unit is high, the utilities use reduced power and vice versa. This technique reduces monetary cost, stress on the grid and as well as reduces the peak-to-average ratio (Gelazanskas and Gamage 2014). One major drawback of the DSM is its challenging implementation because it requires a generic system to achieve objectives independently.
Different techniques and architectures are used to implement DR in smart homes. The number of appliances is multiple in smart homes to minimize electricity cost and schedule home appliances in a balance away to reduce stress on the grid. Article (Khan et al. 2020) uses blockchain technology for smart grid security. Researchers in Han and Lim (2010), Costanzo et al. (2012), Tahir et al. (2019), Shafie-Khah and Siano (2017), Jahn et al. (2010), Killian et al. (2018), Husen et al. (2021), Chen et al. (2017), Li et al. (2015) and Anvari-Moghaddam et al. (2015) designed different architecture and algorithms for home energy management systems (HEMSs) using different pricing approaches, i.e., CPP, TOU, RTP, and renewable and sustainable energy, to reduce electricity cost and peak-to-average ratio during the day when the electricity price is high. Some nature-inspired techniques are also used to solve the load shifting problem.
Nature is a source of inspiration from the past few decades, which develop a searching algorithm to solve a complex engineering problem. These heuristic algorithms give near-optimal solutions to a specific problem. Khalid et al. (2018) and Dagdougui et al. (2020) used different bio-inspired algorithms; these algorithms provide search space, and from that search space, one with an optimal solution is used for scheduling various home appliances. There are many bio-inspired algorithms used for scheduling home appliances. Authors in Rahim et al. (2018a) designed a home energy management system, HEM, using two heuristic algorithms such as harmony search algorithm (HSA) and the bacterial foraging optimization algorithm (BFA). Based on HSA and BFA, the authors proposed a hybrid algorithm called hybrid bacterial harmony (HBH) algorithm. Authors in Khalid et al. (2018) proposed a HEMS (home energy management system) for scheduling different home appliances on the day ahead and in real time to reduce electricity cost, peak-to-average ratio, and user discomfort. The authors used a genetic algorithm (GA) and bacterial foraging optimization algorithm (BFA) and designed an HBG model. Authors in Ahmad et al. (2017) proposed a hybrid GA-PSO (HGPO) algorithm using genetic algorithm (GA), binary particle swarm optimization algorithm (BPSO), bacterial foraging optimization (BFO). Authors in Rahim et al. (2016) proposed architecture for DSM and evaluated the performance of energy management controller using genetic algorithm (GA), binary particle swarm optimization (BPSO), and ant colony optimization algorithm (ACO). Authors in Naz et al. (2018) proposed a hybrid technique HGWDE technique to schedule home appliances, using enhanced differential evolution (EDC) and gray wolf optimization (GWO) inspired by the hunting and leadership nature of wolves.
Irregular utilization of electricity increases the load on utility. Thus, a different electricity generation is required at some specific hours to overcome electricity demand, which increases PAR and electricity cost at peak hours. This extra power generation usually occurs from fusel fuel, which emits toxic gases harmful to the environment. The increasing load demand in the residential area and irregular electricity load profile has encouraged us to propose an efficient home energy management system (HEMS) to shift load from on-peak hours to off-peak hours in a balanced way.
The contribution of the paper is as follows: For appliance scheduling to shift load from on-peak hours to off-peak hours, we proposed a hybrid algorithm (HB-ACO) containing both ant colony optimization algorithm and bacterial foraging optimization algorithm properties. The proposed algorithm improves search efficiency as compared to BFA and ACO.
We consider real-time scheduling a binary knapsack problem when a user switches off a particular load. The remaining time of appliance is allocated to high-priority appliance(s) by rescheduling to reduce waiting time of appliance and solve this knapsack problem using ACO algorithm.
2 Literature review Smart home energy management systems (SHEM) efficiently monitor and control electricity storage, generation, and consumption (Ullah et al. 2019). Models are discussed in this section, and a short overview is discussed in Table 1.
Authors in Han and Lim (2010) proposed a smart home energy management system (SHEMS), which is based on 802.15.4 standard and ZigBee called ''ZigBee Sensor Network.'' The proposed system divides and assigns different home network tasks to appropriate components. It can sense various physical devices and control various home appliances. The authors also proposed a new routing protocol, DMPR, to improve the performance of the Zig-Bee sensor Network. Different sensors, video cameras, and actuators are used in this system to gain data from physical objects and humans, which is a very high cost. It creates privacy issues, and maintenance of such a system is also an issue (Costanzo et al. 2012). The disadvantage of this system is that it will create another peak-to-average ratio when all the load is shifted simultaneously. Authors in Tahir et al. (2019) proposed a SHEMS to control home appliance, battery storage, distributed generation using approximate dynamic programming (ADR), and temporal difference learning; an approach applied for grid-level storage. Authors in Shafie-Khah and Siano (2017) proposed a stochastic model for home energy management (HEM) by considering the uncertainty of availability of EVs (electric vehicles) and small-scale renewable energy generation to reduce electricity cost with reasonable user satisfaction. In this model, dissatisfaction occurs due to discharging of batteries. Authors in Jahn et al. (2010) designed a middleware framework called Hydra, which provides communication to smart devices on P2P connection. This framework provides real-time data of smart devices collected through smart meter plugs for monitoring and analysis. Mobile application is working on the top of the middleware framework, which shows which appliance consumes how much energy. The object is recognized in the image recognition server. Every appliance is an object ID and position. This system is highly cost and contains security and management issues. Authors in Killian et al. (2018) propose mixed-integer quadratic programming model predictive control (MPC), which has both thermal and electrical key qualities; the proposed model optimally manages PEV, thermal storage, and battery storage. Unsupervised occupancy prediction decreases cost due to user thermal comfort constraints. There is no coordination between renewable and sustainable energy. Authors in Husen et al. (2021) design hardware for SHEMS with communication and sensing capability and machine learning algorithm to detect human activities in a smart home to reduce electricity cost. This system will send consumers the weather information to better manage their home appliances. However, user comfort is ignored in this model. Authors in Chen et al. (2017) proposed a humancentric model for energy management in a smart home at the butler level. The model senses data from physical and cyberspace to find the pattern of power usage and know the behaviors of human beings. Authors in Li et al. (2015) proposed a multi-agent model for smart home energy management for efficient energy use. It communicates with an energy source and smart devices in the smart home. Smart appliances are multiple agents, and an optimization algorithm is used to make agents. Authors in Anvari-Moghaddam et al. (2015) proposed a multi-objective MINLP-based algorithm that schedules different tasks for optimal energy use in smart homes. Authors in Khalid et al. (2018) used meta-heuristic algorithms BFA and HAS proposed HEMS and a hybrid bacterial harmony algorithm (HBH). These algorithms provide search space, and the optimal one is selected for scheduling to reduce electricity cost, PAR, and user comfort. Dynamic programming is used for the coordination between home appliances. However, a trade-off exists between user comfort and EC. In article (Rahim et al. 2016), the authors designed an architecture for demand-side management. They evaluated the performance of the home energy management controller using genetic algorithm GA, binary particle swarm optimization (BPSO), and ant colony optimization (ACO) algorithm, using time of use (TOU) and inclined block rate (IBR) tariff rate. Researchers in Khomami and Javidi (2013) proposed an architecture of home energy management system (EMS) and automated demand response (DR) framework for scheduling smart home appliances, using run-time price (RTP) and inclined base rate (IBR. In this method, authors reduce EC and PAR but ignore user comfort. In this article (Ahmad et al. 2017), the authors proposed OHEMS that integrates RES (Renewable Energy Sources) and ESS (Electricity Storage System). Different meta-heuristic optimization algorithms are applied like GA, binary particle swarm optimization (BPSO), winddriven optimization (WDO), BFA, and proposed hybrid GA-PSO (HGPO) to reduce electricity cost and PAR. However, user comfort is not considered. Authors in Rahim et al. (2018b) schedule home appliances using bio-inspired elephant herding optimization (EHO) and adaptive cuckoo search algorithm (ACS). These two algorithms proposed a new hybrid elephant adaptive cuckoo (HEAC). It solves real-time scheduling using dynamic programming and using the concept of coordination among home appliances. A trade-off exists between EC and PAR. In this article (Lorestani and Aghaee 2017), the authors designed an energy management system for smart homes using the shuffled frog leaping algorithm (SFLA) for the optimum schedule of different resources like PV (photovoltaic) panels, electric plug-in electric vehicle (PEV), batteries, electric heaters (EH) to balance electric and gas consumption and reduce daily electricity cost. The author in Hussain et al. (2018) proposed an efficient home energy management controller (EHEMC), using heuristic GA, wind-driven optimization (WDO), harmony search algorithm (HAS), and proposed a hybrid genetic harmony search algorithm (GHSA) for a single home and multiple homes to reduce cost and to wait time of appliances, using price tariff RTEP, and CPP. Authors in Aslam et al. (2017) proposed a HEM scheme to reduce cost, PAR, and user discomfort using heuristic GA, cuckoo search optimization algorithm (CSOA), and crow search algorithm (CSA). To improve the performance of smart home authors, take an electric storage system (ESS). The author in Ullah et al. (2020) proposed intelligence supervisory predictive control (IPSC) to reduce the energy consumption trends. Authors in Ullah et al. (2021) proposed a multi-objective winddriven optimization algorithm and multi-objective genetic algorithm for energy optimization. Authors in Samuel et al. (2022) designed an analytical pricing scheme to reduce electricity cost and a dynamic multi-pseudonym technique for privacy in a smart grid. Authors in Dagdougui et al. (2020) proposed a model predictive control MPC algorithm for smart building. This system schedules home appliances in a smart building and power exchanges with a smart grid. A list of the literature review is shown in Table 1. Different mathematical and heuristic models are proposed to solve the optimization problem. But there always exists a trade-off between different parameters. To improve search efficiency, this is a challenging task. Some issues are present here; user comfort is compromised due to high electricity costs. To reduce electricity cost using appliance scheduling, compromise user comfort in terms of waiting time. Reducing electricity cost concerning maximum user comfort increase the grid's burden in terms of peak-to-average ratio.
The SHEM system is proposed for load shifting to reduce electricity cost and PAR in this research. Two heuristic algorithms, BFA and ACO, are used for scheduling home appliances. BFA provides local search and limitation having global search, for global search, we use ACO because it is simple, robust, short computation time. After analyzing the performance of existing algorithms, it is required to improve search efficiency, so based on these algorithms, we proposed a hybrid algorithm, bacterial foraging and ant colony optimization algorithm (HB-ACO). Further, we use the concept of coordination among home appliances. When a user switches off an appliance, the remaining time slot is used to reschedule high-priority appliances to reduce the appliance's waiting time in run time. We consider this a knapsack problem and solve it through the ACO algorithm.

System model
This section assumes a smart home system with smart appliances that communicate with the energy management system. The monitoring unit that corresponds with the utility for price signal monitors user power demand. Management unit that schedules home appliance and control unit decides which appliance should be ON or OFF according to assign working hours. HEMS work efficiently depends upon proper coordination between user and system. Run-time scheduling is the responsibility of the management unit, in which one appliance is turned OFF, and another appliance is rescheduled in particular space-time. Figure 1 shows the system model of a smart home. A smart meter is installed to provide two-way communication between the service provider and end-user to receive service and electricity prices from the service provider. The end-user sends power consumption to the smart grid. This model for smart home schedule appliances on a day-ahead and real-time basis reduces electricity cost, PAR, and waiting time of appliances.

Problem formulation
The proposed HEMS shifts the load on a day-ahead realtime basis. Considering the scheduling techniques, we focus on achieving multiple objectives. The day-ahead goal includes minimizing the electricity cost, PAR, and realtime scheduling to reduce the waiting time of appliances. In this section, equations used for loading shifting, electricity cost minimization, PAR reduction, and user comfort are written on our own. The day-ahead model for home load management is given by the following:

Load shifting
To schedule home appliances in a balanced way neither creates PAR nor compromises user comfort. The proposed algorithms schedule home appliances optimally. Power consumption of appliances during a particular hour is given in Eq. 1.
K l Electric power load per hour represents the average load of an ON appliance during a particular time.
APP a p rate Ã q ð1Þ q = 1, 0 represents the ON and OFF states of the appliance during a particular hour, and D represents the number of appliances.

Electricity cost minimization
Second objective is cost minimization, which can be mathematically represented as follows: K total cost total electricity cost of all appliances for a single day. where per hour cost is calculated using Eq. 3.
APP d p rate represent power consumption of each appliance is given in Table 2.

PAR reduction
To maintain grid stable, it is necessary to reduce PAR. Therefore, the reduction of PAR is one of the research objectives. It can be mathematically represented as: This is accomplished by Eq. 1. Formally, the PAR can be written as: where K N load is equal to K 1 load ; K 2 load ; . . .; K 24 load È É is a per-hour electricity load calculated using Eq. 1 Fig. 1 A view of the system model between the user and the service provider Energy optimization in smart urban buildings using bio-inspired ant colony optimization 977

User comfort
In some situations, the user wants to turn off an appliance and reschedule another appliance at this particular time to reduce the waiting time of that appliance. This will maximize user comfort, which can be written mathematically as follows: When interrupt T occurs to switch off appliance and request for real-time scheduling from list of rescheduling appliances APP C list . It can be mathematically represented as follows: APP d wait Appliance waiting time and comfort have inverse relation with each other.
The waiting time of appliance d is calculated using Eq. 8.

Proposed algorithm
We proposed a hybrid bacterial foraging and ant colony optimization algorithm (HB-ACO) to solve a scheduling problem. The purpose of our proposed algorithm is load shifting to reduce cost and electricity. Moreover, we use the concept of coordination among appliances and consider it a knapsack problem and solve it through the ACO algorithm.

Day-ahead scheduling
For day-ahead scheduling, Algorithm 1 is used, which follows the hybridization concept to improve the efficiency of BFA. We are using the ACO algorithm together with BFA. BFA selects the best population from a group of lowcost bacteria while searching for food and eliminates bacteria with fewer nutrients. We use the pheromone trial of the ACO algorithm and select a population through probability having high pheromone level and with less pheromone level that are eliminated to choose the best population. The proposed hybrid algorithm (HB-ACO) replaces the elimination and dispersal step of BFA through update pheromone and probability selection of ACO.

ACO
Ant searches for food randomly and deposits some chemical called pheromone. Depending on pheromone level and attractiveness function, other ants follow the maximum pheromone route because ant has sensing ability. After some time, all ants follow the shortest route. Dorigo (2006) presents this computer programming concept to solve complex problems. Khan (2010) presents different parameters for a scientific workflow using ant colony optimization. Equations (9) to (13) are taken from Khan et al. (2010). The amount of pheromone level deposit by an ant is mathematically represented as follows: where Ds represents the amount of pheromone deposit by ant k traveling from edge i to j. In 1 L k L k represents the path length found by a kth ant. The shorter the path, the higher pheromone should be deposited by the ant. Pheromone level without vaporization: Pheromone level with vaporization: if q is equal to 1, all pheromone evaporates before depositing new pheromone. If q is equal to 0, it means no vaporization. The probability of ant to select a node is mathematically represented as follows: P i;j Represent the probability of choosing edge i and j. where g i;j represent quality of edge i and j on the graph. We are interested in the shortest path so, a and b are used to find relative importance between pheromone and distance.

BFA
To represent the social behavior of bacterial foraging in a computer program M. Passino represent an algorithm to Energy optimization in smart urban buildings using bio-inspired ant colony optimization 979 solve complex engineering problem (Irshad et al. 2019). When E. Coli bacteria search for food, it follows three steps: (a) chemotaxis, length of lifetime of bacteria, i.e., single bacterium or a group of bacteria swim for food, when it finds an environment with good nutrients to swim further to gain more nutrients to perform extra activates like reproduction, sleep. Otherwise, it will tumble mean changing its position. BFA starts its working by calculating the fitness function J i of each bacteria using the Rosenbrock function given in Eq. (15). To represent the movement of bacteria, Eq. (16) is used; let (j,k,l) represent ith bacteria with jth chemotactic steps, kth reproduction step and lth elimination and dispersal step where (C i ) represents the change in direction.
(b) Reproduction: When a group of bacteria swim for food and perform well in their lifetime gain more food, having less cost function. These bacteria will constantly reproduce next generation.
(c) Elimination and dispersal: Due to unfavorable conditions like fewer nutrients, high temperature. These bacteria are eliminated to some other place and dispersed, having low probability. In the end, the elimination and dispersal of the best bacterium are selected using the fitness function given in Eq. (14), representing the schedule of appliances.

HB-ACO
In this research, we follow the concept of hybridization to solve the scheduling problem of smart buildings. We proposed a hybrid bacterial foraging and ant colony optimization algorithm (HB-ACO) explained in algorithm 1. HB-ACO followed the step of BFA as explained in the previous section with the difference elimination and dispersal. The proposed algorithm replaces the elimination and dispersal step of BFA through update pheromone and probability selection (Fig. 2).

Real-time scheduling
When a user interrupts in an emergency to use a highpriority appliance, the scheduler switches off such appliance at real time. It allocates the reaming time of the appliance to a high-priority appliance. We consider this problem to be a knapsack problem and to solve this problem. We are using the ant colony optimization algorithm. For selection, we generate an artificial ant that calculates the object's width, which is an operational time of a particular appliance and cost of the object, which is the total cost of the object in that particular hour. We consider knapsack capacity as the reaming time of the stooped object. Start real-time scheduling 24 h into on-peak and offpeak, as discussed in Tables 3 and 4.
Also, schedule home appliances according to load scheduled that appliance that uses less electricity during on-peak hours and schedule appliance with high load in off-peak hours in a balanced way. If Interrupt occurs during an emergency, we consider this is a knapsack problem. Therefore, stop appliance and calculate reaming time of running appliance and allocate this time to knapsack capacity.
ACO starts its work by moving an artificial ant containing a list of appliances APP C list to reschedule. Where knapsack capacity is the available time interval when an interrupt T occurs. The weight of an item is considered, the operations time of a particular appliance and value is the cost of the appliance during a particular hour depending upon operational time and price signal.

Result before coordination
This section analyzes proposed solutions using two different pricing rates: ToU and CPP. The simulation results before coordination are clear from Figs. 3, 5 and 7. Figure 7 shows that unscheduled load price is high for both tariffs. It shows the total unscheduled electricity cost 1800 cents for ToU and 6700 cents for a CPP. The result shows that implemented optimization techniques shift load, which directly affects electricity cost, as shown in Fig. 3. HB-ACO shows relatively low price signals for high peak hours. Graphical representation of per hour cost for an unscheduled and HB-ACO proposed approach along with ACO and BFA is shown in Fig. 7. Due to load shifting from on-peak hours to off-peak hours cost paid is less compared to unscheduled load. Performance of HB-ACO for ToU tariff compared with other two approaches is better; HB-ACO has reduced 48% PAR and 17% cost. Cost reduction of BFA is the same as HB-ACO, but PAR is comparatively higher than HB-ACO. HB-ACO again outperformed the CPP and reduced 42% PAR and 40% cost, Fig. 4 Per-hour scheduled load after coordination a ToU. b CPP Energy optimization in smart urban buildings using bio-inspired ant colony optimization 983

Result after coordination
Simulation results after coordination are given in Figs. 2, 4 and 6. Heuristic algorithms perform better compared to evolutionary approaches, where hybrid algorithms outperform both algorithms used in this paper, as shown in Fig. 8. It is also shown from Fig. 8 that 5%, 8% and 8% less cost Energy optimization in smart urban buildings using bio-inspired ant colony optimization 985 than without coordination for ACO, BFA and HB-ACO. Figure 8 clearly shows that HB-ACO reduces 5% maximum cost with a 9% increase in PAR and 14% reduced waiting time shown in Fig. 12. However, a trade-off occurs between PAR and cost during coordination because sometimes it passes heavy load appliance. The result clearly shows the difference between before and after coordination because of the reduction in the load and increase in the peak load (Figs. 9, 10, 11, 12).
Simulation result further shows a trade-off between cost, PAR and waiting for the time of appliances. Table 5 shows the effect on electricity cost, PAR and waiting time after coordination. The difference between before and after waiting time for base load and interruptible load appliances is the list of rescheduled appliances belong to this category (Tables 6 and 7).

Conclusion and future work
In this paper, we have designed a home energy management system (HEMS) to shift electricity load in a single home having multiple appliances on a day-ahead basis and a real-time basis. To evaluate the performance parameters, electricity cost, PAR and user comfort in terms of waiting time for three heuristic algorithms BFA, ACO and a hybrid HB-ACO are used for scheduling home appliances. For real-time scheduling, when interrupts occur, the scheduler turns off the appliance, allocates reaming time to the priority appliance, and solves it using ACO. This coordination and reschedule increase user comfort in terms of waiting time. To evaluate the performance of the proposed algorithm, two pricing schemes ToU and CPP are used. Finally, for efficiency, the result of the proposed algorithm  1:00 AM to 10:00 PM On-peak hours Energy optimization in smart urban buildings using bio-inspired ant colony optimization 987 is compared with ACO and BFA. The result shows that 48% electricity cost and 38% PAR are reduced. Appliances' scheduling is a challenging task because the different users have different behaviors of consumption electricity. There always exists a trade-off between different parameters like electricity cost, peak-to-average ratio and user comfort. Opportunities always exist to improve search efficiency further to reduce electricity load with maximum user comfort.
Funding This research is based upon work supported by King Fahd University of Petroleum and Minerals, and the author Fakhri Alam Khan at KFUPM acknowledges the support received under Grant no. SR211008.
Data availability Enquiries about data availability should be directed to the authors.

Declaration
Conflict of interest The authors have not disclosed any competing interests.