**5.2 Population initialization of RGSGCS algorithm**

One of the important steps in GA is initialization of population. This initialization supports GA to find best solutions within the available search space. In this step, in GA, if bad solutions are generated randomly, the algorithm provides bad solutions or local optimal solutions. To overcome the posed problem, generating individuals using well-known heuristics in the initial step of the algorithm is required. These heuristics generate near-optimal solutions and the meta-heuristic algorithm combines these solutions in order to obtain better final solutions.

Scheduling heuristics such as Min-Min, Minimum Completion Time (MCT), Minimum Execution Time (MET) (Braun et al., 2001), are proposed for independent tasks. Most of these heuristics are based on the following two assumptions.

First, the expected execution time *EETij* is deterministic and does not vary with time.

Second, each task has exclusive use of the resource. Traditional MCT heuristic assigns each task to the resource that completes it earliest. The new algorithm, Random-MCT, is described below: For the first tasks in the grid, which their number equals to total resources number in the grid, the resources are assigned randomly. The remaining tasks in the grid are assigned according to earliest finishing time. Where *RTj* is the Ready Time of resource *j*. The time complexity of Random-MCT heuristic is O(*M*.*N*). After completion of RGSGCS's initialization, the evaluation phase is introduced.

(a) Roulette Wheel Selection

Fig. 6. Example of Roulette Wheel Selection and Rank Selection

**5.4 Rank Roulette Wheel Selection (RRWS) of RGSGCS algorithm**

part of roulette wheel then spin the wheel *n* time to select *n* individuals.

the best will have fitness value equals to N (Obitko, 1998).

Wheel Selection (RWS).

following equation:

**5.4.2 Rank Selection (RS) of GA**

**5.4.1 Roulette Wheel Selection (RWS) of GA**

Task Scheduling in Grid Environment Using Simulated Annealing and Genetic Algorithm 97

This phase chooses chromosomes from a population for later breeding (crossover). RRWS combines the advantages of two types of selections, namely, Rank Selection (RS) and Roulette

GA uses proportional selection. The population of the next generation is determined by *n* independent random experiments; the probability that chromosome *xi* is selected from the pool (*x*1, *x*2, ··· , *xm*) to be a member of the next generation at each experiment is given by the

> *RP*(*c*) = *Fitness*(*c*) ∑*<sup>N</sup>*

This process is also called roulette wheel selection. Where each chromosome of the population is represented by a slice that is directly proportional to the chromosome's fitness. A selection step is a spin of the wheel, which in the long run tends to eliminate the least fit population chromosomes. Figure 6 (a) explains the selection method of (RWS) (Obitko, 1998). A roulette wheel where are placed all chromosomes in the population, every chromosome has its place big accordingly to its fitness function. The procedure now is to assign to each chromosome a

RWS has problem when the fitness value differs very much. In RS (as shown in figure 6 (b)) the worst value has fitness value equals to 1, the second worst value equals to 2, ··· , etc, and

Therefore, the RGSGCS's selection process is accomplished by applying RRWS (Wael et al., 2009c; Jadaan et al., 2009), RRWS orders the chromosome's fitness values of population in ascending order, and save this order in array, say *Rank*. After that, it associates the probability shown in equation( 7) with each individual chromosome, calculates cumulative proportion of each chromosome, and selects solutions from the population by repeated random sampling

(b) Rank Selection

*<sup>n</sup> Fitness*; (6)

 

#### **Algorithm 1** Random-MCT


#### **Algorithm 2** RGSGCS

1: Generate Initial Population *P* of size *N*1 using Random-MCT (algorithm 1). 2: **for** *g* = 1 to *MaximumGenerations* **do** 3: Calculate the fitness of each chromosome using equations (3, 4 and 5 ) 4: Generate offspring Population from *P* 5: {Rank based Roulette Wheel Selection 6: Recombination and Mutation 7: Calculate the fitness of each chromosome using equations (3, 4 and5)} 8: (elitism) Select the members of the combined population based on minimum fitness, to make the population *P* of the next generation.

9: **end for**

#### **5.3 The evaluation phase of RGSGCS algorithm**

The evaluation phase evaluates the quality of resulted schedule depending on a fitness equation. The fitness equation must be devised to determine the quality of a given chromosome instance and always returns a single numerical value. In this chapter, the fitness function is the makespan, i.e., the minimum completion time of the last finishing task. In other words, makspan is the schedule length. The main goal is to maximize the throughput of the grid by minimizing makespan through an intelligent load balancing. The makespan is calculated using the equations 3 and 4.While the fitness function is expressed as in equation 5.

$$\mathbf{C}\_{\mathfrak{M}} = \sum\_{\mathfrak{n}} EET\_{\mathfrak{n},\mathfrak{m}} \tag{3}$$

$$\text{makespan} = \text{Max}\{\mathbb{C}\_m\}\tag{4}$$

$$fitness = makespan\tag{5}$$

Where *m* = 1, 2, ··· , *M*; *n* = 1, 2, ··· , *N*; *M* is the total number of resources; and *N* is the total number of tasks. *Cm* is the sum of *EET* of each task *Tn* assigned to resource *Rm*, which denotes the completion time of the last task on resource. After the completion of the evaluation Phase, selection phase is used.

Fig. 6. Example of Roulette Wheel Selection and Rank Selection

#### **5.4 Rank Roulette Wheel Selection (RRWS) of RGSGCS algorithm**

This phase chooses chromosomes from a population for later breeding (crossover). RRWS combines the advantages of two types of selections, namely, Rank Selection (RS) and Roulette Wheel Selection (RWS).

#### **5.4.1 Roulette Wheel Selection (RWS) of GA**

8 Will-be-set-by-IN-TECH

**Algorithm 1** Random-MCT

3: *Cij* = *EETij* + *RTj*

5: attach *Ti* to *Rp*

10: *Cij* = *EETij* + *RTj*

12: attach *Ti* to *Rp*

6: **end for** 7: **end for**

13: **end for** 14: **end for**

9: **end for**

selection phase is used.

**Algorithm 2** RGSGCS

1: **for** *Ti* = 1 *to M* tasks in the grid **do** 2: **for** all resources *Rj* in the grid **do**

8: **for** remaining tasks *Ti* in the grid **do** 9: **for** all resources *Rj* in the grid **do**

2: **for** *g* = 1 to *MaximumGenerations* **do**

4: Generate offspring Population from *P* 5: {Rank based Roulette Wheel Selection 6: Recombination and Mutation

**5.3 The evaluation phase of RGSGCS algorithm**

4: find resource *Rp* randomly for *Ti*

11: find resource *Rp* which will finish *Ti* earliest

1: Generate Initial Population *P* of size *N*1 using Random-MCT (algorithm 1).

3: Calculate the fitness of each chromosome using equations (3, 4 and 5 )

7: Calculate the fitness of each chromosome using equations (3, 4 and5)}

to make the population *P* of the next generation.

8: (elitism) Select the members of the combined population based on minimum fitness,

The evaluation phase evaluates the quality of resulted schedule depending on a fitness equation. The fitness equation must be devised to determine the quality of a given chromosome instance and always returns a single numerical value. In this chapter, the fitness function is the makespan, i.e., the minimum completion time of the last finishing task. In other words, makspan is the schedule length. The main goal is to maximize the throughput of the grid by minimizing makespan through an intelligent load balancing. The makespan is calculated using the equations 3 and 4.While the fitness function is expressed as in equation 5.

*Cm* <sup>=</sup> <sup>∑</sup>*<sup>n</sup>*

Where *m* = 1, 2, ··· , *M*; *n* = 1, 2, ··· , *N*; *M* is the total number of resources; and *N* is the total number of tasks. *Cm* is the sum of *EET* of each task *Tn* assigned to resource *Rm*, which denotes the completion time of the last task on resource. After the completion of the evaluation Phase,

*EETn*,*<sup>m</sup>* (3)

*makespan* = *Max*{*Cm*} (4) *fitness* = *makespan* (5) GA uses proportional selection. The population of the next generation is determined by *n* independent random experiments; the probability that chromosome *xi* is selected from the pool (*x*1, *x*2, ··· , *xm*) to be a member of the next generation at each experiment is given by the following equation:

$$RP(c) = \frac{Fitness(c)}{\sum\_{n}^{N} Fitness};\tag{6}$$

This process is also called roulette wheel selection. Where each chromosome of the population is represented by a slice that is directly proportional to the chromosome's fitness. A selection step is a spin of the wheel, which in the long run tends to eliminate the least fit population chromosomes. Figure 6 (a) explains the selection method of (RWS) (Obitko, 1998). A roulette wheel where are placed all chromosomes in the population, every chromosome has its place big accordingly to its fitness function. The procedure now is to assign to each chromosome a part of roulette wheel then spin the wheel *n* time to select *n* individuals.

#### **5.4.2 Rank Selection (RS) of GA**

RWS has problem when the fitness value differs very much. In RS (as shown in figure 6 (b)) the worst value has fitness value equals to 1, the second worst value equals to 2, ··· , etc, and the best will have fitness value equals to N (Obitko, 1998).

Therefore, the RGSGCS's selection process is accomplished by applying RRWS (Wael et al., 2009c; Jadaan et al., 2009), RRWS orders the chromosome's fitness values of population in ascending order, and save this order in array, say *Rank*. After that, it associates the probability shown in equation( 7) with each individual chromosome, calculates cumulative proportion of each chromosome, and selects solutions from the population by repeated random sampling based on cumulative proportion.

$$RP(c) = \frac{Rank(c)}{\sum\_{n}^{N} Rank};\tag{7}$$

takes the best chromosomes. After this phase, the algorithm continues to the next iteration.

Task Scheduling in Grid Environment Using Simulated Annealing and Genetic Algorithm 99

Time complexity analysis of RGSGCS algorithm can be analyzed step by step as shown in table 1. From table 1 time complexity of RGSGCS algorithm is expressed as: O(*Q*.*PS*.*N*.*M*). Where *PS* is population size, and *Q* is Maximum number of iterations of RGSGCS algorithm.

Selection O(*PS*<sup>2</sup> + *PS*.*log*(*PS*) + 2*PS*)

**7. Mutation based simulated annealing algorithm for minimizing makespan in grid**

SA is a global optimization technique. It derived from the concept of metallurgy which crystallizes the liquid to the required temperature. Traditional SA, as shown in figure 9 (Akella, 2009), explores globally, spending more time in regions which on average have fitter solutions. In the later stages, the search is confined to a small area, and SA optimizes within

Instead of population which is used in GA, two solutions are maintained in MSA algorithm

Interestingly, MSA works iteratively keeping two tentative chromosomes at every iteration. For the first iteration, single exchange mutation operator is applied to initial chromosome, with different genes to produce two new solutions. For the remaining iterations, First chromosome is generated from the previous one by applying single exchange mutation operator to it, while the second chromosome is generated by applying single exchange mutation operator to initial chromosome (generated by Random-MCT algorithm 1), and each one either replaces it or not depending on acceptance criterion. The acceptance criterion works as follows: the old and the new solutions have an associated makespan *Makespan*, determined by a fitness function. If the new solution is better than the old one, then it will replace it, if it is worse, it replaces it with probability P. This probability depends on the difference between their *Makespan* values and control parameter T named temperature. This acceptance criterion provides a way of escaping from local minimum. Therefore, the probability of moving to the new solution decreases exponentially as its fitness gets worse, and also temperature gets lower. Usually temperature is gradually decreased so that uphill

movements (for minimization problem) become less and less as the run progresses.

Phase Complexity Initialization O(*PS*.*M*.*N*)

Crossover O(*PS*.*N*) Mutation O(*PS*) Evaluation O(2.*PS*.*N*.*M*) Elitisim O(*PS* + *PS*.*log*(*PS*)) RGSGCS algorithm O(*Q*.*PS*.*N*.*M*)

The algorithm terminates after it reaches the maximum generations number.

**6. Time complexity analysis of RGSGCS algorithm**

Table 1. Time complexity analysis of RGSGCS algorithm

that area. In these final stages, it is similar to local search.

**computing systems (MSA)**

at a time.

RRWS determines how many and which individuals will be kept in the next generation. Next, crossover operator and mutation operator are explained.
