Energy-Aware Scheduling of Workflow Using a Heuristic Method on Green Cloud

Energy consumption has been one of the main concerns to support the rapid growth of cloud data centers, as it not only increases the cost of electricity to service providers but also plays an important role in increasing greenhouse gas emissions and thus environmental pollution, and has a negative impact on system reliability and availability. As a result, energy consumption and efficiency metrics have become a vital issue for parallel scheduling applications based on tasks performed at cloud data centers. In this paper, we present a time and energy-aware two-phase scheduling algorithm called best heuristic scheduling (BHS) for directed acyclic graph (DAG) scheduling on cloud data center processors. In the first phase, the algorithm allocates resources to tasks by sorting, based on four heuristic methods and a grasshopper algorithm. It then selects the most appropriate method to perform each task, based on the importance factor determined by the end-user or service provider to achieve a solution designed at the right time. In the second phase, BHS minimizes the makespan and energy consumption according to the importance factor determined by the end-user or service provider and taking into account the start time, setup time, end time, and energy profile of virtual machines. Finally, a test dataset is developed to evaluate the proposed BHS algorithm compared to the multiheuristic resource allocation algorithm (MHRA).(e results show that the proposed algorithm facilitates 19.71%more energy storage than the MHRA algorithm. Furthermore, the makespan is reduced by 56.12% in heterogeneous environments.


Introduction
With the rapid increase in demand for service-oriented computing, in association with the growth of cloud computing technologies, large-scale virtualized data centers have been established worldwide. ese huge data centers consume power at a large scale, which results in a high operational cost [1]. Furthermore, they emit greenhouse gases such as carbon dioxide [2][3][4][5][6][7] and thus produce adverse effects on the environment [8][9][10]. e destructive consequences of high energy consumption have attracted the attention of researchers, which has led to the emergence of a new research field called green computing [11][12][13]. e main idea of green computing is to enable the effective and efficient use of resources, by designing algorithms and methods that can reduce energy consumption. To achieve this goal, data centers must manage their resources with the use of efficient energy reduction techniques [14]. One way to decrease energy consumption is to utilize scheduling policies that allocate tasks to specific resources, which affect processing time and energy consumption [15]. Scheduling is a fundamental solution to improve the productivity of all cloudbased services [16]. erefore, the issue of scheduling parallel programs with limited priority or a directed acyclic graph (DAG), which is one of the applied models used in scientific and engineering disciplines, on homogeneous and heterogeneous computing systems such as cloud data centers with regard to the amount of energy consumed and other performance parameters is of fundamental importance and is considered as one of the problematic optimization issues that many innovative algorithms have been proposed to solve them [2]. A tradeoff must be made between the parameters of efficiency and energy consumption, which leads to a lowered makespan and energy consumption and the increase in efficiency reaching the service agreement level. Several methods are available to reduce the power consumption of an application when it is running on a distributed platform. For example, Miyoshi et al. [17] used low-power processor architectures or dynamic frequency and voltage scaling, Tiwari et al. [18] used algorithmic design and effective energy patterns in compilers, and Beloglazoy et al. [19] applied the change in scheduling policies for task-based applications on existing resources. e main focus of most traditional algorithms for scheduling DAG tasks on distributed computing platforms, such as clusters, grades, and cloud computing, has been to minimize makespan while eradicating concerns about the energy consumed by data centers [16][17][18][19][20][21]. However, there is a trade-off between energy consumption and makespan, as increasing the efficiency to enable faster implementation occasionally requiring higher energy consumption [22,23]. In turn, high energy consumption increases costs and thus reduces the profitability and efficiency of cloud service providers [8,9]. Meanwhile, end-users and cloud service providers want their services to be provided at a lower cost and time [24][25][26]. Cloud end-users generally anticipate completing their tasks without any delay, whereas cloud providers seek to reduce the energy cost, which constitutes as one of the major costs in the cloud service environment. However, lowering energy consumption increases the makespan and leads to customer dissatisfaction [27]. Most existing techniques for minimizing cost and time are designed for traditional computing platforms, which cannot be applied to cloud computing platforms with resource management methods [13]. In this paper, we attempt to minimize makespan and energy consumption based on the importance factor determined by the enduser and the provider, by the utilization of resource allocation in a queue created by four heuristics methods and the grasshopper algorithm. e most appropriate method to implement each task is then chosen using the roulette wheel.
To solve the above problems, this paper makes five main contributions: (i) Energy-aware run-time scheduler for scheduling of workflow.
(ii) Provides a methodology to automatically generate the required power consumption profile.
(iii) Selects the best sorting method to perform any task between a heuristic method and grasshopper algorithm to increase productivity.
(iv) Offers a model to estimate the energy consumption and makespan of the task.
(v) Evaluates the trade-off between energy saving and makespan for different scenarios.
e article is structured as follows: Section 2 provides an overview of related work, and Section 3 states the problem. Section 4 describes the proposed method. Section 5 expresses the evaluation of the proposed method. e time complexity analysis for the proposed algorithm and MHRA algorithm is presented in Section 6, and finally, Section 7, discusses the conclusion and future work.

Related Works
Today, cloud computing plays an essential role in academia and industry [28]. However, due to high customer demand and limited resources, it is necessary to transfer a small amount of work to data centers [29]. is process helps to complete the applications provided to data centers through more flexible and inexpensive use of resources. Because there are so many tasks on cloud servers and resources in the cloud are heterogeneous [30], scheduling tasks in a cloud environment is a consistent challenge. In this section, we briefly describe some existing research in the field of scheduling on the topic of allocating resources to tasks in cloud environments. Barzegar et al. [2] introduced a timeand energy-aware scheduling algorithm called EATSDCD. e paper presents a method that uses a combination of two clustering and duplication strategies and the use of slack time, to schedule DAGs on data center processors with dynamic voltage and frequency scaling capability. In the first phase, by intelligently combining the two strategies of duplication and clustering, the focus is placed on reducing the makespan and energy consumed by processors in an effort to execute DAG while satisfying the throughput constraint. en, the main idea of the algorithm is to reduce the maximum energy consumption in the second phase. After calculating the slack time for each task and then determining the critical path, the slack time is distributed between the set of noncritical dependent tasks in a cluster, and the frequency of processors with dynamic scale scalability then performs the dependent task set. en, the frequency of DVFS-enabled processors is scaled down to execute noncritical tasks as well as idle and communication phases, without increasing the makespan of the tasks. Juarez et al. [22] introduced an energy-aware timing algorithm for task-based applications called the multiheuristic resource allocation algorithm (MHRA). e objective of this scheduling algorithm is to minimize the function of the target that combines energy consumption and makespan. ese criteria are combined with an importance factor determined end-users and service providers to define which is more important for their objectives: energy saving or makespan. e authors also proposed a model for estimating the energy consumption required to execute efficiently applications on set of resources. Safari and Khorsand [23] investigated the energyaware schedule algorithm for a workflow with limited time intervals in a homogeneous cloud environment. ey were able to reduce makespan, particularly when the number of tasks was large. is offers also a promising way to reduce energy consumption that takes into account time limits and service quality as a service level contract. Sofia and GaneshKumar [27] proposed a multiobjective algorithm based on nondominated sorting genetic algorithm (NSGA-II). Minimizing the energy consumption and makespan from the cloud service, the main objective was NSGA-II. In order to control the energy consumption efficaciously, the DVFS system was incorporated into the optimization procedure, and a set of nondomination solutions are obtained and used. Furthermore, the artificial neural network (ANN), which is a successful machine learning algorithm, was used based on the features of the resources available in it. e authors proved that the number of generations was critically reduced by using ANN in the optimization procedure. Additionally, the computational cost was minimized by optimally choosing the control parameters of genetic algorithm (GA), such as the number of generations, population size, crossover, and mutation probability. Yang et al. [31] proposed an energy-aware importance ratio-based stochastic task scheduling (EISTS) algorithm, which maintains a good balance between the optimization of makespan and energy consumption. e authors claimed that the algorithm achieves a shorter makespan when the importance ratio of makespan to energy consumption is high and a lower energy consumption when the ratio is low. Voorneveld [32] proposed an algorithm based on the Pareto solution that is similar to our method of using the objective function. However, their proposed combination is that of energy consumption and task makespan. In contrast, the method proposed in this paper considers makespan and energy consumption for various elements such as cores, virtual machines, and nodes. Ben Alla et al. [33] proposed efficient energy-aware task scheduling with deadline-constrained in cloud computing (EATSD). e main objective of their proposed solution is to reduce the energy consumption of the cloud resources, consider different end-user priorities, and optimize the makespan within the deadline constraints. ey achieved good performance by minimizing the makespan, reducing energy consumption, and improving resource utilization while meeting deadline constraints. Peng et al. [34] proposed an online resource scheduling framework based on the Deep Q-network (DQN) algorithm.
e framework was able to realize a trade-off between the two optimization objectives of energy consumption and task makespan, by adjusting the proportion of the reward of different optimization objectives. is framework could effectively be used for a trade-off of the two optimization objectives of energy consumption and task makespan. Yao et al. [35] proposed an energy-aware scheduling algorithm called EnMORL. eir objective was to simultaneously minimize the makespan and energy consumption while meeting budget constraints. is method is based on RCB and can be applied to other workflow scheduling problems with budget constraints. Singh et al. [36] proposed an efficient metaheuristic approach called energy-efficient workflow scheduling (EEWS) for minimizing makespan and maximizing energy conservation while scheduling workflows. e results of EEWS were better than both HCRO and MPQGA, in terms of makespan, conserved energy, and fitness value. Belgacem et al. [37] proposed a dynamic resource allocation model to meet customer demand for resources with improved responsiveness. eir model also proposes a multiobjective search algorithm called the spacing multiobjective ant lion algorithm (S-MOAL) to minimize both the makespan and the cost of using virtual machines. Its impact on energy consumption with the dynamic management of resources was studied through the use of unused virtual machines (VMs), which indicated that their approach would save energy. Yadav et al. [38] proposed adaptive heuristic algorithms, namely, least medial square regression, for minimizing energy consumption with minimal service level agreement (SLA). e main idea is overloaded host detection and minimum utilization prediction for VM selection from overloaded hosts. Baker et al. [39] implemented a new multicloud service broker called Cloud-SEnergy for locating, invoking, and integrating the most energy-aware services for multicloud service providers. Table 1 summarizes the previous studies on scheduling policies for allocating tasks on processors with different objectives.

Problem Statement
Modern computing centers and data centers consume large amounts of energy, which is mainly derived from conventional energy generated from fossil fuels. For example, a medium-sized data center, such as a university data center, consumes about 80,000 kilowatts of electricity.
In this paper, the best heuristic scheduling (BHS) algorithm for allocating resources to the tasks in the queue created by sorting tasks based on heuristic and grasshopper algorithms and selection of the most appropriate method for performing each task based on the importance factor determined by the end-user or service provider is recommended to achieve a suitable solution in a timely and economic manner. e proposed algorithm has a dualpurpose objective function: to reduce energy and makespan consumption according to the importance factor determined by the resource provider or end-user. e symbols used in this paper are summarized in Table 2.

Problem Models.
e S-sequence is first considered as a DAG by evaluating the dependencies between parts of the tasks in real-time. G � (T, D) represents this graph, where T is the set of tasks and D is the set of link analysis. For the task i, j, T link analysis in the form (i ⟶ j) determines the dependence between the tasks i and j, so that task j must be executed after the end of task i. In this case, i is the parent and j is the child; a node can have several parent nodes. e node j starts to run when all of its parents are fully executed. A cloud platform is considered as a set of nodes � n 1 , n 2 , . . . , n n , whereby each node is responsible for managing a set of virtual machines VM � vm 1 , vm 2 , . . . , vm n }, where the virtual machine k is given from node m by Vmk. Each virtual machine k has a set of processing cores C mki � c mk 1 , c mk 2 , . . . , c mkn , in which the core i from the virtual machine k is represented by C mki . Finally, Scientific Programming Table 1: Previous studies on energy-aware task scheduling techniques.

Authors Proposed method Target
Barzegar et al. [2] EATSDCD Reducing the makespan and energy consumed by the processors to perform the tasks in the DAG Juarez et al. [22] MHRA Minimize the energy consumption and makespan Sofia and GaneshKumar [27] NSGA-II Minimizing the energy consumption and makespan from the cloud service Yang et al. [31] EISTS Balance between optimization of makespan as well as energy consumption Ben Alla et al. [33] EATSD Reduce the energy consumption of the cloud resources and optimize the makespan under the deadlines constraints Peng et al. [34] DQN e framework for trade-off optimization energy consumption and task makespan Yao et al. [35] EnMORL Simultaneously minimize the makespan and energy consumption while meeting the budget constraint Singh et al. [36] EEWS Minimizing makespan and maximizing energy conservation while scheduling workflow Belgacem et al. [37] S-MOAL Minimize both the makespan and the cost of using virtual machines Table 2: Symbols used in this paper.

Symbol Description c mki
Core i from the virtual machine k S mki Set of schedules for all cloud resources C max Makespan E flow Energy flow α Importance factor determined by the end-user or service provider task j mki Task j assigned to core i of the virtual machine k in the node m time init j Initial time of the task j time setup j Setup time of the task j time end j End time of the task j T Prej A set of prerequisite tasks for the task j time pre j Start time of the task j prerequisite time end pre End time of task j prerequisites time transfe Data transfer times required to perform a task that is outside the virtual machine time exec j Processing time of a task j in the core i of the virtual machine k of the node m e taskmki Energy consumed by a task j e transfer mk Energy consumed by the data transfer of the task j e vmk Energy consumed by the virtual machine k e task mk Energy consumption by various tasks j in a virtual machine k e nm Energy consumption per node e net Average data transfer power in cloud infrastructure P cmk i Power proportional to the use of a specific core in a virtual machine P upVmk Power consumed to up a virtual machine P down  Lower bound on the dimension D the scheduling problem involves searching for the S scheduling. is indicates the order in which each task j is performed in the available set of resources. us, the scheduling for C mki is shown by S mki , which is presented by equation (1). is shows that the n task is executed to core i of the virtual machine k from the node (j n ⟶ C mki ). e complete solution S can be represented by equation (2), as a set of schedules for all cloud resources: (2) In the case of scheduling, the search process for scheduling tasks is guided by two objectives: (1) To improve the energy efficiency by looking for the best positions of tasks in resources such that the energy consumed by the implementation of the whole set of tasks is minimized. (2) To improve executive performance by searching for the allocation of resources that minimize the makespan.
However, a balanced relationship between energy efficiency and makespan provides a solution that minimizes energy consumption and increases makespan. e objective of the proposed scheduling strategy is to reconcile the two objectives. erefore, we propose a function that combines energy consumption and makespan, with C max or makespan and E flow as the energy flow with a coefficient of significance defined by α, to determine for the end-user or resource provider whether energy or makespan is more important. Accordingly, the proposed scheduling problem is modelled as an optimization problem, which seeks a solution that minimizes the objective function shown in the following equation: e objective function is composed of two main terms E flow (S) and C max (S), where E flow (S) is the energy consumed by the implementation of solution S and C max (S) is the makespan, defined as the maximum time taken for the last task to leave the system.
To balance the objective function, the adaptive weighted sum method is applied, which introduces a weight factor α, where 0 ≤ α ≤ 1, to indicate which term is more important for the end-users or service providers. However, makespan and total energy flow have different units. e makespan is calculated in seconds, while energy consumption is calculated in watt-hours (Wh). Two factors, c sf and E sf , have been used to normalize energy flow and makespan that are never equal to zero. As explained, the makespan is defined by the last task that leaves the system, and estimating E flow is challenging. e next section provides further details about the model used to estimate E flow for the S schedule.

Energy Model.
e objective function presented in the previous section requires the calculation of the exponential and energy for the solution of a given schedule. rough this scheduling solution, an energy-aware scheduler can extract the following times to estimate the makespan and energy consumption: Another critical piece of information for energy calculation is the power profile for different sources. For each source, we must calculate the following values: (1) P cmki is the average power consumed by core i of a virtual machine k in node m. (2) P up Vmk and P down Vmk are the average power consumed by the virtual machine when the service provider creates and destroys the virtual machine k in node m. (3) P idle is the average power consumed by node m in the idle mode. In other words, the power consumed is such that the service provider is not in control of the virtual machines and only the operating system services are running. (4) P net nm is the average power required to transmit data through cloud infrastructure. (5) PUE is the average power consumed by the support system (UPS, coolers, etc.).
Finally, the energy consumed by each parameter can be estimated by multiplying the duration of the different events by the corresponding average amount of power.

Energy Consumed by Each Task.
To calculate the energy consumed by task j assigned to the core i of the virtual machine k in the node (task j mki ), the initial time (time init j ), setup time (time setup j ), and end time (time end j ) of each task must be estimated.
Task Start Time. Each task j has a set of pretasks (T pre ) L that must be completed before task j begins. erefore, the minimum start time for task j depends on the longest end time of one of the previous tasks L (time pre j ). Calculated according to the following equation, a task that has no precedent timepre j is equal to zero: e task j is the first task assigned to a core, and the start time is directly determined by the preceding end time. However, if the tasks are assigned before this to a data center, Scientific Programming the start time depends on the end time before the task, shown by time end j .
In this case, the start time of the task is expressed by the maximum value of the most significant preceding end time (time pre j ) and the maximum end time of the previously assigned tasks in the same core c mki , that is, t ∈ T mki . Finally, j is the first task assigned to the virtual machine k of the node m (Vmk); the start time depends on the setup time in Vmk.
If this time is more than the preceding maximum end time, the task start time (time init j ) will be considered equal to setup vmk . Calculation of the start time of task j is shown as follows: Task Setup Time. Before starting a task, the data required for the task must be transferred to the source where it is executed. is time is known as the setup time, denoted by time setup j . It depends on the proposed scheduling solution because the extent of data transfer depends on the source to which the previous tasks were assigned. erefore, the setup time for task j is equal to the sum of all the required data transfer times (time transfer vmk(f i ) ) outside the virtual machine: Task End Time. Task end time (time endj ) equals total task initial time (time init j ), task setup time, and task execution time j in core i of the virtual machine k from node m (time exec j ) and is calculated as follows: Energy Consumption of Each Task. e energy consumed by task j is represented by e taskmki j , which is estimated by the sum of the energy consumed by the data transfer of a task and the energy consumed by the task processing. e energy consumed by the data transfer is estimated by multiplying the time spent transferring the required data by the average power of the data transfer in the cloud infrastructure (P net ).
In contrast, the energy consumed by task processing is calculated by multiplying the processing time of work j with the average power proportional to using a special core in a virtual machine (P Cmki ), using the following equations: e taskmki j � e transfer mk + time exec j C mki × P Cmki .
Energy Consumed by Each Virtual Machine. e second parameter that must be calculated to estimate the energy flow is the amount of energy consumed by each virtual machine used in the cloud (Vmk). e energy consumed by the virtual machine k is denoted by e Vmk , which is calculated as follows: e Vmk � setup vmk × P up Vmk + e task mk + down vmk × P down Vmk . (10) is equation includes the amount of power consumed to start and shutdown the virtual machine k from node m, which is estimated by multiplying the time elapsed for it. Setup and shutdown times of the virtual machine are (setup vmk , down vmk ), with average power (P up Vmk , P down Vmk ). Energy consumption is calculated by the various tasks j in the virtual machine k as follows: Energy Consumed by Each Node. e energy consumed by a node (e nm ) is calculated based on the total amount of energy consumed by virtual machines when they are running and idle. e energy consumed by all of the virtual machines in a node is calculated as When the cloud infrastructure allows the node to be shutdown, all nodes running at the same time are equal to the makespan. Accordingly, the makespan of the node is shown as Once the makespan of the node is estimated, we can estimate the amount of energy consumption per node as follows: e nm � Run nm × P idle + e vm .
3.1.3. Makespan and Energy Flow. When we calculate the energy required for tasks, virtual machines, and nodes, we must calculate C max and E flow . Makespan can be calculated using equation (15). It is based on the sum of the end times of the last task j performed in the cloud and the shutdown time of the virtual machine in which this task is performed: e energy flow (E flow ) is calculated as equal to the sum of the energy consumed by each node in power consumed by the support systems (e.g., the cooling system and UPS), which is calculated using the following equation:

Proposed Method
e best heuristic scheduling (BHS) is to schedule resources and allocate them to tasks and thus generate the solution of the high-quality scheduler in a real period. e BHS algorithm offers a step-by-step solution to achieve the desired goal.
e stages of the proposed heuristic algorithm are shown in Figure 1.
e ideal heuristic scheduling algorithm receives the DAG, which includes the set of tasks to be performed on cloud processors as input. e algorithm automatically analyzes the DAG and implements a set of free tasks that are not required to be performed.
is algorithm automatically analyzes the DAG and a set of free tasks that do not have prerequisites or with prerequisites that have been executed and can be executed in parallel with specifying the implementation. e main algorithm (BHS) then proceeds as follows: first, the tasks are sorted based on the heuristic methods and the grasshopper algorithm. ey are placed in the corresponding list of that method. is step generates five list types, before progressing to the next step to allocate resources to the task. In this step, the resources assign necessary tasks by resource allocation cost function algorithm (RACF), according to energy profiles of the tasks based on the amount of memory and the core to perform each task. e resource is allocated, and the amount of objective function for each of the five lists formed in the previous step is calculated based on the importance factor determined by the end-user or service provider. e next step is to estimate the amount of makespan and energy consumed for each of the five lists. In the last step, using a roulette wheel, the amount of the calculated objective function is examined for five types of lists, and for each of the five possible types of lists to be executed, one of them has the amount of the objective function to perform the desired task. More optimal (minimum) value is selected.

Grasshopper Algorithm.
e grasshopper belongs to the insect family. Grasshoppers are known as pests because they damage agricultural products. Although they are usually found in nature individually, they can also be found together in one of the largest groups of all creatures. e size of these groups may be enormous and can be a nightmare for farmers. e mathematical model of the grasshopper algorithm mimics the behavior of grasshoppers in nature to solve the optimization problem. e simulation results show that the locust algorithm is able to provide better results compared to known algorithms and recent literature. Simulation results on real problems also proved that the grasshopper algorithm is able to solve real problems with unknown space [40].

Explanation of Grasshopper Behavior by Mathematical
Relations.
e mathematical model used to simulate the behavior of grasshoppers is presented in the following equation: X i is the location of the grasshoppers i, S i is the social interaction between grasshoppers, G i is the gravitational force between grasshoppers, and A i is the movement of the wind. Since grasshopper nymphs only walk on the ground and do not jump, the gravity of the Earth does not affect them. While wind movement has the most significant effect on nymphs, we can ignore them and consider only adult grasshoppers: where d ij is the distance between grasshopper i and grasshopper j and is calculated as d ij � |x j − x i |, S is a function that shows the power of social interaction in a high relation, and d ij � ((x j − x i )/d ij ) is a unique vector from grasshopper i to grasshopper j. e S function, which represents social interaction, is calculated by where f is the gravity intensity and l is the length of the absorption. e values of f and l should be 1.5 and 0.5, respectively, to obtain an optimal answer. e gravitational relation between the grasshoppers is also calculated as e gravitational constant is g, which is usually considered to be 9.8 or 10, and e indicates the unit vector toward the center of the Earth. e wind displacement relation is also calculated from

Scientific Programming
where u is the thrust constant and e w is the unit vector that determines the direction of the wind. e sum of the relations mentioned above determines the value of X or the next movement of the grasshopper: e −r − s(r) � fe ((− r)/l) and N is the number of grasshoppers. e modified version of this relationship is intended to optimize issues: where ubd is the upper bound in dimension D, lbd is the lower bound in dimension D, s(r) � fe ((− r)/l) − e − r , T d is the amount of D after the target (the best solution that has been determined up to that point), C is a decreasing coefficient, and S is similar to equation (17).
To balance the search and increase the optimization, it is necessary to reduce the C parameter proportionally or the number of iterations. In this mechanism, as the number of repetitions increase, optimization increases. e C coefficient reduces the comfort zone by the number of repetitions and is calculated as where C max has the highest value, C min has the lowest value, I represents the current repetition, and L represents the maximum number of repetitions.

Heuristic Methods Used in the Proposed Method.
In the proposed method, in addition to the grasshopper algorithm, the following heuristic methods are used to sort the tasks: (1) LPT (longest processing time): the highest priority is given to a task whose processing time is longer than the others. (2) SPT (shortest processing time): the highest priority is given to a task whose processing time is shorter than the others. (3) LNS (last number of substantial): the highest priority is given to tasks that have more pretasks. (4) LSTF (least slack time first): the highest priority is given to a task that has more slack time than the others.

Evaluation of the Proposed Method
Data analysis is particularly important for the validity of hypotheses for any research. e simulation environment used to evaluate the proposed method is the MATLAB tool. We have installed the MATLAB tool on an Asus notebook with an Intel core i7-A540UP 2.4 GHz CPU with 8 cores and 4 GB memory. In this section, we review the results of implementing the proposed method.

Evaluation Parameters.
To evaluate the proposed method, four virtual machines from Intel and AMD were used, with characteristics as listed in Table 3. In addition, tasks with parameters having the values listed in Table 4 are used.

Best Heuristic Scheduling (BHS) Algorithm.
e BHS algorithm is designed to identify the optimal scheduling of tasks assigned to the cloud and to estimate the optimal possible amount of energy for consumption and the makespan based on the importance factor determined by the end-user or service provider. e pseudocode of BHS is shown in Algorithm 1.
is algorithm includes the number of search factors or number of grasshoppers, the number of repetitions of the algorithm, the lower bound and the upper bound, the number of dimensions and features that the grasshopper is supposed to optimize. e resource allocation algorithm and the estimation of the objective function are expressed in Algorithm 2. e virtual machines are received as input and in return for the optimal value of the objective function, and the type of sorting returns the tasks to be executed as output. In line 2, the grasshoppers are given an initial value in such a way that N, or the same number of grasshoppers, is considered to be a position equal to the set of tasks to which the resource is to be assigned. Lines 3 to 5 are investigated based on the objective function to determine whether the implementation of line 2 is appropriate. Lines 6 to 19, based on the grasshopper algorithm formulas, calculate the distance between the grasshoppers considered in the previous section until reaching the target grasshopper that has the lowest possible value, and select the best grasshopper, which represents the best way to perform tasks in this way. From lines 20 to 24, resources are allocated to the lists formed by the grasshopper method and four heuristic methods using the RACF algorithm, and the value of the objective function is calculated for each list. In line 25, out of five values of the objective function obtained in the previous section, the most optimal value should be selected, using a roulette cycle for each of the five possible lists to be considered. e best method (the method that has the lowest amount for the objective function) is then selected to perform each task. In lines 26 to 32, one of the five lists from the previous section is selected since a list of tasks is provided while the number of tasks is required. e number of elements in the identifiers list is then placed in an array called the ID. Line 34 adds one to the number of repetitions of the algorithm, and this cycle continues until the best possible response is found. 8 Scientific Programming

Resource Allocation Cost Function.
Resource allocation cost function (RACF) algorithm is used to allocate resources to tasks and calculate the amount of objective function expressed by Algorithm 2. In this algorithm, the list of tasks, resources, and significance coefficient is received as input and the amount of objective function, energy consumption, and makespan is estimated and finally returned as output. e first line of this algorithm is related to the introduction of the function, which receives a list of tasks, virtual machines, and importance factors and returns the amount of the objective function, energy consumed, and makespan as the output of the algorithm. In line 2, there are tasks that have not yet been processed or tasks that have been reserved and that are running, as long as these two modes are in place, the steps are repeated. Line 3 investigates whether resources should be allocated to tasks or should wait for a task to be completed. In line 4, if it has to be allocated to the resource task, it will consider that task as the current task. Lines 5 and 6 examine the first to the last virtual machine, to find the appropriate virtual machine with the required amount of RAM and core to perform the task, and most importantly, that virtual machine is switched on. In lines 7 and 8, the virtual machine assigns the desired task. Line 9 calculates the makespan (end time) of the task. In line 10, the task enters the reservation list. In line 11, the makespan is calculated. In lines 12 to 16, the energy consumed during data transfer, the energy consumption of each task, the energy consumption of each virtual machine, the energy consumption of each node, and finally energy consumption are calculated according to the equations described in Section 4. Lines 21 to 27 proceed when the task at hand is completed, and the resources allocated to it must be released. At the end of line 31, the amount of the objective function expressed in equation (3) is calculated.

Evaluation Results.
On evaluating the proposed method, heuristic methods and grasshopper algorithms were used to sort the tasks each time they were performed. Based on the proposed BHS algorithm, a sorting method was selected for each task, resulting in the most optimal response. is has improved the proposed method compared to the MHRA method.

Effect of the Importance Factor on Energy Consumption
and Makespan. In this section, for 1000 tasks, we changed the importance factor (α) from 0.0 to 1.0 in each step by 0.1. According to the results of the LPT exploratory method shown in Figure 2, performing this task is more appropriate than other methods and provides more optimal results. As shown in Figure 2, when the importance factor reaches 1.0, energy consumption increases to the maximum possible value of 3584 Wh, while the makespan decreases to the minimum possible value of 15,000 sec. When the importance factor reaches 0.0, the energy consumption decreases to the minimum possible value of 2541 Wh, while the makespan increases to the maximum possible value of 16,298 sec. erefore, as the importance factor increases from 0.0 to 1.0, the amount of energy consumption increases, while the makespan decreases. By increasing the importance factor, more resources are used to speed up the tasks. It can be concluded that when the energy consumption is more important for the end-user or service provider, the importance factor should be set to 0.0. Otherwise, when makespan is more important, the end-user or service provider must set the importance factor to 1.0. As a result, proper selection of the importance factor is crucial.

Choice of Importance Factor When Both Items (Energy Consumption and Makespan) Are Important to the End-User
or Service Provider. In this section, the amount of energy consumption and makespan with different importance factors are reviewed and compared to determine the importance factor according to Figure 3, which shows the makespan and energy consumption in an acceptable state for the end-user or service provider.
As mentioned in the previous section, when the energy consumption is more important for the end-user or service provider, the importance factor is equal to 0.0, and when makespan is more important, the importance factor is equal to 1.0. According to Figure 3, with an importance factor of 0.7, the amount of energy consumed is equal to 3017.9 Wh, and the makespan is 15,399 sec. e graph of both cases somewhat comes down, which indicates that the amount of energy consumed and makespan are both reduced. In summary, when both power consumption and makespan are important to the end-user or service provider, the importance factor should be 0.7.

Comparison of the Proposed BHS Method with MHRA.
In this section, we review and compare the energy consumption and the proposed BHS method with the MHRA method. For this purpose, the implementation of 1000 tasks with different coefficients of importance and the LPT heuristic method for two scheduling methods was analyzed.   Figures 4 and 5 and suggest that the proposed BHS method returns more optimal results than the MHRA method.
According to the results obtained in the previous sections, the lowest energy consumption with an importance factor of 0.0 for the BHS method is equal to 2500 Wh and for the MHRA method is equal to 3113.6 Wh. ese results show that, in the proposed BHS method, energy consumption has decreased by 19.71%. In the worst case, for energy consumption, where the importance factor is 0.1, the energy consumption in the BHS method is equal to 3584 Wh and, in the MHRA method, is equal to 3812 Wh, which in this case also decreased by 6.51%. It can be concluded that the BHS method, using the least amount of available resources, causes significant energy storage and is suitable for reducing energy consumption.

Time Complexity Analysis
We want to analyze the time complexity of algorithms presented in the previous sections.

Analysis of BHS Algorithm.
is algorithm is designed to find the best task schedule based on the importance factor determined by the user or service provider. Lines 3 to 5 run the number of grasshoppers, i.e., |N| times of the RACF function to allocate resources to tasks and calculate the target function. Also, the innermost for loop with index j (lines 12 to 16) is |N| times performing the next grasshopper position estimation operation according to its current position. For loop with index k (lines 11 to 18) n/2 times, perform checking and sorting operations. Lines 20 to 24 also call the RACF function to calculate the value of the target function of the generated lists, whose complexity is |n| × (|m| + |m|). Given that these instructions are in the for loop with index i, where | N| repeats this operation, so the number of executions is equal to |N| × (|N| + |N| + |n| × (|m| + |m|)). Also, the while loop in line 7 has a max iteration number of |L| times performing the entire operation above, so the number of runs is equal to |L| × (|N| × (|N| + |N| + |n| × (|m| + |m|))), and therefore, the complexity of the BHS algorithm is equal to O(L|N 2 |+| N nm |).

Analysis of RACF Algorithm.
is algorithm is used to allocate resources to the tasks in the lists created in the BHS algorithm and to calculate the value of the objective function to execute each list. Assuming that the number of virtual machines is equal to m, then for loop with index j (lines 5 to 19), which performs the operation of allocating resources to the tasks in the list and calculating the amount of energy consumption and makespan, it is executed |m| times, and for loop with index r, which performs the operation of freeing up the resources allocated to the tasks that are on the reserve list and have been completed, it is also executed |m| times. Given that both for loops are in an external while loop and assuming that the number of list elements is n, the while loop is |n| runs when the total number of operations is equal to |n| × c(|m| + |m|). As a result, the complexity of the RACF algorithm is equal to O(|nm|).

Analysis of MHRA Algorithm.
e MHRA algorithm in the paper [22] consists of 5 nests for loops. e for loop in   line 2 is executed in the number of heuristic methods K � 4 times. Also, the number of iterations in two for loops in lines 3 and 5 is, respectively, 10 and |n| times. "|n| is equal to the number of nodes in the DAG." In addition, the for loop in line 7 where task sorting operations can be done at times |n| is based on the exploratory method. Also, the for loop in line 9 has the number of cores |m| times performing resource allocation operations to tasks. erefore, the number of executions is equal to 4 × 10 × (|n| × (|n| × |m|)), and therefore, the complexity of the MHRA algorithm is equal to O(|n 2 m|).

Conclusions and Future Work
In this paper, we have presented a dual-objective scheduling algorithm that is aware of makespan and energy consumption in order to allocate resources to tasks and to sort tasks, based on heuristic methods and grasshopper algorithm. Furthermore, the most appropriate method to execute each task is selected based on the importance factor determined by the end-user or service provider, set by using the roulette wheel in the cloud. e proposed BHS algorithm minimizes the target function according to this importance factor, taking into account the start times, setup times, and end times for virtual machines and energy profiles.
To implement the desired algorithm, MATLAB simulator was used with a DAG generated for 1,000 tasks having different coefficients of importance and four virtual machines from Intel and AMD. e results of the assessment indicate that, to execute any task based on the importance factor determined by end-user or service provider, a specific type of heuristic or grasshopper method is appropriate. e response is more efficient compared to the rest of the methods. It can also be concluded that when energy consumption is more important for the end-user or service provider, they must set the importance factor equal to 1.0. When the makespan is more critical, the end-user or service provider must set the importance factor equal to 0.0, and when both the energy consumption and the makespan are critical, they must set the importance factor equal to 0.7. erefore, determining the importance factor is very important. e evaluation results show that the proposed algorithm has reduced energy consumption by 19.71% compared to MHRA and has reduced the makespan by 56.12% when energy consumption is of high importance. Overall, selecting the optimal method for sorting and performing each task can significantly reduce the makespan and amount of energy consumed, as well as the costs involved.
Future research should investigate parameters such as reliability, performance enhancement, and security enhancement for each task, based on the importance factor set by the end-user or service provider.

Data Availability
e data used to support the findings of this study are available on request to the corresponding author.

Conflicts of Interest
e authors declare that they have no conflicts of interest.