• Keine Ergebnisse gefunden

TheMapping Problemis a NP-complete problem and complex to solve. Therefore an approxi-mative solution to the problem seems reasonable by using a search algorithm that heuristically processes the search space. Therefore, a meta heuristic approach, more precisely a genetic algo-rithm approach, has been selected, since it is widely used and its effectiveness has been proven.

Generally, genetic algorithms can be used whenever problems have to be approximated due to the lack of efficient algorithms for exact computation. Genetic algorithms are inspired by the Darwinian law. Thefittest individuals, proven to have the ability to adapt best to changing en-vironmental conditions, have a high probability to survive and inherit its genes to subsequent generations of individuals. The Mapping Problem is solved as shown in Listing 6.1.

1 // main routine returning thefittest solution

2 defMPGA(num_iterations, k):

3 // initialize population with 20 individuals

4 complete_individuals[] = init_polulation(20)

5

6 while(i != num_iterations && QoS_solution <= QoS_max && best_since <= k) do

7 // assignfitness values to individuals

8 calculate_fitness(complete_individuals[])

9 // select individualsforrecombinationandmutation

10 selected_individuals[] = selection(complete_individuals[])

11 // recombine individuals

12 recombined_individuals[] = recombine(selected_individuals[])

13 // mutate individuals

14 mutated_individuals[] = mutation(recombined_individuals[])

15 // create individualsforthe next iteration step

16 complete_individuals[] = evaluation(complete_individuals[] + mutated_individuals[])

17 // increment loop counter

18 i++

6.7 Solving the M-TOP Mapping Problem 189

19

20 //returnthefittest solution

21 returnsolution = select_fittest(complete_individuals[])

Listing 6.1:Genetic Algorithm to solve the M-TOP Mapping Problem.

The algorithm runs until either the maximal number of iterations (num_iterations) is reached or the best individual is the same (best_since) sincekiteration steps. For both cases the solution’s additive QoS targets must be satisfied (QoS_solution<=QoS_max).

The challenge now is how to implement the single steps of the genetic algorithm to solve the Mapping Problemfinally. The solution is presented and discussed in the next sections.

6.7.1 Encoding of a Solution and Initial Population

Thefirst step is to define an encoding for the potential solution4. It defines the data structure on which recombination and mutation operations work. Individuals are value-encoded hav-ing the followhav-ing appearance: Mk ={V1, ..., Vm}. Mk represents an individual of the problem, where k is the index identifying a certain individual within the set of all individuals. Vi rep-resents a value for variable i where each variable is related to the respective operator by the index i which corresponds to the S-labeled slice index with 1 i ≤ |S-slices|. The domains of values for each variable corresponds to the domain that is defined by the list of candidate nodes for each operator, which is actually also defined by the S-labeled slice with indexi. The values are represented by valuescnodek Cknode representing candidate node IDs, identifying a candidate node. A value is unique within a single solution Mk which means that a candidate node is selected only once per individual (see Equation 6.4b).

The population is initialized randomly (by means of a uniform distribution) to spread the concrete setting of a specific solution, hopefully in the best way. As a starting population,20 potential solutions are generated. Also another value is possible. However, during our evalua-tion (see Secevalua-tion 6.8) this value has proven to provide good results with moderate computaevalua-tion efforts. The potential solutions generated in this step are the basis for all subsequent operations.

At this point it is not guaranteed that the potential solution generated so far do not violate any constraints as described in Section 6.6.

6.7.2 Fitness Definition and Selection Strategy

The dimension to measure the quality of a certain individual is given by the individuals’

fitness values. Thefitness value characterizes individuals and makes them comparable to each other. The fitness function calculates the fitness values. The objective function (which is referred to as fitness function for the rest of this work) mostly corresponds to the objective

4In the followingindividualwill be used as a synonym for apotential solution.

function defined in Equation 6.3a and satisfies Equation 6.4c. However, Equation 6.4a and Equation 6.4b must be satisfied. Thus the modifiedfitness function looks as follows:

o(CG) =max (" n

X

i=1

t(ci)

#

·oadd(CG)·sconn(CG)·sass(CG) )

(6.5)

Obviously, the solution must also build a connected solution graph. The candidate nodes and candidate links that are part of the solution must build a connected solution graph, denoted bysconn(CG). sconn(CG)returns 1iffthe solution graph is connected, otherwise a value0.5is returned which degrades the fitness value of this solution. Additionally, sass(CG) checks for the unique assignment of a candidate from the domain within a certain solution and returns1 if the assignment is unique and0.5, if not degrading thefitness value of this solution. Once we know the fitness of each individual, we have to select some for recombination and mutation where many different strategies exist.

The selection strategyelitismsaves the best individuals from the current iteration for future iterations. For the remaining individuals afitness proportional selection strategy seems promis-ing. Individuals having a lowfitness value will probably not satisfy additive QoS targets.

6.7.3 Recombination and Mutation

Recombinationcreates new alternatives in the search space from the individuals selected in the steps performed beforehand. Recombination combines two individuals to form new ones with characteristics from both. The point in question is where to define the recombination points. Here we exploit knowledge from the SP graph level. Recombination points should broaden the search in search space. For this reason, recombination points are defined to be operators representing a branch or a junction. It is expected to have the most impact in terms of search space traversal. The detection of these points is done once per SP graph. Each time a branch or a junction is detected it is marked as a potential recombination point. These potential recombination points are now considered as recombination points to combine two individuals.

The decision of which potential recombination point to take is inverse fitness-proportional.

Potential recombination points having a worsefitness value are more probable being selected for recombination (and hopefully improve this). Once a recombination point is chosen the individuals are combined and the next two individuals are taken for recombination, until all individuals have been processed. Possibly neither branches nor junctions are detected. In such cases an arbitrary recombination point is chosen by using an inversefitness-proportional strategy (as withselection).

The probability of individuals being selected asmutation candidates is proportional to the inversefitness value. Mutation then occurs with a certain probability (mutation probability) on one variable. The current variable assignment is replaced by a random value of its respective

6.8 Evaluation 191