• Tidak ada hasil yang ditemukan

Pseudocode for tournament selection

A.3 Popup message which appears at the end of the run

2.2 Pseudocode for tournament selection

input :tournament size output: A GP individual

1 begin

2 for i←1 totournament sizedo

3 random individual← randomly select an individual from the GP population.

4 if i= 1 then

5 best individual← random individual

6 end

7 else

8 Comparebest individualand random individual and store the one with the higher fitness tobest individual.

9 end

10 end

11 return best individual

12 end

The tournament size dictates theselection pressure [2]. If the tournament size is small then there is a small amount of selection pressure. The opposite can be said for a large tournament size whereby it results in a greater amount of selection pressure.

CHAPTER 2. GENETIC PROGRAMMING 19 A large tournament size leads to an elitist GP algorithm which could converge prematurely to a local optimum. Tournament selection is a commonly used selection method. In comparison to the fitness proportionate method, tournament selection benefits from the fact that a selection pressure can be used. If the tournament size is selected correctly, then tournament selection will maintain diversity and additionally drive the GP algorithm towards a solution. Additionally, tournament selection does not require the extra computations involved in calculating the adjusted fitness and the normalised fitness.

detail.

2.10.1 Reproduction

The reproduction operator copies a parent across to the next generation by simply duplicating the individual and making no alterations to it [1–3]. The reproduction operator is a local operator since it makes no alterations to the parent being copied across.

2.10.2 Mutation

The mutation operator [1–3] creates an offspring by mutating a single parent as follows. A mutation point, p, is randomly selected in the parent, and the subtree rooted at the point is removed. A new randomly generated subtree is inserted at pointp. Mutation can cause trees to grow rapidly and thuspruningis used to ensure that individuals do not grow beyond a certain size. Pruning is achieved by replacing any function node at the maximum tree depth with a terminal node. Mutation is a global operator due to the fact that random subtrees are created at the mutation points which can result in a significant difference between the offspring and the parent. Consequently, the mutation operator does not promote convergence. Figure 2.6 illustrates the mutation operator.

Figure 2.6: Mutation operator, adapted from [1].

2.10.3 Crossover

Thecrossover operator creates two new offspring which are formed by taking parts (genetic material) from two parents [3] [2]. The operator selects two parents from the population based on a selection method. A crossover point is then randomly selected in both trees, say point p1 and p2, from tree t1 and t2 respectively. The

CHAPTER 2. GENETIC PROGRAMMING 21 crossover then happens as follows: the subtree rooted at p1 is removed from t1 and inserted into the position p2 in t2. The same logic applies to the point p2; the subtree root at the point is removed from t2 and inserted into the place of p1 in t1. Figure 2.7 illustrates the crossover operator. Crossover promotes convergence and is a local search operator.

Figure 2.7: Crossover operator [2].

2.11 Termination

Koza states that the GP “paradigm parallels nature in that it is a never-ending process” [3]. This obviously is not feasible, hence the GP algorithm should terminate once a success predicate is met. The success predicate can be defined in different ways however the most common one is to find a solution which has a hits ratio of 100%, i.e. a perfect solution to the problem. The success predicate can be problem dependent [1] and thus defined differently from one problem to another. However in certain problem domains, aiming for a perfect solution is not reasonable, hence once a near-solution is found the GP algorithm can terminate.

2.12 Strongly-Typed GP

Strongly-typed genetic programming [15] enforces constraints on the nodes within a representation. A type is allocated to the terminals and functions, and consequently, this guarantees that syntactically correct trees are evolved. Strongly-typed GP will ensure that during the initial population generation and application of the GOs, the types of the functions and terminals are respected and not violated. Additionally, strongly-typed GP reduces the size of the program space by limiting the different combinations of functions and terminals [15].

TheIf-Then-Else function is one which requires strongly-typed GP. This function is illustrated in figure 2.8, and each of the three arguments can be assigned a type.

The If-Then-Else function has an evaluation (the If part) and two consequences (theThen andElse parts) which are executed respectively based on the evaluation.

Assume a boolean type is assigned to the If part as illustrated in figure 2.8; as a result of strongly typed GP, the If part should always return a boolean type and this enforcement cannot be violated. Thus variables x and y have to be boolean types.

When applying GOs to strongly-typed GP, it must be ensured that the assigned types are not violated. Thus assume in figure 2.8 that the terminalx is selected as a mutation point, it must be ensured that the new subtree at this point will return a boolean value. If the assigned types are violated, then the trees would be invalid.

Figure 2.8: If-Then-Else function.

2.13 GP Control Models

There are two major control models which can be used when implementing a GP algorithm, a generational control model and a steady-state control model [2]. The models control the population and how they evolve. The generational control model

Several operators have been designed in such a way that they can preserve parts of the GP individual. These preserved parts can then be further reused within other individuals. The goal in this approach is to capture good building blocks so that the GOs cannot alter these building blocks. Two of the methods described in this section are GOs which achieve modularisation.