## 1 Introduction  
Energy utilization efficiency is increasing with increased use of technology and smart appliances in every field of life in the residential, commercial and industrial sectors. At the same time, a reliable and high-quality electrical power system is extremely vital to fulfil the residential energy demand. Meanwhile, there is a rapid increase in demand for global natural resources. Throughout the world, major blackouts occur due to consumer demand and utility supply mismatch and system automation deficiencies. Hence, a transition process from the Traditional Electric Power Grid (TEPG) to the Smart Grid (SG), to integrate communication and information technologies, is the demand of the future. Presently, about 40% of the total generated energy is consumed by residential users, and approximately 30-40% of carbon emission is due to these residential areas [1]. The unnecessary and inefficient use of electrical energy brings sustainability issues to the forefront, such as economic growth, heavy pollution and global warming. Conventionally, the service provider power systems run on fossil fuel and add to global warming with high carbon emissions. Furthermore, in the present power systems, electricity power flow is uni-directional, i.e., from the supply- to the demand-side. Conversely, SG's purpose is to make the flow of electricity supply and demand bidirectional [2]. Secondly, the search for and integration of new green renewable energy resources are obligatory in such circumstances. The integration of green renewable energy resources needs a broader perspective of design, planning and optimization. Up to this time, different conventional optimization techniques, such as Linear Programming (LP) [3], Non-Linear Programming (NLP) [4], Integer Linear Programming (ILP) [5], Mixed Integer Linear Programming (MILP) [6], Dynamic Programming (DP) [7] and Constrained Programming (CP), have been practised. However, in the present situations, the integration of renewable energy resources is mandatory, and the problems are non-linear and have numerous local optima, making conventional optimization techniques obsolete. In the last decade, bio-inspired modern heuristic optimization techniques have grown in popularity due to their stochastic search mechanisms and avoidance of large convergence time for the exact solution [1]. In this research work, we propose a new meta-heuristic optimization algorithm, named Time-constrained Genetic-Moth-Flame Optimization (TG-MFO), and applied it for efficient energy optimization in smart homes and buildings. We have also explored and analysed five bio-inspired heuristic algorithms for the energy optimization problem, namely the ACO, GA, Cuckoo Search Algorithm (CSA), Firefly Algorithm (FA) and MFO algorithms. For analysis and validation of the proposed algorithm, we applied these algorithms in different consumer scenarios, such as a single home for one day, a single home for thirty days, thirty different sizes of homes for one day and thirty homes for thirty days. Simulation results show that our proposed algorithm reduced the end-user discomfort in terms of appliance waiting time being nearly equal to zero, as compared to the bio-inspired optimization algorithms, along with minimization of total energy cost and minimum PAR. Renewable energy sources are also integrated for further minimization of the total load and its cost. To achieve this goal, the smart electric grid is modelled as a residential sector comprised of 30 homes having different sizes, different Lengths of Operational Time (LOTs) and appliance power ratings. Appliance power ratings are different due to the home size requirements. For example, a small-sized home runs a one-ton (12,000 BTU) air conditioner compared to a large-sized home that runs 1.5 tons (18,000 BTU) or even more. Some homes have a Renewable Energy Source (RES) and a Battery Storage Unit (BSU). In the considered model, we have forty-eight (48) Operational Time Intervals (OTIs) in a day, by dividing one hour into two-time slots of thirty minutes each.