• No results found

A Hybrid Genetic Algorithm

3.4 New Methods for Service Selection

3.4.3 A Hybrid Genetic Algorithm

This section elaborates the hybrid genetic algorithm. This hybrid genetic algorithm utilises a knowledge-based crossover operator to handle constraints on inter-service dependence and conflict. The basic idea behind the knowledge- based crossover is that of copying all good genes in one parent individual p1

that have no conflicts with each of the other genes, this is a way of exploiting domain knowledge to its child, and copying the remaining gene values from the other parent p2 to the child, making the child always has less conflicts than

p1. The knowledge-based crossover is in essence a local improvement procedure

to eliminate conflicts for handling constraints on inter-service dependence and conflict. Another feature of the hybrid genetic algorithm is the use of a local optimiser to improve the solution quality of individuals in the population. Below

3.4 New Methods for Service Selection 79

introduces the hybrid genetic algorithm in detail.

Genetic Encoding

The hybrid GA still uses the same representation method (see Figure 8) as the penalty-based GA introduced in the previous section.

Fitness Function

The fitness function is the same as the one used by the penalty-based GA.

Genetic Operators

Unlike the crossover operator used in the penalty-based genetic algorithm and the repairing-based genetic algorithm, the crossover operator used in the hybrid genetic algorithm is a knowledge-based crossover operator. The crossover operator takes two parents, p1 and p2, and produces two children c1and c2.

When producing c1, the crossover operator firstly finds all the concrete web

service selections that do not have any constraints with any other concrete web service selections in p1and copies them to c1. The rest of the concrete web service

selections of c1 are copied from p2. Similarly, when producing c2, the crossover

operator firstly finds all the concrete web service selections that do not have any constraints with any other concrete web service selections in p2 and copies them

to c2. The rest of the concrete web service selections of c2 are copied from p1.

3 2 6 1 10 15 2 5

P1 6 1 10 15 P2 3 10 5 6 2 5 4 8

3 2 6 10 5 15 2 1 4 15

C1

Figure 3.4: Knowledge-based crossover

An advantage of the above crossover operator is that child c1 always has less

conflicts than parent p1, and child c2 always has less conflicts than parent p2. In

other words, a local improvement in terms of constraint violation times can be made by applying this crossover operator. This is because for a child individual of length equal to m, which was generated by copying all n (n < m) genes from parent p1that do have any constraints (obviously, p1has n − m genes that violate

constraints), and the remaining n − m copying from parent p2, the worst case is

that the number of genes that violate constraints in this child is n − m (only when all the n − m genes copied from p2 happen to violate constraints), equal to the

number of genes that violate constraints in parent p1. In most cases, the number

of genes that violate constraints in the child is less than n − m.

The mutation operator is the same with the mutation operator used in the penalty-based genetic algorithm and the repairing-based genetic algorithm (see Figure3.3).

3.4 New Methods for Service Selection 81

Local Optimiser

Given an individual solution, which may or may not be feasible, the local optimiser is used to optimise the individuals in the population. The local optimiser is used at the beginning of the genetic algorithm to improve the individuals in the initial population, which are randomly generated, and at the end of each generation to improve the individuals in the population.

The local optimiser improves the fitness value of an individual by increasing its overall QoS value and by reducing the number of constraint violations, if any, simultaneously. This is done by systematically checking all the concrete web service selections one by one to see if there exists an alternative concrete web service that gives the individual a better fitness value. If the fitness value is improved, then the current web service selection is replaced with the alternative concrete web service. According to the definition of the fitness function, when the fitness value of an individual increases either the overall QoS value increases, or the number of constraint violations, if any, decreases, or both. Thus, the local optimiser contributes to both maximising the overall QoS value and minimising the number of constraint violations of an individual.

An abstract web service may have many implementations, such as concrete web services. Although, if we check all the alternatives of a concrete web service selection it would be too time consuming. Each time we check an

alternative we need to re-calculate the new fitness value of the individual. Which is computationally expensive as the fitness function calculation involves a calculation of the response time transformed into the problem of computing the critical path of the workflow. Therefore, in order to reduce the computation time, the following strategies are adopted. If the current concrete web service selection does not violate any constraint, then we check the alternatives one by one in a decreasing order of their weighted QoS value. Once a better alternative concrete web service is found, we replace the current concrete web service selection with the alternative immediately and then move onto the next concrete web service selection. However, if the current concrete web service selection violates any constraints, we check through all the alternatives and pick up the alternative that gives the best fitness value. Doing this, we can strengthen the constraint violation repairing ability of the local optimiser.

In order to improve the computation time of the local optimiser, instead of sorting all the concrete web services for each of the abstract web services, they are sorted only once at the beginning of the genetic algorithm, before the local optimiser is invoked. Algorithm 5 is the algorithm description for the local optimiser.

3.4 New Methods for Service Selection 83

Algorithm 5: Local optimiser algorithm

1 randomly generate a sequence of abstract web services,

Wx1Wx2· · · Wxn

2 for x=x1 to xndo

3 if the concrete web service selection at position x does not violate

any constraintsthen

4 foreach concrete web service w of Wxdo

5 calculate the fitness value of the new web service selection

plan

6 if the concrete web service selection at position x does not

violate any constraintsthen

7 update the web service selection plan;

8 end

9 end

10 replace the concrete web service selection with the best

alternative

11 end 12 else

13 foreach concrete web service w of Wxdo

14 calculate the fitness value of the new web service selection

plan

15 if the new fitness value is greater than the old fitness value

then

16 replace the web service selection with the alternative

and exit

17 end

18 end 19 end 20 end

Algorithm Description of the Hybrid GA

Having defined the fitness function, genetic operators, initial population generation and local optimiser, the hybrid genetic algorithm for the web service selection problem is now presented as Algorithm6.

Algorithm 6: A hybrid genetic algorithm for the web service selection problem

1 randomly create an initial population of P opSize individuals,

P opulation

2 foreach concrete web service w of Wxdo

3 optimise it using the local optimiser described by Algorithm5and

then calculate its fitness value using the fitness function

4 end

5 while termination condition is not true do 6 select fit individuals for reproduction

7 apply the knowledge-based crossover operator to generate

offspring

8 apply the mutation operator to offspring

9 optimise each individual using the local optimiser described by

Algorithm5and then calculate its fitness value using the fitness function

10 end

Related documents