• No results found

5.4 Genetic Optimisation of School Allocations

5.4.3 Chromosome Manipulation: Crossover and Mutation

When a fixed number organisms are selected by roulette-wheel reproduction, according to the bound on the generation size, some of the organisms undergo crossover and mutation. It is customary to first per- form crossover and then mutation.11 A crossover parameter, a real number from 0 to 1, determines which percentage of reproduced organisms will be crossed over. Since crossover is always performed on pairs, an even number of organisms on which crossover will be performed, needs to be calculated, given the crossover parameter and the fixed bound on the generation size. The number of organisms on which crossover will be performed, that is the size of thecrossover pool, is:

size crossover pool = (c⋅ρc) − [c⋅ρc mod 2]where

ˆ c is the fixed bound on the generation size;

ˆ ρc is the crossover parameter;

ˆ [x mody], withx, y∈R, is the remainder after division ofxbyy as a real number.

Since the GOPAM orders the chromosomes selected by reproduction in the order of the intervals in which the random numbers, created for roulette-wheel reproduction, fell, the first k occurring selected chromosomes, where k is the size of the crossover pool, can be selected for crossover. In this way it is guaranteed that a percentage, corresponding to the crossover parameter, ofrandomly selected chromosomes is crossed over.12

Furthermore, by just pairing up the crossover pool (e.g. ⟨a, b, c, d⟩becomes⟨(a, b),(c, d)⟩) also random pairs of chromosomes are selected for crossover. Given a pair of chromosomes (A, B), the operation of crossover first determines a random integerr, s.t. 0<r< ∣A∣ = ∣B∣, which is a cut-off point for splitting the chromosome (permutation) A. For the splitting ofA a functionsplitAtis used, such thatsplitAt(i,Ð→S)creates two lists, a list of items before Ð→S(i)ordered as in Ð→S, and a list of items fromÐ→S(i) onwards, ordered as inÐ→S. For instance,splitAt(1,⟨a, b, c⟩) = (⟨a⟩,⟨b, c⟩). The first list created bysplitAton some listAwill be called in the

11Mitchell (1996): pp. 8-9; Goldberg (1989): p. 12. 12cf. the remarks in Section 5.3 after Definition 5.2.

following,L(A), the second list,R(A). After the listAis split intoL(A)andR(A), the crossover operation, will create two new listsC andD, s.t.:

ˆ C=L(A) + +B′;

ˆ D=B′′+ +R(A),

where B′ are all students not occurring inL(A) ordered as inB, andB′′ are all students not occurring in

R(A)ordered as inB. The new permutationsCandDso obtained by the crossover operation are the results of performing crossover on permutations A and B. More formally, the crossover operation is the following procedure:

input :A randomized list (population)Ð→P of permutations (chromosomes)Ð→Si, the crossover

parameterρc, the bound on the generation sizec.

output:A list (population)Ð→P′of permutations (chromosomes)Ð→Si.

LetÐ→P′∶= ∅;

Lets∶= (c⋅ρc) − [c⋅ρc mod 2]; LetP ool∶=ι(s,Ð→P);

LetP airs∶=pairU p(P ool), where

pairup(Ð→X) = {(x, x′) ∣ (i, x),(i+1, x′) ∈ Ð→X and[i mod 2] =0}; for (Ð→A ,Ð→B) ∈P airsdo

Generate a random integerr, s.t. 0<r< ∣Ð→A∣; Let(L(Ð→A), R(Ð→A)) ∶=splitAt(Ð→A , r), where

splitAt(Ð→X , i) = ({(j, x) ∈ Ð→A ∣j<i},{(j, x) ∈ Ð→A∣j≥i}; LetÐ→C ∶=L(Ð→A) + +Ð→B′, where Ð→ B′= {(i, b) ∈ Ð→B ∣ (i, b) ∉L(Ð→A)}s.t. ∀(i, b)(j, b′) ∈Ð→B′∶ Ð→B−1(b) < Ð→B−1(b′) ⇒Ð→B′−1(b) <Ð→B′−1(b′); LetÐ→D ∶=Ð→B′′+ +R(Ð→A), where Ð→ B′′= {(i, b) ∈ Ð→B ∣ (i, b) ∉R(Ð→A)}s.t. ∀(i, b)(j, b′) ∈Ð→B′′∶ Ð→B−1(b) < Ð→B−1(b) ⇒Ð→B′′−1(b) <Ð→B′′−1(b); LetÐ→P′∶= Ð→P′+ +Ð→C+ +Ð→D; returnThe list (population) Ð→P′.

It is immediate that the permutations Ð→C and Ð→D so produced will still be permutations of students if the permutationsÐ→A andÐ→B are. Hence, the operation of crossover performed on two permutationsÐ→A andÐ→B will produce organisms, corresponding toÐ→C andÐ→D, that are Pareto-optimal allocations for the school market in question.

Mutation differs from crossover in that no ‘(mutation) pool’ is generated before the operation is performed. Mutation is performed on each chromosome individually, that is, for each gene in the chromosome a biased coin is flipped to determine if the gene will be mutated, thereby mutating the chromosome. The bias of the coin is determined by the mutation parameter, which is some real number ρm∈ [0,1]. This means that if the mutation parameter is 0.25, then some gene, in some chromosome, is mutated with a probability of 0.25. More formally, the operation of mutation generates a random real numberr← [0,1]for each gene s

s.t. if r< ρm, then s is mutated. A mutation of s will be an exchange of s with some student s′ in the

permutation in question (the respective chromosome) s.t. the index of s′ is at least as low as the index of

s. If the operation has ‘flipped a coin’ for each allele in the chromosome, then the operation of mutation is finished for that chromosome. More formally the operation of mutation, on some population is the following:

input :A list (population)Ð→P = ⟨Ð→S0,Ð→S1, ..,Ð→Sc⟩of permutations (chromosomes)Ð→Si, the mutation

parameterρm

output:A list (population)Ð→P′= ⟨Ð→S′0,Ð→S′1, ..,Ð→S′c⟩of permutations (chromosomes)Ð→Si.

LetÐ→P′∶= ∅;

for0≤i≤ ∣Ð→P∣ −1 do LetÐ→S′i∶= ∅;

for0≤j≤ ∣Ð→Si∣ −1 do

Generate a random integerr← [0,1]; if r≥ρmthen

LetÐ→S′i∶= Ð→S′i+ +⟨Ð→Si(j)⟩;

else

Generate a random indexk s.t. 0≤k≤vectSi−1(j);

LetÐ→S′i∶= Ð→S′i∪ {(j,Ð→S′i(k))}(i.e. inserting the random student at the new position); LetÐ→S′i∶= Ð→S′i∖ {(k,Ð→S′i(k))}(i.e. removing the student from the old position);

LetÐ→S′i∶= Ð→S′i∪ {(k,Ð→Si(k))}(i.e. inserting the present student at the random position);

LetÐ→P′∶= Ð→P′+ +⟨Ð→S′i⟩; returnThe list (population) Ð→P′.

Note that when some gene is mutated, in most cases that gene, some students, is assigned a lower index in the resulting new permutation; the side effect of this is of course, that then also some other random student

s′, with whomsswitches places, is assigned a higher index. The student who ‘mutates’ is never worse off, however, every mutation in which some student is better off (in terms of position in the permutation), will always yield some student who is worse off (in terms of position in the permutation).