• No results found

I. SpinningTop

9. Bond Order and Formal Charge Assignment

9.4. Optimisation Methods

9.4.2. Genetic Algorithm

A genetic algorithm is a stochastic optimisation method emulating the process of natural selec- tion. A population of candidate solutions, i.e. electron distributions, is evolved towards better

9.4. Optimisation Methods

solutions through a combination of point mutations and recombination. The fitness of each can- didate solution is evaluated using some objective function, the energy of the electron distribution (definition 9.1), and influences the make-up of future generations. To allow for easier program- matic manipulation, a candidate electron distribution is represented as an array of bits, with each bit representing a possible position for an electron or electron pair to be placed, giving of total of|P|bits. A1means that position is filled and a0that it is empty. As such, the total number of bits set to1is restricted to the number of electrons or electron pairs that need to be placed,eT.

9.4.2.1. Initialisation

An initial population size consisting ofNpcandidate solutions is generated. Candidate solutions

can be generated either randomly or through a seeding mechanism. A random candidate solu- tion,S, is produced by randomly choosing elements fromPsuch thatSPand|S|=eT. The

seeding mechanism employed uses a greedy position filling process to create an initial candi- date solution before performing mutations to create further candidates. Greedy position filling is performed as follows. A base energy is calculated using the partial electron distribution where no electrons or electron pairs have been positioned. Positions are filled by iteratively choosing the position which causes the most negative change in the energy of the partial electron distri- bution. This initial candidate solution is then used as the source candidate solution and point mutated (section 9.4.2.3) to produce a further candidate solution. If either the mutated candidate solution has a lower electron distribution energy than the source solution, or the source solution has already been mutated five times, the source solution is replaced with the mutated candidate. Mutations proceed iteratively, updating the source candidate as described, until Ns candidate

solutions have been generated this way, withNs≤Np.

9.4.2.2. Breeding Selection

Breeding selection selectsNp/2 unique pairs of candidate solutions which are bred together to

form Np children. Each parent pair is obtained by randomly choosing two members of the

initial population. The selection process can be biased towards selecting fitter parents by theξb

parameter.ξbis a scale parameter to affect the probability of selecting lower energy candidates.

When ξb=0 each candidate has an equal probability of being selected, while at ξb=1, a

candidate’s probability of being selected depends entirely on its energy in relation to all other candidate energies. For a given value ofξb, the probability of selecting a stateiis:

Pi= ξbexp(− Ei) ∑Np j=1exp(−Ej) +1−ξb Np (9.6)

9. Bond Order and Formal Charge Assignment

whereEiis the energy of candidatei.

9.4.2.3. Genetic Operators

Genetic operators are the driving force behind the ability of genetic algorithms to optimise solu- tions. There are two main operators, mutation and crossover, though others are possible. Only the mutation and crossover operators are used here, and are detailed below.

Mutation The mutation operator as employed here reverses the state of two random positions, one of which is filled, the other which is empty. A filled source position is randomly chosen and paired with a randomly selected non-degenerate unfilled target position. The fill state of these two positions is then flipped.

Crossover The crossover operator uses a two parent,aandb, single point crossover technique to create two children. Each parent independently undergoes mutation with a probabilityρm,

prior to the crossover process. Potential crossover points are then determined by tracking the total number of1’s present in each of the parents. A potential crossover point is one where the total number of1’s up until that point is the same between the two parents, ensuring that both children have the correct number of electrons or electron pairs. The crossover point,x, used is randomly chosen from the set of all potential crossover points, and two children produced. The first child matches parentafrom 0 toxand parentbfromxto|P|. The second child is the opposite of this, matching parentbfrom 0 toxand parentafromxto|P|.

9.4.2.4. Generational Progression

The selection process chooses which candidate solutions to pass onto the next generation from the combination of the produced child candidate solutions and the candidate solutions of the current generation, i.e. there are 2·Npcandidate solutions to choose from. The method used to

select the next generation is the same as that used to select parents for breeding, thoughξbin

equation 9.6 is replaced by an independent parameter,ξg. Once a candidate solution has been

selected for progression to the next generation, it is removed from the current generation. 9.4.2.5. Termination

Termination of the genetic algorithm occurs in one of two situations. The first occurs when some maximum number of generations, M, have passed. The second occurs when at least m generations have passed, and the lowest energy candidate solution has not changed fort gener- ations. Further, a situationally more efficient brute force method, which calculates the energy

9.4. Optimisation Methods

of all possible combinations of electron positions, is used instead of the genetic algorithm when |P|

eT

≤mN.