Analyzing energy consumption of nature-inspired optimization algorithms

Nature-Inspired Optimization (NIO) algorithms have become prevalent to address a variety of optimization problems in real-world applications because of their simplicity, flexibility, and effectiveness. Some application areas of NIO algorithms are telecommunications, image processing, engineering design, vehicle routing, etc. This study presents a critical analysis of energy consumption and their corresponding carbon footprint for four popular NIO algorithms. Microsoft Joulemeter is employed for measuring the energy consumption during the runtime of each algorithm, while the corresponding carbon footprint of each algorithm is calculated based on the UK DEFRA guide. The results of this study evidence that each algorithm demonstrates different energy consumption behaviors to achieve the same goal. In addition, a one-way Analysis of Variance (ANOVA) test is conducted, which shows that the average energy consumption of each algorithm is significantly different from each other. This study will help guide software engineers and practitioners in their selection of an energy-efficient NIO algorithm. As for future work, more NIO algorithms and their variants can be considered for energy consumption analysis to identify the greenest NIO algorithms amongst them all. In addition, future work can also be considered to ascertain possible relationships between NIO algorithms and the energy usage of hardware resources of different CPU architectures.


Introduction
Optimization is a commonly encountered mathematical problem in many disciplines such as engineering, business activities, industrial designs, etc. Many realworld applications in science and engineering encompass various forms of optimization such as: minimizing energy consumption, cost or maximizing performance and efficiency. Traditional optimization algorithms for real-world problems are predominantly highly nonlinear with large numbers of local optima accompanied with a set of complex nonlinear constraints [1]. On the other hand, nature-Inspired Optimization (NIO) algorithms are population-based metaheuristics that mimic diverse phenomena in nature [2]. They circumvent local optima more Jamil and Kor Green Technology, Resilience, and Sustainability faster processors have resulted in increased energy consumption. Therefore, the energy usage of an algorithm is a crucial element that needs to be factored in for the evaluation of an algorithm (i.e. in terms of performance and sustainability). The effectiveness and efficiency of an algorithm need to be assessed in the context of a target application because its deployment would have an impact on energy consumption and environmental impact. Carbon footprint is one way to assess the environmental impacts of ICT. Companies can make the software an integral part of their sustainability efforts by assessing its energy efficiency level, associated carbon footprint and deploying it to green business operations or processes [4]. Over the past few years, the deployment of Machine Learning (ML) models has grown exponentially in size [5]. The associated energy consumption and cost involved for training as well as building ML models has become a growing concern [6]. It is found that designing and training translation engines in Natural Language Processing (NLP) can emit between 0.6 and 280 tonnes of CO 2 [7]. Hence, an algorithm's carbon footprint needs to be appropriately addressed during its design, implementation, and deployment.
Currently, there are more than a hundred existing NIO algorithms and their variants in literature [2]. However, this study aims to analyze energy consumption and corresponding carbon footprint for four widely used NIO algorithms, namely Genetic Algorithm (GA), Particle Swarm Optimization (PSO), Differential Evolution (DE), and Artificial Bee Colony (ABC) algorithm. These four algorithms have been considered in this study due to their wide ranging application areas. This research aims to demonstrate how the energy consumption of these algorithms could be empirically assessed. Note that other NIO algorithms could be addressed in future work.
Genetic Algorithm (GA) evolves from the Darwinian evolution of biological systems, where the main characteristics are three genetic operators, namely crossover, mutation, and selection [8]. It has been applied to solve complex problems such as computer-automated design [9], power electronics design [10], gene expression profiling analysis [11], bioinformatics multiple sequence alignment [12], facility layout problem [13,14], etc. However, a limitation of GA is its premature convergence that can lead to the loss of alleles, which makes it difficult to identify a gene [15].
Particle Swarm Optimization (PSO) is derived from the swarm intelligence of flocking of birds and schooling of fishes in search of food, where each particle contains its own velocity and position [16]. It has been used to address several problems such as software cost estimation [17], human motion tracking [18], resource allocation in the cloud [19], assembly line balancing [20], data clustering [21], etc. However, a limitation of PSO is it easily falls into local optimum in high-dimensional space and has a low convergence rate in the iterative process [22]. Differential Evolution (DE) is formulated on the vector population evolution, where new individuals are generated by differential crossover and mutation operators [23]. It has been used in tackling many different problems such as electromagnetic inverse scattering problems [24], electromagnetic imaging [25], antenna array design [26], robot motion planning and navigation [27], etc. However, a limitation of DE is its unstable convergence, and it easily falls into regional optimum [28].
Artificial Bee Colony (ABC) algorithm is elicited from the food searching behavior of honey bee swarm, where the swarm comprises three components, namely food source, employee foragers, and unemployed foragers [29]. It has been applied to solve a number of problems such as economic dispatch problem [30], traveling salesman problem [31], mobile robot path planning [32], load balancing in the cloud [33], image segmentation [34], etc. However, a limitation of the ABC algorithm is it converges slowly in the process of searching and easily suffers from premature convergence [35].
A set of objectives to support the aim of this study is as follows: • Conduct a critical literature review on the environmental impact of ICT, green or energyefficient software, the impact of hardware energy consumption by software, and the analysis of energy consumption in algorithms implementations as well as nature-inspired algorithms and energy efficiency. • Implement the four NIO algorithms using MATLAB and conduct a set of experiments for measuring the energy consumption of these algorithms by utilizing a commonly used benchmark function, named Sphere Function. • Estimate the equivalent carbon footprint of each algorithm based on the amount of energy consumed by each algorithm. • Investigate whether the average energy consumption of these four algorithms is significantly different or not by performing a one-way ANOVA (Analysis of Variance) test.
Several existing work has conducted a comparative analysis of the energy consumption of different programming languages [36][37][38] and sorting algorithms implementations [39][40][41][42]. To date, in existing literature, energy consumption and carbon footprint of NIO algorithms have not been analyzed to the best of our knowledge.
Hence, the novel contribution of this study is to analyze the energy impact of NIO algorithms during execution in MATLAB by conducting experiments with a benchmark function. The limitation of this research is that only four types of NIO algorithms have been investigated. However, the energy consumption-related experiment procedures could be replicated for all other non-listed NIO algorithms. In addition, the equivalent carbon footprint of each algorithm has been estimated based on their energy consumption, and an ANOVA test has been conducted to test the significant difference in the average energy consumption among these algorithms. This study will help developers choose the greenest NIO algorithm to solve a particular domain problem when energy consumption minimization is the top priority. The remainder of this article is organized as follows: a literature review on the environmental impact of ICT, green or energy-efficient software, the influence of hardware energy consumption by software, and related works on the analysis of energy consumption in algorithms implementations as well as nature-inspired algorithms and energy efficiency is presented in Section 2. Section 3 provides a brief overview of methodologies, which include both macro and micro methodology as well as experiment setup and design. Findings and discussion are presented in Section 4, which discusses energy consumption and corresponding carbon footprint of each algorithm, the ANOVA test, and ethical issues and challenges of this study. A summary of the discussion and recommendations for future studies is presented in Section 5.

Environmental impact of ICT
The ICT sector is accountable for two percent of global carbon emissions, while the rest of the sectors, for example, health, transportation, education, etc., are responsible for the remaining 98% of carbon emissions [43]. The increase of carbon emissions due to GreenHouse Gases (GHGs) and other factors will have a negative impact on the environment as well as the economy [44]. Due to the increasing global demand for ICT products and services, the ICT sector can play a crucial role in reducing global carbon emissions by minimizing the carbon footprints of its products and services. Though a lot of research has been undertaken for making hardware and other embedded systems energy-efficient [45][46][47][48], a similar focus needs to be given to the development of energy-efficient software and applications [49,50].

Energy-efficient software
A piece of software is labeled as green or energy-efficient when it consumes less energy for its efficient computation that results in minimal adverse effects on environment [51]. Several research work has been conducted on the investigation of energy efficiency of web-based software application [52] and software features [53]. The direct impact of software on a laptop or mobile battery can easily be measured as approximately 25% to 40% of the total energy consumed by a device [54]. However, the indirect impact of software is comparatively harder to assess as they are related to the life cycle of the host device [55]. An energy-efficient or green software can be achieved when its positive and negative impacts are duly considered during the design as well as deployment phase. In view of this, optimization of ICT application services is highly necessary to lessen unpropitious effects on the environment.

Impact of hardware-Related energy consumption by software
The hardware-related energy consumption behavior of software has a direct influence on the energy consumed by hardware as well as the battery life of a device [56]. A poorly designed software or application can nullify several energy-efficient features embedded into the hardware that may eventually increase the energy consumption of a device [57]. For example, it can inhibit energy-saving features of hardware as well as affect hardware utilization, which may ultimately increase indirect energy consumption [58]. One of the most challenging tasks during the design phase of an embedded system is the development of energy-efficient software that makes a piece of hardware more energy-efficient as well. Therefore, some tradeoffs between performance and sustainability will have to be considered so that software and applications can be made more productive yet energy-efficient [59].

Analysis of energy consumption in algorithms implementations
In existing literature, there is relatively little work that provides insights into algorithm implementation-related energy consumption. Rashid and colleagues have analyzed the energy efficiency of four sorting algorithms, namely Bubble, Merge, Quick, and Counting sort [39]. In this study, an experiment was set up on an ARM-based device, and the energy consumption of four sorting algorithms implemented in three programming languages was measured. This study found that the ARM assembly language implementation of Counting sort was the greenest solution.
Measurement of the energy consumption for five sorting algorithms, namely Bubble, Insertion, Quick, Selection, and Counting sort, has been conducted in [40]. In this study, five different Apps were developed for each sorting algorithm to measure energy consumption. This study found that Quick sort is the most energy-efficient sorting method in average cases, while Bubble sort is the most energy-consuming algorithm.
Deepthi and colleagues have conducted experiments to study how different sorting algorithms have an impact on energy consumption using C language implementation [41]. This study found that both time and energy have an impact on the efficiency of these sorting algorithms. This Ayodele and colleagues have carried out a comparative experimental analysis of the energy consumption of Quick, Merge, and Insertion sort algorithms using three programming languages (C, Java, and Python) and two algorithm implementation styles (Iterative and Recursive) [42]. This study found that data size, the programming language used, and algorithm implementation styles affect the total energy consumption. Besides, this study provides information for choosing sorting algorithm type and its algorithm implementation style in order to minimize energy consumption.
Though several existing research related to energy consumption analysis of different sorting algorithms implementations have been performed, the energy consumption of NIO algorithms has not been analyzed till now to the best of our knowledge. Therefore, the initial motivation and primary focus of this study is to analyze the energy consumption of four NIO algorithms based on a benchmark function.

Nature-inspired algorithms and energy efficiency
Existing nature-inspired algorithms research primarily addresses the following areas of research: optimization [1,2,60,61] using metaheuristics [62] or heuristics [63] approaches; greening processes, for example greening the supply chain [64], smart energy management [65], data center energy efficiency [66]; energy efficiency [67] and energy optimization [68] in wireless sensor network clustering. Our critical literature review has shown that to date, there is no research on energy efficient natureinspired algorithms and thus, our research aims to address this identified gap.

Macro methodology
In this study, an LCA (Life Cycle Assessment) methodology for ICT GNS (Goods, Networks, and Services) [69] has been considered as the macro methodology. It is a systematic analytical method to assess the potential environmental effects of ICT GNS in a consistent and transparent manner. It has a cradle-to-grave scope that comprises four life cycle stages, namely Raw Material Acquisition (RMA), Production, Use, and End-of-Life Treatment (EoLT). The ICT LCA application considered in this study is the assessment of energy consumption as well as evaluation of an environmental impact, namely carbon footprint of four NIO algorithms and comparative analysis between them. Figure 1 shows the structure of the LCA methodology specification for ICT GNS.
The first phase of LCA is General Requirements, which consists of high-level requirements of life cycle stages that will be assessed in the context of the problem. In this study, the four NIO algorithms have been considered as an ICT service (application), and their use stage has been considered, where the algorithms impact on energy use. The second phase is Goal and Scope Definition, where the goal phase states the intended application, reasons for conducting the study as well as the intended audience to whom the results of the study will be beneficial, while the scoping phase identifies the building blocks and system boundaries of the ICT GNS. In this study, the goal and scope have been defined in Section 1. The third phase is the Life Cycle Inventory (LCI) which includes data collection within the system boundary and analysis of the collected data to quantify the inputs and outputs of a unit process. In this study, a discussion of data collection has been presented in Sections 3.2 and 3.4, while the analysis of the collected data has been presented in Sections 4.1 and 4.3. The fourth phase is the Life Cycle Impact Assessment (LCIA) that estimates the potential environmental impact quantified in the LCI analysis. In this study, the potential environmental impact has been estimated in Section 4.2.
The fifth phase is the Life Cycle Interpretation, where findings from the LCI analysis and LCIA are considered together to answer queries raised in the goal definition as well as draw conclusions, identify limitations and provide recommendations. The sixth and final phase is reporting which summarizes the various reporting requirements and additional reporting considerations in order to make evidence-based decisions. In this study, a summary of the discussion and some scope of improvement for future studies have been presented in Section 5.

Micro methodology
The micro methodology involves the use of a number of tools or software, as discussed below.

Data collection
The four NIO algorithms considered in this study have been gathered from existing literature [8,16,23,29] and implemented accordingly using MATLAB.

Energy profiling
The energy consumption of each NIO algorithm has been estimated using Microsoft Joulemeter software [70], which has the ability to measure the energy consumed by a running application or software and individual hardware resources, such as CPU, Monitor, Disk, and Idle or Base power.

Carbon footprint
The DEFRA guideline for greenhouse gas conversion factors [71] has been used for calculating carbon footprint corresponding to the energy consumption of each algorithm. After obtaining energy consumption in terms of kilowatt-hours (kWh), the recorded data is converted from kWh into equivalent CO 2 emission based on the emission factor for electricity consumption (0.25319 kgCO 2 e/kWh).

Experiment setup 3.3.1 System specification
Different hardware specifications would bring about different results. Therefore, all experiments were conducted on a laptop with the following specifications shown in Table 1.

Calibrating Joulemeter
Since Windows 8.1 Pro operating system lacks the support for automatic calibration (in Joulemeter), the calibration has been done manually based on the Joulemeter user manual, which is shown in Fig. 2.

Experiment design
All four NIO algorithms have been implemented using MATLAB programming language. A commonly used benchmark function, namely sphere function, has been used for measuring the energy consumption of these four algorithms. The sphere function can be written as: where search space, x i ∈[ −5.12, 5.12], for i = 1, ..., d, and global minimum, f (x * ) = 0, at x * = (0, ..., 0).
For each algorithm, the dimension size (D) has been taken as 50, population size as 10 * D, maximum iteration as 100 * D, and optimal value to reach is set as 10 −8 . All algorithms have been executed ten times separately, and during each run, the estimated energy consumption of each algorithm has been captured by Joulemeter.
For each algorithm, the dimension size, population size, maximum iteration, optimal value to reach, and the number of execution have been considered the same to analyze the measurements' consistency and avoid outliers.
The corresponding result of each algorithm has been stored in a separate CSV file. All results of each algorithm have been aggregated in an Excel file for analyzing the energy consumption of these four algorithms. The design of experiments can be summarized as follows.

Energy consumption
The details of energy consumed by each optimization algorithm for all experiment runs are shown in Table 2,  Table 3 depicts the aggregated data for all the experiments conducted for each algorithm. The convergence time of each algorithm is different. Therefore, to perform a fair comparison and maintain the measurements' consistency between four algorithms, the corresponding energy consumption of each algorithm is normalized for t = 1s, which is shown in Table 4.
For better illustration, Fig. 3 shows a comparison of normalized hardware energy consumption for each algorithm, while Fig. 4 depicts the energy consumption by the hardware and application for each algorithm.
From Table 4 and Fig. 3, it can be seen that the DE algorithm consumes the least energy, followed by PSO and GA, while ABC algorithm has the highest energy consumption.
As mentioned earlier, different hardware specifications would bring about different results. Therefore, if the experiments are conducted on a laptop with different specifications, the result will vary. From Fig. 4, it can be observed that the energy consumption of hardware that runs the application is much higher compared to the energy consumed by the application for each algorithm. In order to facilitate the reduction of the overall energy consumption, more research and investigation need to focus on the optimization of interaction and processes between hardware and software [52].
Since DE algorithm is found to have the lowest energy consumption, it is used as a base to investigate the energy consumption ratio of other algorithms which is shown in Table 5. From Table 5, it is obvious that running ABC algorithm consumes almost four times more energy compared to DE algorithm, while the energy consumed by GA algorithm is approximately double in comparison with DE algorithm. The energy consumed by PSO is comparatively lower than ABC and GA algorithms.

Carbon footprint
The carbon footprint of each algorithm has been calculated by converting the aggregated total energy consumption (kWh) into equivalent CO 2 emission based on the emission factor for electricity consumption (0.25319/kgCO 2 e/kWh) [71], which is shown in Table 6.
From Table 6, it can be seen that DE algorithm has the lowest carbon footprint, followed by PSO and GA, while ABC algorithm has the highest carbon footprint among all algorithms.

One-way ANOVA (Analysis of variance) test
A statistical parametric test, named one-way ANOVA, has been conducted to verify whether the average energy consumption per second of these four algorithms is significantly different or not at the significance level (α = 0.05) using Excel Data Analysis ToolPak.
The statistical hypotheses for one-way ANOVA are formulated as follows.
-Null Hypothesis: The average energy consumed by each algorithm is equal. -Alternative Hypothesis: The average energy consumption of each algorithm is significantly different.
The null hypothesis for the test will be rejected if the 481 p-value is less than the significance level (α = 0.05) [72] or otherwise. In order to understand the energy impact of each algorithm, the ANOVA test is performed on the average energy consumption per second (J/s) of each algorithm for all experiment runs, as shown in Table 7. Results obtained after the ANOVA test are depicted in Table 8.
From Table 8, it is evident that the p-value (5.85E − 37) is less than the significance level (α = 0.05), so the null hypothesis is rejected. Therefore, it can be concluded from the ANOVA test that the average energy consumed by each algorithm is significantly different.

Ethical issues and challenges
The goal of this study is to measure and understand the energy consumption behavior of four NIO algorithms. This study will provide greater insight into how one NIO algorithm performs compared to other algorithms in terms of energy consumption. Some possible validityrelated problems in this study can be divided into four categories [73,74], namely conclusion validity, internal validity, construct validity, and external validity.

Conclusion validity
This category describes factors that may influence the validity of drawn conclusions [74]. From the experiments conducted in this study, it is clear that different NIO algorithms incur varying amount of processingrelated energy consumption. For a better comparison, the energy consumption of the CPU as well as other hardware resources consumption, such as Monitor, Disk, and Idle or Base power, have also been measured. Additionally, to present the analysis in this study, only four NIO algorithms have been chosen due to their applicability to solving a wide range of problems in diverse areas. Nevertheless, the experiments conducted in this research could be replicated for other NIO algorithms.

Internal validity
This category concerns itself with what factors may interfere with the results of a study [74]. When measuring the energy consumption of the four NIO algorithms, other factors alongside the different implementations of algorithms using different programming languages may contribute to variations, for example, a specific version of a laptop. In order to avoid this, every NIO algorithm has been implemented using MATLAB, and the energy consumption of these algorithms is measured by utilizing a commonly used benchmark function named Sphere Function. Besides, on a specific laptop, each NIO algorithm was executed 10 times, and the corresponding energy consumption of each algorithm was measured accordingly. This allowed us to minimize the particular states of the tested machine, including uncontrollable system processes and software. However, the measured results are quite consistent and thus reliable. In addition, the used energy measurement tool has also been proven to be accurate.

Construct validity
This category concerns the generalization of the results to concepts or theories that underlie the experiments [74].
In practice, all the four NIO algorithms have been implemented in different programming languages. However, in this research, each algorithm has been implemented using MATLAB, and the energy consumption of these algorithms is measured by utilizing a commonly used benchmark function named Sphere Function. This allows us to compare the energy consumption of different NIO algorithms for the same task execution. Steps have been taken to ensure that the experimental procedures remain consistent for all the four algorithms.

External validity
This is concerned with the generalization of the results [74]. The greenest NIO algorithm found in this study is based on the outcome of several conducted set of experiments. Since there exist more than a hundred NIO algorithms and their variants in the literature [2], we could not make a generalization about the greenest NIO algorithm because it requires further experiments with all other NIO algorithms. Additionally, experiments run on varying devices would yield different results. In order to ensure consistency and valid results, the algorithms would have to be deployed on the same device. Thus, it is necessary to report the experiment procedures in order to understand Table 6 Carbon Footprint for Each Algorithm its applicability to other contexts [74]. To summarize, the actual approach and methodology used in this study fosters easy replications. Thus, other researchers would be able to easily replicate the applied methodology for future work.

Conclusion and future work
In this study, energy consumption and associated carbon footprint of four widely used Nature-Inspired Optimization (NIO) algorithms have been examined. Each optimization algorithm exhibits significantly different energy consumption, where Differential Evolution (DE) is found to be greenest compared to other algorithms. In addition, a one-way Analysis of Variance (ANOVA) test has been performed, where the test reveals that the average energy consumed by each algorithm is significantly different from each other. The aim of this study will raise awareness of the energy efficiency issue of NIO algorithms and encourage researchers to conduct more research in this field to provide pragmatic yet greener solutions. Research in  However, there exist some challenging concerns of NIO algorithms in spite of their popularity and effectiveness. All NIO algorithms contain algorithm-dependent parameters, and the value of these parameters can significantly influence their performance under consideration [75]. It is still not evident what the best value of these parameters is to achieve an optimal balance of exploration and exploitation for a given algorithm and a given set of problems as parameter settings can be algorithm or problemdependent [61]. Therefore, an investigation of tuning and controlling of parameters for NIO algorithms can be explored so that their performance can be maximized with reduced energy consumption.
As far as future work is concerned, more NIO algorithms and their variants can be considered for energy consumption analysis so that the top ten greenest NIO algorithms could be identified. Besides, more benchmark functions and real-life optimization problems can also be taken into account while evaluating the energy consumption of NIO algorithms. Moreover, different CPU architectures, such as AMD and ARM, can also be considered for running these algorithms. Energy usage of hardware resources for different CPU architectures can be collected in order to identify possible relationships between NIO algorithms and the energy usage of hardware resources. All these proposed efforts will shed light energy efficiency of NIO algorithms for complex applications.