Top Banner
A Genetic Algorithm to Maximise the Efficiency of Electrical Conductors, by Minimising the Proximity and Skin Effect Matthew W. A. Sparkes BSc School of Computing Sciences, University of East Anglia, Norwich, United Kingdom, NR4 7TJ [email protected] January 29, 2007 Abstract This project aims to create a faster method to analyse the effect of skin and proximity effect on electrical conductors, and to apply this to a Genetic Algorithm. This will provide a faster method to calculate the op- timal shape for electrical conductors, and reduce the energy consumption of electrical circuits designed using it. 1
47

MSc Dissertation - Matthew Sparkes

Oct 15, 2014

Download

Documents

Matthew Sparkes

A Genetic Algorithm to Maximise the Efficiency of Electrical Conductors, by Minimising the Proximity and Skin Effect
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: MSc Dissertation - Matthew Sparkes

A Genetic Algorithm to Maximise the Efficiency

of Electrical Conductors, by Minimising the

Proximity and Skin Effect

Matthew W. A. Sparkes BScSchool of Computing Sciences,

University of East Anglia,Norwich,

United Kingdom,NR4 7TJ

[email protected]

January 29, 2007

Abstract

This project aims to create a faster method to analyse the effect ofskin and proximity effect on electrical conductors, and to apply this to aGenetic Algorithm. This will provide a faster method to calculate the op-timal shape for electrical conductors, and reduce the energy consumptionof electrical circuits designed using it.

1

Page 2: MSc Dissertation - Matthew Sparkes

Contents

1 Acknowledgments and Foreword 4

2 Introduction to Genetic Algorithms 52.1 What is a Genetic Algorithm? . . . . . . . . . . . . . . . . . . . . 52.2 Natural Selection and Mutation in Nature . . . . . . . . . . . . . 62.3 Evolution as a Paradigm for Problem Solving . . . . . . . . . . . 7

3 The History of Genetic Algorithms 83.1 The Birth of GA . . . . . . . . . . . . . . . . . . . . . . . . . . . 83.2 Problems Associated with Genetic Algorithms . . . . . . . . . . . 8

3.2.1 Complexity and Reliability . . . . . . . . . . . . . . . . . 83.2.2 Legal, Ethical and Moral Issues . . . . . . . . . . . . . . . 9

4 Anatomy of a Genetic Algorithm 104.1 Encoding and Population Size . . . . . . . . . . . . . . . . . . . . 104.2 Crossover Operations . . . . . . . . . . . . . . . . . . . . . . . . . 11

4.2.1 Single Point Crossover . . . . . . . . . . . . . . . . . . . . 114.2.2 Double Point Crossover . . . . . . . . . . . . . . . . . . . 124.2.3 Cut and Splice Crossover . . . . . . . . . . . . . . . . . . 124.2.4 Uniform Crossover . . . . . . . . . . . . . . . . . . . . . . 12

4.3 Mutation Operations . . . . . . . . . . . . . . . . . . . . . . . . . 144.4 Fitness Evaluation . . . . . . . . . . . . . . . . . . . . . . . . . . 154.5 Population Initialisation . . . . . . . . . . . . . . . . . . . . . . . 16

4.5.1 Pre-Defined Variance . . . . . . . . . . . . . . . . . . . . . 164.5.2 Randomly Generated Solutions . . . . . . . . . . . . . . . 174.5.3 Evenly Spaced Solutions . . . . . . . . . . . . . . . . . . . 17

4.6 Halting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 184.6.1 Resource Based Halting . . . . . . . . . . . . . . . . . . . 184.6.2 Solution Fitness Based Halting . . . . . . . . . . . . . . . 184.6.3 Progress Based Halting . . . . . . . . . . . . . . . . . . . 19

5 Current Applications of Genetic Algorithms 205.1 Code/Cipher Decryption . . . . . . . . . . . . . . . . . . . . . . . 205.2 Resource Allocation in Communication Infrastructures . . . . . . 205.3 Neuro-Evolution . . . . . . . . . . . . . . . . . . . . . . . . . . . 205.4 Electrical Circuit Design . . . . . . . . . . . . . . . . . . . . . . . 205.5 The Arts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 215.6 Gene Sequence Analysis . . . . . . . . . . . . . . . . . . . . . . . 215.7 Physical Engineering Design . . . . . . . . . . . . . . . . . . . . . 22

5.7.1 JET/ITER Fusion Reactors . . . . . . . . . . . . . . . . . 22

6 Competing Techniques to Genetic Algorithms 23

7 Introduction to Skin and Proximity Effect 247.1 The Chosen Application . . . . . . . . . . . . . . . . . . . . . . . 247.2 Representation in GA . . . . . . . . . . . . . . . . . . . . . . . . 24

7.2.1 Representation of Bars . . . . . . . . . . . . . . . . . . . . 257.2.2 Converting Angles to Cartesian Coordinates . . . . . . . . 25

7.3 Calculating Fitness Values . . . . . . . . . . . . . . . . . . . . . . 26

2

Page 3: MSc Dissertation - Matthew Sparkes

8 Aim of Project 27

9 Design 289.1 Fitness Function . . . . . . . . . . . . . . . . . . . . . . . . . . . 289.2 Population Initiation . . . . . . . . . . . . . . . . . . . . . . . . . 299.3 Population Size . . . . . . . . . . . . . . . . . . . . . . . . . . . . 309.4 Halting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 309.5 Selection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 309.6 Mutation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31

9.6.1 Variable Mutation Rate . . . . . . . . . . . . . . . . . . . 319.7 Logging Features . . . . . . . . . . . . . . . . . . . . . . . . . . . 329.8 Implementation Language Choice . . . . . . . . . . . . . . . . . . 329.9 GUI Design . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32

9.9.1 Drawing the solutions . . . . . . . . . . . . . . . . . . . . 329.9.2 Colour Use . . . . . . . . . . . . . . . . . . . . . . . . . . 32

10 Implementation 3310.1 GA Prototype - Word Finder . . . . . . . . . . . . . . . . . . . . 33

10.1.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . 3310.1.2 Design . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3310.1.3 Implementation . . . . . . . . . . . . . . . . . . . . . . . . 3310.1.4 Results . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34

10.2 Proximity and Skin Effect Genetic Algorithm . . . . . . . . . . . 3610.2.1 Solution/Curve Representation . . . . . . . . . . . . . . . 3610.2.2 Implementation Plan . . . . . . . . . . . . . . . . . . . . . 3610.2.3 Results . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3710.2.4 Possible Improvements . . . . . . . . . . . . . . . . . . . . 38

10.3 Further Research . . . . . . . . . . . . . . . . . . . . . . . . . . . 3910.3.1 Counter-Balanced Mutation . . . . . . . . . . . . . . . . . 3910.3.2 Meta-Testing - Automation of Design Refinement? . . . . 3910.3.3 Experiment in Metametahueristics . . . . . . . . . . . . . 40

11 Conclusion 4111.1 Project Results . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4111.2 Real-World Benefits . . . . . . . . . . . . . . . . . . . . . . . . . 4111.3 Adaptability to Other Problems Spaces . . . . . . . . . . . . . . 41

12 Appendix 4412.1 Source Code for GA Word Finder . . . . . . . . . . . . . . . . . . 4412.2 Example output from GA Word Finder . . . . . . . . . . . . . . 4512.3 Source Code for GA . . . . . . . . . . . . . . . . . . . . . . . . . 47

3

Page 4: MSc Dissertation - Matthew Sparkes

1 Acknowledgments and Foreword

Many thanks to Paul Murgatroyd, who provided his supervision and expertise,without which I would have been lost several times. Thanks also for providingthe initial idea for the project, and introducing me to a fascinating subject.[5]

I should also thank Richard Dawkins for his invaluable book, The Blind Watch-maker, which is a fascinating book even if you aren’t writing a dissertation onevolutionary algorithms. [4]

Thanks also to Neela Das and John MacFarlane at New Scientist, for giving methe time off I needed to finish off this project - even if they weren’t always awareof it.

4

Page 5: MSc Dissertation - Matthew Sparkes

2 Introduction to Genetic Algorithms

2.1 What is a Genetic Algorithm?

A Genetic Algorithm (GA) is a type of metahueristic algorithm, designed tooperate on optimisation problems. Optimisation problems typically demandthat a certain variable be either minimised or maximised, whilst remaininglegal within some set of constraints. These problems are often extremely largein their nature, usually to the point of NP-hardness, which effectively meansthat finding the exact or optimum solution is infeasably difficult. To enumerateevery possible solution and evaluate them to determine which is the optimumwould take an inordinate amount of time.

In certain applications, where optimality is not necessary, metahueristics canbe used to find a ’good enough’ solution, often in a very short time. Meta-heuristics vary in their strategies, but all use some technique to explore thespace of all possible solutions. One such example of a metahueristic approachis GAs [3]. Other metaheuristic techniques are detailed in section 6. It mustbe emphasised that they are only suitable for applications where a good solu-tion is adequate, where an optimum solution is not essential. Metahueristics donot guarantee to find the best solution, although they may fortuitously stum-ble upon optimality. This may sound like an unacceptable compromise, butthe massive reduction in computing time makes metahueristics very desirablein some situations. [4]

GAs are a special subset of metahueristics, which use a form of biologicalmimicry which emulate the process of natural selection.

”Three billion years of evolution can’t be wrong. It’s the most pow-erful algorithm there is.” [20]

This quote from Dr. Goldberg sums up the aim of Genetic Algorithms; tomodel nature, and harness their proven ability to refine solutions, or animals,to a very efficient form. They are a form of metahueristic search in that theyfind solutions to hard problems, possibly even NP-hard, where it is not feasibleto enumerate all possibilities in order to find the best solution.

GAs work by creating a selection of possible problems, called the population, andbreeding them with each other. [10] This alone would not refine the solutionsin any way, so the process of natural selection is used to ’kill off’ a section ofthe least efficient solutions in each generation. Each solution is evaluated bya ’fitness method’ which uses some problem-specific algorithm to calculate the’goodness’ of that solution. The best solutions from each generation are usedto create the next, and the worst are deleted, in a simple model of naturalselection.

To create the next generation, a combination of mutation and crossover is used.Crossover takes some qualities from two solutions and creates another - thismodels breeding and procreation. Mutation is also used, as in evolution, ran-domly to change these solutions in the hope that a desirable feature is intro-duced. [15] Mutation is also important in order to avoid local optima, which

5

Page 6: MSc Dissertation - Matthew Sparkes

are areas of the search space which appear to be optimum, but are actually justisolated by neighboring solutions of a less desirable nature.

Figure 1: An example of a local optimum.

2.2 Natural Selection and Mutation in Nature

Within nature, members of a population are born, procreate, and die. Pro-creation creates offspring which are a combination of the two parents, withoccasional mutation also operating on the genes. This mutation does not neces-sarily have to be obvious or large. The mutation of a single gene can have littleor no effect, but equally may have large repercussions - entirely dependent onits role within the body. It is often the case that combinations of genes affecta certain characteristic so that the alteration of a gene may have no obviouseffect, but actually subtly alter many charecteristics.

Mutation can occur within any cell in the body, and usually occurs duringreplication. There are mechanisms which reduce the amount of mutation thatis allowed to occur, but they are not infallible. There are two types of cell inliving creatures; somatic and germline. Germline cells produce sperm and eggs,and all others are somatic. Therefore if the mutation occurs in the somatic cells,then this mutation will die with the cell, but if it occurs in the germline cellsthen it will be passed onto offspring - provided the organism isn’t detrimentallyaffected to the point of not surviving to procreation. [14]

These mutations can be beneficial or harmful, and can provide the animal withan advantage over the other members of the species, or cause it to be less capableof survival than others. As Dawkins explains in ’The Blind Watchmaker’, thesemutations are more than likely to be detrimental than beneficial, as ’there aremore ways of being dead than being alive’. By this he means that within thevast space of possible gene sequences, there are few that represent living andsurviving organisms, and an almost limitless amount of pools of non-living aminoacids. [4]

For example, an increase in the capability to detect certain smells may makethe animal a better hunter, or better enable it to detect predators, and in either

6

Page 7: MSc Dissertation - Matthew Sparkes

case would provide the animal with an advantage over other members of thatspecies. This would mean that it would be more likely to survive to adulthood,and to procreate, spreading its genes. An animal with a detrimental mutationhowever, such as a reduced sense of smell, would be more likely to succumbto starvation or attack from predators before procreation could occur. This isnatural selection, and is a natural feedback process which causes ’good’ genesto spread, and takes ’bad’ genes out of the pool. It is this interplay betweenentirely random mutation, and non random selection that makes up the processof evolution, causing species to adapt to their environment - not by intent butby default. It is a process that takes an almost unimaginable length of time tooccur.

There is little doubt ... that usually feedback mechanisms operateto regulate the size of populations. [23]

2.3 Evolution as a Paradigm for Problem Solving

The powerful refinement and improvement abilities of natural selection can beharnessed to solve combinatorial optimization problems using a computer.

By creating a model of an environment, where the organisms become potentialsolutions to the problem, and genes become variables modeling that solution, wecan recreate natural selection to ’breed’ solutions that increase in fitness witheach generation. We can simulate all processes of evolution; procreation can bemodeled by combining two or more solutions in certain ways, mutation can bemodeled using random number generators, natural selection and death can bemodeled using a fitness evaluation method, and selecting which solutions will’survive’ to the next generation.

In this way we can explore the search space, refining our solutions, and avoidinglocal optimums by including random mutation - some of which will be detri-mental and not survive to procreation, and some which is beneficial and willsteer the solutions towards unexplored space.

7

Page 8: MSc Dissertation - Matthew Sparkes

3 The History of Genetic Algorithms

3.1 The Birth of GA

Work conducted in the 1950’s and 1960’s in cellular automata started the idea ofusing GAs to solve problems inherent in engineering, wherever they constitutedoptimisation problems. [15]

In the 1980s research into GAs started, and an international conference for thefield was founded. As early as 1995 there were several successful examples ofGA optimisation being used in industry including Texas Instruments designingchips to minimise size but maintain functionality. Critical designs such as theengine plans leading to the development of the Boeing 777 engine by GeneralElectric were also developed using GAs.

US West uses GA sto design fiber-optic cable networks, cutting design timesfrom two months to two days, and saving US West $1 million to $10 millionon each network design. [6] Genetic Algorithm derived designs have now evenbeen used in satellites by NASA, with the development of an aerial being takencompletely out of engineers hands. The orbit of those same satellites is noweven determined with the use of a Genetic Algorithm. [29][30]

3.2 Problems Associated with Genetic Algorithms

GAs and genetic programming algorithms, which use GA type evaluation andmutation to write functional code, are by no means a ’silver bullet’. There areseveral reasons for which they are not suited to all problems, and these areexamined here.

3.2.1 Complexity and Reliability

Sometimes GAs or genetic programming provide solutions that are so complex orconvoluted that no human programmer could decipher what is being performedwithin. Because they do not follow any logical examination of the problem, asa human designer would, they may find an extremely counter-intuitive way toachieve a certain task. No design of any kind is actually performed in order tofind a solution, so apparent logic in the result is not guaranteed.

The methods that GAs use to design systems are not necessarily logical so thefinished code, no matter how effective, may be all but indecipherable to the hu-man user. This means that sometimes full testing is not possible, and code thatappears to work completely cannot be proven to work in all examples. Goldbergtalks of the difference between conceptual machines and material machines, i.e.an algorithm and a vehicle engine respectively. [12]One is fully testable, but theother is not necessarily so.

Although this is a normal problem with testing; not all cases can be tested, butif the code is readable then a talented tester can devise test cases that will likelytrip the system up which is not possible with highly complex code. This creates

8

Page 9: MSc Dissertation - Matthew Sparkes

ethical problems with implementing GA derived designs in mission critical orreal time applications. Bearing in mind that a failure in air traffic control, lifesupport hardware etc could be fatal, or that failure in a financial institutioncould be disastrous in other ways, but that GA is also used to develop actualmechanical devices. Goldberg tells an amusing story about an airline passengerworrying about the design and its testing. If you were to imagine a plane as aGA, and the passenger as a GA user, then you could imagine the stress thatthe thought of a failure would cause. [12]

3.2.2 Legal, Ethical and Moral Issues

One interestiong problem that arises from the use of Genetic Algorithms isthe moral or ehtical implications arising from a design that is not of humanderivation. If there is a fundamental flaw in a human design, and this leads toa failure involving financial loss or human injury then blame is aportioned tothe engineer responsible for the negligent design. However, if a GA designs asystem that leads to a failure (possible due to unforeseen emergent behaviouras a result of massive complexity) then it is difficult to find the root cause ofthis issue.

9

Page 10: MSc Dissertation - Matthew Sparkes

4 Anatomy of a Genetic Algorithm

This section outlines the basic structure and components of a GA. It will becomeclear that each section is indeed an algorithm in its own right, and that thereare numerous choices of strategy for each. A GA is simply an abstractionof a subset of algorithms. It should also be noted that the huge variation ofapproaches possible for each of the several components of a GA mean that thereis a vast number of programs that fall under this catch-all title. A taxonomy ofdifferent approaches to the GA idea would be an extremely complex tree.

4.1 Encoding and Population Size

Population size is the term used for the number of solutions held by the GA.The population size is a critical variable, which presents a trade-off betweenthe computational power of each generational iteration, and the computationalintensity of each iteration. A small number of solutions allows a greater numberof generations to iterate in a given time, because each generation will be lesscomputationally intensive.

A large population size will provide more variety in each generation, whichmeans more likelihood of a beneficial solution, but the trade off is that each gen-eration will take longer to compute. However, within a relatively small amountof generations the solutions will begin to converge on a similar solution. Theamount of variation on average will decrease as the generation number increases,although the rate will vary on the magnitude of the mutation. Therefore it maybe beneficial to choose a smaller value for the population size.

Small variations, if beneficial, will propagate through a small population justas they will through a larger one. Although a large population size means thatthere is more mutation per generation, the faster computation of a smaller pop-ulation size would be capable of allowing a similarly large amount of mutationover a small number of solutions within the same time period [4]. The onlyconstraint on population size is that the initial population needs to be at least2 solutions large, as with any smaller amount no crossover operations would bepossible, and it would be impossible to derive any more beneficial solutions inthis way.

With a straightforward mutation-only algorithm is would be possible to reachan optimal solution, but this entirely random approach would not yield anysignificant increase over any other brute-force approach. Because of this itwould not classify as a GA, or even a metaheuristic.

10

Page 11: MSc Dissertation - Matthew Sparkes

4.2 Crossover Operations

Crossover is one of the two main methods used in GAs in order to alter solutions.It is important to use both, as one maintains desirable traits whilst combiningsolutions, and the other introduces random noise in the hope of creating emer-gent properties that add value.

Crossover is the operation that allows solutions to combine. If mutation wereused alone then it would essentially be a random solution generator, but wouldstill work. Crossover allows the retention of desirable traits, without the needto keep entire solutions.

Mutation alone is not mathematically guaranteed to work, although it is in-finitesimally unlikely that it would not at some point reach optimality or closeto it. [4] Crossover is the method by which a GA can take value from previ-ous solutions, and build the next generation of solutions in a semi-intelligentmanner. [16]

The method of crossover requires careful thought, and it’s success is highly de-pendent on the problem to which it is applied. The encoding that is used torepresent a single solution needs to be paired to crossover. For example, if asolution consists of three variables, all 4 bits long, then our total solution occu-pies 12 bits. The simplest crossover approach would be to bisect two solutions,and create two new solutions by combining the start of one and the end of an-other, and vice versa. If this approach was taken though, the efficiency of theprogram would be greatly reduced. Any time that a good value for the middlevariable was found there is a good chance that it would be overwritten by thenext generation. However, if the crossover was designed with the solution inmind, then the solutions could be trisected and recombined to preserver thevalue of individual variables. This would be more likely to arrive at a solutionin a reasonable length of time.

Figure 2: An example of single point crossover.

4.2.1 Single Point Crossover

Single point crossover is the simplest form of crossover operation. It simplytakes the genes of a pair of solutions, and bisects them at the same arbitrary

11

Page 12: MSc Dissertation - Matthew Sparkes

point, the tail or head sections are then exchanged. (See figure 4.2.1) In thisway the pair of parent solutions can create a pair of children that share certainaspects of both solutions. If the two sections that make up the new child bothcontain features that are beneficial then a successful evolution has occurred,and a solution that exceeds the fitness of previous solutions has been created.[16]

4.2.2 Double Point Crossover

With double point crossover the strategy is similar to single point, but thetransferred section of genes does not have to include the tail or head of a solution.(See figure 3) This enables greater flexibility in the sections altered, and alsoprovides all genes with an equal chance of exchange, whereas in the single pointstrategy any point chosen is guaranteed to swap the end gene, and will favorgenes towards the edge of the solution. [16]

Figure 3: An example of double point crossover.

4.2.3 Cut and Splice Crossover

Cut and splice is a technique that does not maintain solution length, whichmeans that it is not acceptable for all GAs. In both double and single pointcrossover the length of the solution is kept, and therefore genes can have spe-cific properties. (See figure 4) For example, in a GA that designed possibleengine parts each gene could represent a quality of that part such as height orthickness. In single and double point crossover these values would be swappedaround, but maintain their context and meaning, but in a strategy which variessolution length this is not possible. Instead, cut and splice is more fitting toproblems where the solution strings represent a solution to some singular prob-lem to optimize, for example in certain combinatorial optimization problems.[16]

4.2.4 Uniform Crossover

In uniform crossover the bits from each parent are swapped, depending upona probability. In half uniform crossover the number of differing bits between

12

Page 13: MSc Dissertation - Matthew Sparkes

Figure 4: An example of cut and splice crossover.

the two parents is calculated, and this number is divided by two. The resultingnumber is the number of non-matching bits that will be exchanged.

13

Page 14: MSc Dissertation - Matthew Sparkes

4.3 Mutation Operations

To fully equip a GA with the ability to find a solution as close as possible to op-timality within a given time it is desirable to use a combination of crossover andmutation operations. With solely crossover operations there is a distinct possi-bility that the algorithm would work towards a local optimum and remain there,as promising solutions are crossed with others a local optimum would quicklypropagate through the solutions in use, and stall the algorithm. With a mu-tation operation involved as well, random solutions are thrown into contentionthroughout the cycle of finding a solution, and this may eventually enable analgorithm to branch out from underneath a local optimum, in order to pursueother avenues. [4]

Mutation is an essential part of any successful genetic algorithm. Withoutmutation an algorithm would simply combine the fittest solutions. This wouldmean that the generations would quickly converge into an amalgam of goodsolutions, and cease to improve. Mutation can be performed in a number ofways, and each will be appropriate for different problems. [18]

In fact, mutation alone is capable of finding a solution, even the optimum solu-tion, given sufficient time. For example, consider an algorithm with a populationof only one solution, that only operates upon the solution with mutation. Aftereach generation the solution is either better or worse than the previous one,and either fulfills the halting algorithm, or does not. It will eventually stumbleupon a good enough solution. However, with a well designed GA we can reacha satisfactory result far quicker. It should be noted however that it can oftenbe useful to create a simple algorithm such as this in order to get started indevelopment of a more complex and intelligent system.

while (solution is not optimal)(create random changecheck for improvementif (improvement has occurred)(save changego back to start of loop)else(discard changego back to start of loop))

14

Page 15: MSc Dissertation - Matthew Sparkes

4.4 Fitness Evaluation

The fitness evaluation section of the GA determines which solutions are removed,and which progress to the next generation. It uses an algorithm to calculatehow good a certain solution is. Once each generation has been created, thefitness of each solution is evaluated and ranked.

Fitness evaluation mimics the environment in which members of a species wouldlive. The higher the fitness value, the more likely a solution is to ’survive’ tothe next generation, and the lower it is the more likely it is that the solutionwill ’die off’. Therefore the fitness evaluation mimics anything dangerous in areal world environment - predators, disease, famine, etc.

The fitness evaluation is extremely problem specific, and must be designed verycarefully. It can be a simple case of maximising one value, or there may be manycomplex and interacting values to take into account. These must be analysed,weighted and summed within the fitness evaluation code, and condensed to onevalue with which that solution may be judged.

15

Page 16: MSc Dissertation - Matthew Sparkes

4.5 Population Initialisation

The initialization of the first generation population could conceivably alter thespeed with which the program finds a solution that satisfies the halting algo-rithm. The distance of the solution’s fitness from optimum would affect thenumber of generations needed to satisfy the halting algorithm.

In the extreme case it is possible that one of the initial solutions actually satisfiesthe halting algorithm, in which case the program would complete before anycrossover or mutation was necesarry.

With an entirely homogenous population, the algorithm would rely on mutationin order to provide variance in early generations, as crossover between similarsolutions achieves little. By creating a varied initial population it is conceivablethat good solutions would be found quicker, and the algorithm would completefaster.

The exact method of initialization that would provide the optimum start isunknown, as is the magnitude of the positive effect possible. It is highly likelythat a varied population would be more beneficial than a homogenous one tosome extent however, and any attempt to vary the genes would provide a smalladvantage at the very least.

There are several possible techniques for initializing populations, but the mostefficient method would vary not only from problem to problem, but also frominstance to instance within each problem.

4.5.1 Pre-Defined Variance

One possible approach would be to have designed, pre-defined variance in thesolutions. These could be identical for each run of the algorithm, or designedfor each instance of the problem. It may be possible to tailor In this way, pos-sible ’good’ traits could be engineered into the algorithm. For example, in thescenario below, a GA is searching for a solution to a problem, where the op-timum value is 8. The fitness algorithm simply calculates the integer value ofthe binary string which makes up the solution representation, and returns thedifference of that value from the optimum inverted. The table below shows apossible instance of this problem.

Binary String Integer Representation Fitness Value0000 0 -80011 3 -50110 6 -21001 9 -11100 12 -41111 15 -7

If it was possible to estimate the approximate region of the optimal solution,then it would be possible to create the initial solutions within this range.

Within a few generations, any initial population would congregate around the

16

Page 17: MSc Dissertation - Matthew Sparkes

optimal solution. However, by approximating the optimum with the initializa-tion, this process can be speeded up. The amount of effort required to tailora good range of solutions around an approximation would not be beneficialhowever, as the saving made in computational time would be minimal in com-parison.

It is conceivable that a system could be developed where a user inputs an ap-proximate solution, and the program randomly generates the initial populationwith slight derivations from this. This would reduce the amount of time neces-sary in order to set up the algorithm in this way, but retain most of the benefitof this approach.

4.5.2 Randomly Generated Solutions

A very simple method of initializing solutions would be to randomly generatethem. As a GA would have code to create random variation in the mutationmethod, it would be a trivial matter to adapt this to fully populate the initialdesigns. The scenario below shows an instance of the same GA as in section4.5.1, but where the population is randomly created.

Binary String Integer Representation Fitness Value1010 10 -20011 3 -50110 6 -21101 13 -50010 2 -61001 9 -1

4.5.3 Evenly Spaced Solutions

Another method would be to take the search space, and the number of solutionsin the population, and to calculate an even spread throughout.

17

Page 18: MSc Dissertation - Matthew Sparkes

4.6 Halting

Halting is an important and difficult problem in GAs. Without some form ofhalting criteria, that is checked at every generation, the program would continueto run, even once significant gains in fitness where no longer being generatedby new generations. There are many techniques that are used to halt GAs, andtheir appropriateness depends entirely on the application, but they fall into twomain categories; those that are based on the runtime of the algorithm, and thosethat are based on the quality of the solutions.

4.6.1 Resource Based Halting

It is often the case that a GA can only be allocated a certain amount of aresource, specifically time or computing cycles, to complete. In real time criticalsystems it may be vital to arrive at a solution within a given period, and in thiscase it is the role of the algorithm to find the best solution possible in thattime. Even in non-critical systems such as GPS route planners it is necessaryto impose some time constraints to avoid annoying the user; it is unlikely that auser would be willing to wait hundreds of hours to find the optimal route when5 seconds of calculation may find a route near to optimality.

In cases such as this the halting criteria are time or computing cycle based,rather than being associated with the fitness of the final solution. The algorithmwill check, at the end of every generation cycle, to see if it has exceeded itsallocated time, or if it is likely to in the next cycle, and the algorithm can thenbe halted. In extremely time critical systems this anticipation of possible timeoverruns can be used to avoid the algorithm exceeding its time constraints in-between halting checks. The number of generations can also be the limitingfactor, in a very loose time sensitive case, which although not accurate in termsof time constraints is very simple to implement.

4.6.2 Solution Fitness Based Halting

If time is less of a constraint, then halting can be based on the fitness of thesolutions. This is more desirable from a reliability point of view, as the outputcan be guaranteed to be of a certain quality, determined in the halting method.This is still a desirable practice, and does not mean that they are obsolete,to complete enumeration and evaluation. The reason for this is that thereis no way to find optimality for a problem, without enumerating all possiblesolutions, which can be a very time intensive procedure. A large travelingsalesman problem would demand that an enormous number of different solutionsbe enumerated and evaluated in order to find an optimal solution, where as aGA could be run for an arbitrary amount of time, and with each iteration reacha better solution.

To implement solution based halting, the algorithm must be provided informa-tion about what is an acceptable solution, in terms of the fitness evaluationmethod. In this way the algorithm can check at each generation, to see if thebest solution of that generation exceeds the acceptability levels, and halt if it

18

Page 19: MSc Dissertation - Matthew Sparkes

does. If not then the algorithm simply proceeds with the next iteration of thegeneration loop. This acceptability level can be set to a certain value, derivedfrom the user, or it can be derived by some algorithm within the system, thatensures bounded in-optimality.

4.6.3 Progress Based Halting

Another method that can be used is to monitor the progress that the algorithmis making, in terms of numerical improvements correlating to the fitness of thebest solution of each successive generation. This progress can be recorded andanalyzed, in order to determine the most reasonable time to stop the algorithm.It is highly likely that the algorithm will go through a very short initial phaseof confusion, especially if the initial population was randomly generated andextremely varied, and then go through a period of rapid improvement, beforetailing off in a curve.

There will be exceptions to this curve, in that mutation will occasionally throwup a new solution that avoids a local optimum, and causes a period of noticeablegrowth again. However, there will come a time when the progress that thealgorithm makes will be negligible. This can be used as a halting strategy inmany ways, for example the algorithm could be instructed to halt if 3 successivegenerations did not improve the best solution by more than 1%.

19

Page 20: MSc Dissertation - Matthew Sparkes

5 Current Applications of Genetic Algorithms

Genetic algorithms have been very successful in their transfer from academia toreal world application. They can now be found in use in most large companiesin some way, in a variety of uses. Normally a technology must be adapted foreach and every use, but by their very nature GAs do not require this; they areinherently flexible.

Theoretically all one must do to adapt a GA to a certain problem is to designa genetic representation for solutions, and write a fitness evaluation functionfor those solutions. The rest of the system will have been duplicated manytimes before, and commercial and open source packages are now available thatallow quick and simple building of GAs. Although the crossover operators etcin this package may not be optimum for a given solution they will operate, andallow a solution to be found. Some packages allow these operators and muchmore to be customized, and others only allow the very minimum of change; therepresentation and fitness function.

5.1 Code/Cipher Decryption

The set of all possible decryptions can be thought of as a search space, containingone correct decryption, and therefore can be made suitable for solving with agenetic algorithm.

5.2 Resource Allocation in Communication Infrastructures

Mobile phone networks, Ethernet networks, and other resource allocation prob-lems are all conducive to design and maintenance by GA. The fitness functionmay be as simple as reducing the amount of clients requiring non-existent band-width.

5.3 Neuro-Evolution

Training artificial neural networks when pre-classified training data is not avail-able is an application of GA solving.

5.4 Electrical Circuit Design

21 previous patents have been either duplicated or exceeded in performanceby devices designed by genetic algorithms, showing that these algorithms arecapable of producing the same output as educated engineers. In fact 2 deviceshave been created that are original, and would be patentable if not for thefact that a computer designed them. There are patent laws that forbid thesubmission of applications for designs that have been derived by a computer.[11]

20

Page 21: MSc Dissertation - Matthew Sparkes

5.5 The Arts

Genetic algorithms have also been used extensively in research into artisticendeavors. Their evolutionary approach is conducive to work in this field, as’goodness’ of some piece of art, be it visual or aural, can be evolved, rather thanprogrammed. This is very useful when the criteria for ’good’ art are so vagueand subjective, as the fitness evaluation can be replaced by a human evaluatorinitially. There has even been work to connect the fitness function directly tophysiological signals given off by the brain, which would allow rapid evaluation.[25]

There has also been work to replicate the human capability to improvise musicalcomposition, in one case an attempt to produce jazz solos. [21][22] In oneparticular paper by Wiggins and Papadopoulos a GA was constructed where thefitness of solutions was calculated by several individual methods that analysedthe solution for certain criteria; the amalgam of these figures then went to createthe overall fitness. By using these sectional evaluators the problem was brokendown into understandable rules. However, this research produced little in theway of listenable output. [22]

Better output has been achieved in other systems, where the fitness evaluatorsare more appropriate, or where human evaluation is also made part of the se-lection process. [24] Some systems have even been advanced to the point wherethey can generate short pieces in real time, and take a real players response asinput, to dynamically update the fitness function. Computer generated musichas received much media attention in the past, which will undoubtedly lead toincreased funding for research, and consequently an improvement in the qualityof artificial composition software. One example is a competition run by BBCRadio 3 where 3 pieces of music were played; one was genuine Bach, one wasimitation Bach written by a professor of music, and one was generated by aGA.

5.6 Gene Sequence Analysis

In a bizarre twist, genetic algorithms have also been applied to the study ofgenetics. In sequence analysis, two or more gene sequences are analysed inorder to discover correlations. In this way it is possible to determine whether twospecies evolved from a common ancestor. [17] Genetic algorithms can be usedin this field, to discover correlations in a relatively fast time, as the sequenceanalysis problem is NP-hard. The genes of the GAs solutions will thereforerepresent actual genes, and the abstract concept borrowed from evolutionarybiology is put to work back in the field it came from. [28] Many algorithms thatdo not utilise GAs are already in exisence, such as BLAST and FASTA, but theGA package SAGA (Sequence Alignment by Genetic Algorithm) has proven tooutperform these in speed to optimality. [26][27]

21

Page 22: MSc Dissertation - Matthew Sparkes

5.7 Physical Engineering Design

Optimum shapes for antennaes, coils, pipe bends, car/aircraft/ship bodies tominimise drag

5.7.1 JET/ITER Fusion Reactors

Experiments in fusion reaction have heavily used GAs. THe extreme conditionscreated by the experiements are unprecedented, and created many optimisationproblems. To contain the plasma created in fusion, massive magnets are usedas the heat of the plasma prohibits its interaction with any material. Theseenormous magnets distort the machine itself. Two schools of thought existed toovercome this problem; one was to sink the entire machine into a vast concreteanchor, prohibiting magnetic distortion, and the other was to use GAs to de-termine the optimum shape to avoid this distortion - make the ring the shapeit wants to be under distortion. ITER/JET fusion experiment toroidal sectionshape

Figure 5: An example of single point crossover.

22

Page 23: MSc Dissertation - Matthew Sparkes

6 Competing Techniques to Genetic Algorithms

Simulated Annealing is a technique based on the way that metallurgists repeat-edly heat and cool metal to increase the size of its constituent crystals. Oneeach heating and cooling cycle the metal becomes slightly stronger, and thecrystalline structure slightly larger. This can be thought of as repeated escapesfrom a local optimum, where the variable to be maximised is the strength ofthe metal.

In simulated annealing a variable T mimics temperature, and is gradually re-duced. The solution can be altered or not, based on a probability linked to T.Just as in real annealing, the solution (arrangement of atoms in the metal) ismore likely to change at a high T (temperature), and less so at lower T values.The solution can move to one of several neighbours of the current solution. Thedefinition of neighbour is problem-specific, but would normally involve a slightdeviation.

Ant Colony Optimisation is a metaheuristic for solving combinatorial optimiza-tion problems. It was developed by Colorni et al in the early 1990s and isbased on the way that ants convey information about route efficiency to eachother.

The idea is based on the way in which ants discover the most efficient pathbetween the colony and a food source and vice versa. This is achieved by layinga trail of pheromones at each decision point in the journey, that is, where thereis more than one possible route.

The shortest route will be utilised more as the time taken to cross that pathwill be shorter; therefore the amount of pheromone build up will be greater onthis route. Other ants decide which route to take based upon the amount ofpheromone detected at that decision point. The shortest route will be moreoften travelled and pheromone build up will be higher until eventually all antstake this route. This is a form of autocatalysis, or positive feedback.

Particle swarm optimisation works by exploring a solution space simultaneouslywith a large number of particles. Each of these has access to it’s best positionduring the search, as well as the best position by any particle. It can use thisinformation to make intelligent decisions on where to explore next. [19]

23

Page 24: MSc Dissertation - Matthew Sparkes

7 Introduction to Skin and Proximity Effect

7.1 The Chosen Application

This project takes the GA method of solving combinatorial optimisation prob-lems, and applies them to a specific electronic design problem, proximity andskin effect in conductors.

In DC there is no such problem, as current is evenly distributed throughoutthe conductor. But in AC there is a skin effect, which distorts the distributionof current. In the conductor, the current density is non-uniform due to thisphenomenon, conventionally denoted as S. The current density, J, is strongeston the surface and drops off towards the centre.

Figure 6: Current density in a conductor, showing skin effect.

Proximity effect works in much the same way, but is the force that distortscurrent distribution in a nearby conductor, rather than the surface of one. Bothof these effects are caused by the electromagnetic forces present in a circuit.[5] The equations necessary to calculate the effect of skin and proximity effectin a pair of DC conductors has been calculated in a paper by Murgatroyd andHillen, and it this work on which this project will be based. [5]

There will be differences though, in that the fitness value used in the project willnot be as complex as in the paper, but will be a new approach, using a rangefrom the best to worst points on each solution. In this way the current densitycan be caused to become more uniform, without having to perform much of thecalculations. This should greatly increase the implementation speed, and alsothe computation speed as the code will be less computationally intensive.

The English engineer Arnold proved that if conductors were thin tapes, thenthey could be optimized in shape. These calculations were done in 2-phase,but little work has been done in 3-phase. This project aims to create optimalsolutions using GAs. [?]

24

Page 25: MSc Dissertation - Matthew Sparkes

7.2 Representation in GA

The problem of how to represent the problem within the system is invariablyone with many constraints and compromises. The model, when simulated ina digital environment, has to be measured in finite and discrete amounts. Forexample, the curve of one of the bars could be modelled exactly using vectorsor an equation.

However, to calculate the fitness, the distance from each point on one bar hasto be measured to each point on the other. To do this with an infinite amountof discrete points would take an infinite amount of time. Therefore some ap-proximation must take place, to allow the program to run effectively. Somehappy medium between time and computational efficiency, and accuracy mustbe found.

7.2.1 Representation of Bars

The bars will be represented as being composed of a finite amount of sections,defined by the user as a variable N. The bars will be 2N+1 sections in size, witha constant and fixed central bar on the X axis, and N bars extending below, andabove that section. By altering the value of N it wil be possible to increase ordecrease the accuracy or fidelity of the solutions, and to fine tune the balancebetween accuraucy and computational complexity. Each section will be c long,b thick, and l long. The bars could have been represented as a series of pointson a cartesian graph, but that would require 2 variables for each of every 2N+1points. With the proposed solution only one variable per point would be needed,which would be an angle of derivation from the vertical.

As each section is of a standard length this means that the next point canthen be calculated from this one number. Using this representation reduces theamount of data to be held in the solution, simplifying the evolution process.This simplification can be further achieved by maintaining symmetry along theX axis.

If the two bars (of equal or unequal length) are placed with their centre pointson the Y axsis at 0 then the optimum solution will be symetrical on the Xaxis. Therefore data need only be held on one half of each bar. As the centrepoint will always be placed on the Y axis at 0, and will always be placed at thevertical, it is only necesary to store the remaining N angles. The point used willactually be the centre point of each section, rather than the edge, this allowsthe first centre point to be on the X axis and for the solution to start from 0 onthe Y axis.

7.2.2 Converting Angles to Cartesian Coordinates

The internal representation of the bars is based on angles of derivation andfixed section length, however, the system will need to have cartesian valuesfor points on the bar at some parts of calculation. The fitness evaluation al-gorithms will have to be provided figures to calculate distance from point topoint on each bar, and the GUI will also need cartesian coordinate figures to

25

Page 26: MSc Dissertation - Matthew Sparkes

plot the solutions as output. Therefore some method will need to be developedthat can take a solution, with angle derivation figures for only half of the arcminus the centre section, and convert that into a full set of points for everysection. To calculate these points will make use of trigonometry, as shown here.Point Equation Point EquationX0 symbol*w/2 Y0 0X1 X0+symbol*w/2 Y1 2X2 X1+symbol*w/2 Y2 2XN X(N − 1)+symbol*w/2 YN 2

7.3 Calculating Fitness Values

The fitness value of a proposed solution will be direclty proportional to theresistance of the bars in that solution. We can calculate the DC resistance ofone section, by taking pl/bc. Where p is resistivity, taken as p=1/symbol, wheresymbol is conductivity.

26

Page 27: MSc Dissertation - Matthew Sparkes

8 Aim of Project

The aim of the project is to derive a less computationally intensive approach tocalculating the skin and proximity effect of a given solution, and to incorporatethis approach into a GA. This will then provide a faster method to designconductors than was previously possible.

This could have applications in a number of applications, but will reduce theenergy consumption of systems designed using it.

27

Page 28: MSc Dissertation - Matthew Sparkes

9 Design

9.1 Fitness Function

The fitness function will make use of the equation developed previously by Hillenand Murgatroyd. [5]

Whilst the mathematics used in the fitness function are pre-determined, theactual value to use in the GA is not. The chosen value is the range between thevalues calculated for each point. In an optimal solution each point will have thesame value, or as close as possible to the same. Therefore, by assigning a rangevalue to each solution, and minimizing this, an optimal solution should be thetarget. This approach will also offer significant performance benefits, but hasnot been attempted on this problem before, even though GAs have been appliedto it.

The equation to determine fitness values involves determining the distance be-tween points in the solution. Firstly, one of the solutions must be chosen, thenthese angles must be converted into a full set of cartesian coordinates.

Then the distance from the first point must be calculated, from each point i onthe same curve (Si) and the opposite curve (Ri).

Figure 7: Example of Ri and Si values on a given solution.

In order to find the distance between any two points on the solution, the carte-sian value for x of one point can be subtracted from the cartesian x point ofthe other. Taking the absolute value of this will provide the distance, irrespec-tive of which is taken from which. Squaring this, and adding it to the samevalue from the Y values will give the square of the overall distance. The equa-tion below shows how the distance (Rij) between two point points (i and j) iscalculated.

Rij = sqrt[(Xi - Xj)2 + (Y i− Y j)2]

28

Page 29: MSc Dissertation - Matthew Sparkes

For each point there will be distances from all of the Ri and Si points, these aresummed using this equation.

(Σlog(Si/Ri)) + ((logG)/M)

G and M are constants used to replace the instance where the distance fromone point to itself needs to be calculated. Otherwise a divide by zero error maybe encountered.

In a solution with 12 points on a curve, which is symmetrical on the X axis,then there will be 6 values from this equation. Calculating all 12 points wouldbe redundant as there is symmetry and the values would be the same. In theHillen paper there is further mathematics to determine the effect of the skin andproximity effect, but this project attempts to create a faster method.

By taking the difference between the largest and smallest of these values, the’range’ will be deduced. This can be thought of as a value that increases ascurrent density becomes less uniform, and vice versa.

By taking the absolute value of this, we can reduce the variance in currentdensity, without ever fully calculating what the current density is. The aimof the GA will simply be to get the same range value for each point on acurve.

9.2 Population Initiation

The population of solutions must be ’seeded’, or instantiated in order to givethe program a starting point. from which to derive better solutions. The loopof fitness evaluation and generation creation must be started by evaluating thefitness of some initial populations. The most effective way to do this is unclear,although there are many options to choose from.

One method, consistent with the ethos of this project, and utilising randomness,would be to create the solutions using some kind of random number generation.Another would be to have a pre-determined and human designed set of solutionswith the maximum variance. This would be a set of solutions that occupy awide range of the solution space. One benefit to the human-designed method isthat many solutions could be placed, with deliberate qualities that are designedto avoid local optimums from the start.

However, these variant solutions would quickly leave the population as the al-gorithm progressed, as they are replaced by fitter solutions. Even if a problemhad a quality that would prove to be ultimately desirable, it would still beculled in the presence of a fitter solution - no matter how local an optimum thisreplacement may occupy.

There could also be many ways in which to automatically generate a wide rangeof solutions, for example, cumulative curving. Because the solutions are repre-sented by a set of angles from the vertical, it would be possible to write codethat generates curves of increasing but varied extremity. Solution 1 could be(n*m) degrees, where n is the number of the point in the solution and m is someconstant. Solution 2 could be (n*(2*m)), and so on. This would automaticallygenerate a wide range of initial solutions.

29

Page 30: MSc Dissertation - Matthew Sparkes

Solution Number Equation1 (n*m)2 (n*(2*m))3 (n*(3*m))4 (n*(4*m))5 (n*(5*m))6 (n*(6*m))7 (n*(7*m))8 (n*(8*m))9 (n*(9*m))10 (n*(10*m))

Does it even make much difference? Random population, designed variant pop-ulation, or some other strategy? What technique should be used? In orderto examine which technique for initializing the solutions is most effective, itwould be beneficial to have an easy method to change the data. To this endthe program will read in the initial solutions from a text file. This will allowfaster experimentation than with altering hard-coded values and re-compiling.If calculation is required in order to determine initial values then this file inputcan be easily over-ridden.

9.3 Population Size

With the population size there are two main possibilities; to have variable pop-ulation size, or to have a fixed size. With a variable size population, the sizewould be determined by the user, or by some algorithm that would analyze theproblem to determine the best size. However, it is unlikely that a user, or an al-gorithm would be able to determine the optimal size for a given problem.

9.4 Halting

Initially, during development, the algorithm will use a very simple halting strat-egy, based on the number of generations. The halting code will be placed in amethod, and a switch case structure will be used so that various halting strate-gies can be implemented, and selected by the user from the GUI.

9.5 Selection

There is a significant advantage involved with keeping good solutions from onegeneration to the next. For example, if the best solution from each generationremains in the subsequent one, then there is an inherent guarantee that eachgeneration will be an improvement, which means that the algorithm can onlymove towards optimality in the sense of the best solution. Other solutions maymutate and output a lower fitness value however.

30

Page 31: MSc Dissertation - Matthew Sparkes

9.6 Mutation

9.6.1 Variable Mutation Rate

The mutation rate is an important setting in a GA. With a mutation rate thatis too low, there will be a very short amount of random jumps in the solutions.Although the crossover method will create ’intelligent’ changes, taking desirabletraits from each preceding generation, there can be no improvement on what isalready there.

Mutation is needed to duck from under local optimums and find new strategiesthat may or may not be included in solutions. If the mutation rate is too low thenyou will see results where the best solution is the same for many generations,because the program is waiting for some jump that can lead it closer towardsoptimality.

However, with a mutation rate that is too high there are equally importantproblems. If mutation is excessive then all of the promising solutions in ageneration may be changed, causing a backwards movement in optimality. Thiscan be prevented to some extent, by retaining a copy of the best solutions, andmaking them except from mutation. However, the risk of promising solutionsbeing overwritten still exists.

This problem will always be present in some level, and mutation will always’destroy’ some possibly beneficial traits, perhaps before they have had a chanceto propagate through into other solutions within the population. This is theprice of evolution, and is present in natural evolution as much as simulatedalgorithms. Within natural ’bad’ mutants there would be no natural ’good’mutants, and hence no evolution.

Mutation is a dangerous but vital process, and the program must strike a happymedium, reducing the loss from overwriting to a minimum, but retaining thepowerful ability to find new strategies. One anticipated issue is the mutationrate used by the algorithm. If the algorithm was to use a fixed mutation rate,then there would be issues on getting close enough to solutions.

For example, consider a problem domain that used integers, and could onlymutate by adding or subtracting 5 to this value. If the optimum value was 7,and the intial value 0, then the algorithm would clearly reach either 5 or 10,but never be able to get a closer solution, as the solutions could only occur inthese discrete segments.

To solve this problem the algorithm will use variable mutation rates. Initially,the algorithm would use a mutation rate that was fairly large, and as algorithmprogressed, the mutation rate would decrease to allow finer solutions. The rateat which this is decreased could be controlled in numerous ways, such as bygeneration number, or run-time.

However, the best method is expected to be linked to fitness, as this providesa concrete link to the revealing of a better solution. As the algorithm reachesa better solution, the mutation rate is decreased. It should be noted that bymutation rate, it is meant the discrete size of each mutation, rather than thefrequency at which mutation should occur.

31

Page 32: MSc Dissertation - Matthew Sparkes

9.7 Logging Features

Logging is a feature that can be implemented relatively simply, but choosingthe information to be logged is not so trivial. Storing all available information isnot a feasible option, as the amount of data would soon be overwhelming

9.8 Implementation Language Choice

Java was chosen. Good graphics capabilities, rapid development.

9.9 GUI Design

The main feature of the GUI must be the solutions, that intuitive ability tosee them helps, SHould all solutions be shown? Dependent upon solution sizethere could be many, but at least 8ish. Decided that the best solution onlyshould be shown, as solutions would become similar within a few generationsanyway. Other essential elements of the GUI are the generation number, andmetrics about the solutions like number of points, length of conductor segments(equivalent to conductor size), symmetry constraints.

9.9.1 Drawing the solutions

The solution representation is a set of angles, which represent the angle fromthe vertical of that segment. Therefore, before the solutions can be drawn to thescreen, this data must be converted into cartesian coordinates. Each segmentcan be calculated using trigonometry, as the length of each segment and oneangle is known. This can then be added to the coordinates of the previouspoint, in order to create a chain of points. The table below shows how eachpoint will be calculated, where d is the required spacing between the Y axis andthe apex of the curve, and c is the length of each segment.

Point X Value Y Value1 d c/22 x value of point 1 + c sin angle y value of point 1 + c cos angle3 x value of point 2 + c sin angle y value of point 1 + c cos anglen x value of point n-1 + c sin angle y value of point n-1 + c cos angle

9.9.2 Colour Use

Colour use could be important, and the solution arc could be coded, with badpoints red, and good points blue. Where bad points are the highest loss points,or the hottest points. The colours could be assigned in numerous ways, forexample the N/3 hottest points, where N is the number of points in a solutionarc could be red, and the same amount blue, with the other third black.

32

Page 33: MSc Dissertation - Matthew Sparkes

10 Implementation

10.1 GA Prototype - Word Finder

10.1.1 Introduction

A trivial program was devised as a proof of concept for Genetic Algorithms.It’s purpose was both to prove that the theory of genetic algorithms was sound,and to provide a proven framework within which to create the more complexproximity effect GA. The program simply used text strings as solutions, andaimed to create a specific string. It was initialized with a random population,and attempted to create a pre-determined word by using single point crossoverand mutation.

10.1.2 Design

The design of the program was very simple; there would be 10 solutions in apopulation (this size was chosen arbitrarily, but was even to allow crossoveroperations to be paired). At each generation all 10 would be analysed by afitness variable and assigned a fitness value, to be stored in an integer array.This fitness would simply be the number of characters in a given solution thatmatch the same position in the optimal solution. For example, the solution ’aa’in a program searching for ’ab’ would have a fitness value of 1, and ’ab’ wouldhave a fitness value of 2.

10.1.3 Implementation

The program was implemented with a fitness value that compared each solutionto the optimal, and calculated the number of matching characters. The haltingalgorithm simply stopped the program once the fitness value matched that ofthe character length of the optimal string (and therefore also the length of eachproblem solution in the population).

// Takes a solution and optimal solution, and returns// number of matching characters.public static int evaluateFitness(char[] solution, char[] optimal)

// Number of matching charactersint matches = 0;

// Count matches against goalfor(int i=0;i¡6;i++)

if (solution[i] == optimal[i])

matches++;

33

Page 34: MSc Dissertation - Matthew Sparkes

// If we have reached optimality, set flagif (matches == 6)optimality = true;

// Return fitness valuereturn matches;

Because the solution representation is simply a character string, it was unimpor-tant how crossover was implemented. In order to keep the code simple, singlepoint crossover was used. The length of solutions was set at 6 characters, andcrossover took 3 characters from each solution to be altered. The program tookthe best 2 solutions, and created two new solutions from them which were placedin the positions previously used by the two worst performing solutions. Thisapproach achieved two things; firstly it acted as natural selection, removing theleast desirable solutions, and secondly it allowed the previous two best solutionsto remain. These should never be overwritten, as it would allow the algorithmto back-track and create worst solutions.

10.1.4 Results

Appendix 12.2 shows a typical output from the program, which has a demon-strated 100% success rate in achieving optimality. This was expected however,given the trivial nature of the problem, and the indiscrete nature of the repre-sentation - an optimal solution can have only one value. Figure 10 shows typicaloutput from this test program.

Figure 8: Example output from the text GA prototype.

Following the satisfactory results of the implementation, some changes weremade to the program in order to allow the next stage of development. Some ofthese were trivial updates such as a GUI, and others were slight improvements

34

Page 35: MSc Dissertation - Matthew Sparkes

to the layout and organisation of the program, as well as improvements uponthe actual algorithm.

A GUI was added at this point, as having one in place that was proven tobe functional would be a massive advantage in programming the next stage ofimplementation.

When writing the proximity effect solver it would be vital to be able to see theoutput in order to debug any problems, such was the reasoning behind writingthe graph drawing program separately. Having this GUI would enable these twoprograms to be combined to allow an effective development platform.

35

Page 36: MSc Dissertation - Matthew Sparkes

10.2 Proximity and Skin Effect Genetic Algorithm

10.2.1 Solution/Curve Representation

The solution would represent a curve, which would be the shape of the conduc-tor. Obviously this cannot be represented in its true form with any practicality,and some approximation would have to take place. Therefore the curve wouldbe broken down into modular sections, consistent in size and area. These wouldform a chain that approximated the shape of the curve. The program would al-low these modules to be scaled up or down, in order to raise the accuracy of theprogram. Once a working system had been proven then the modules could bereduced in size to the point where the loss of information in the approximationbecame negligible, and hopefully smaller than the gain in efficiency arising fromusing a GA, in order to provide an overall improvement in circuit conductionefficiency.

These modular sections would be placed in 2D space by describing the loca-tion of their centre point. The angle of derivation from the vertical would beused to store the direction information, as one number can be used insteadof two sets of cartesian coordinates, as would be needed under a graph basedrepresentation.

It would be assumed that one module would always be placed at the same point,and that two chains of modules would extend from its extreme edges. Therefore,by having a fixed position ’root module’ and angle-of-derivation direction infor-mation it should be possible to represent a curve of N modules with an array ofN-1 integers. This is a very sparse representation to a complex solution, whichis beneficial in the case of GAs, in order to reduce the complexity of the fitnessevaluation function.

10.2.2 Implementation Plan

With a trivial problem, such as the word finder GA, it is very simple to un-derstand the internal actions of the system. The data itself is also very humanreadable, as the representation was plain text. Therefore judging the progress ofthe program was extremely intuitive. However, the final implementation, wherethe GA would be adapted to solve the skin and proximity effect problem, wouldbe very different in this respect.

Instead of a solution being comprised of a short alpha-numeric string it wouldbe an array of angular data referring to the difference from vertical of severalpoints on a curve. Looking at this information ’with the naked eye’ is of verylittle use, and some processing would be needed to aid comprehension.

Therefore, the first part of implementation would be a GUI with a graphicalrepresentation of each curve as it progressed through the generations. Thisfirst module would take test data in the form of the final program’s solutionrepresentation, and draw the curve that it described.

Once that module is working it will be possible to create a genetic algorithmaround this, with a set of solutions, crossover and mutation methods and an

36

Page 37: MSc Dissertation - Matthew Sparkes

empty fitness function. The fitness function at this stage will return a randomnumber as a fitness value. This will not impact on the rest of the program, butwill allow testing of the mutation and crossover code to take place.

Once this is working, the random number generator in the code can be replacedby the correct algorithm to calculate proximity and skin effect of a given solution.At this point the program should progress towards the optimum, rather thanrandomly jumping around the solution space.

10.2.3 Results

The program does work towards a certain shape, which immediately shows thatthe genetic algorithm is working towards some ideal fitness value. The importantresult is that it also produces shapes that are exactly what one would expectfrom the previous work on proximity and skin effect.

Figure 9: Example output from the GA.

In the figure below the results from several calculations have been amalgamated.This figure clearly shows that the results closely follow that of the Hillen paper,where the conductors become more curved the further they are from each other.This is because the proximity effect reduces, whilst the skin effect remains. Theoptimal configuration for a single conductor is a closed circle, and the larger thedistance between the two, the more closely the solution should resemble this.[5]

37

Page 38: MSc Dissertation - Matthew Sparkes

Figure 10: Output from the GA, with w values of 0,1,2,3,4 respectively.

10.2.4 Possible Improvements

There are several improvements that could be made to the code, in order toproduce more accurate results, and to improve the maintainability of the code.The initial code was written to use 6 points to represent each quarter-curve ofa solution. A larger amount of points could be used, and this would increasethe accuracy of the solution. This work has actually been undertaken, and thecode altered to allow a user-defined number of points, but the results tend to’clump’ together. Initially the solution progresses as one would expect up to acertain point, when the solution folds in on itself. Often, the points that exceedthe initial six overlay the solution one would expect from a solution representedby 6 points. Obviously the fitness function would also need some adjustmentin order to function properly, and a simple piece of code that doesn’t allowmore than one point to occupy the same space would suffice to stop this fromoccurring.

Another improvement which could be very useful would be the ability to importproblems and user-defined settings from a file. The code did make use of this,but based upon a simple text file where each value was placed on a new line.This quickly became confusing to edit, and it was simpler to edit problems in thecode itself, even if there was a time overhead in re-compiling and running. Onepossible method that could overcome this would be to use an XML file, and tocreate a simple GUI editor for this. This would allow the user to save problems,edit existing ones, and also to output results. Improve architecture

38

Page 39: MSc Dissertation - Matthew Sparkes

10.3 Further Research

10.3.1 Counter-Balanced Mutation

If one point on one solution is mutated, then the magnitude of that changevaries depending on where that point lies. The closer to the centre of the curvethe point is, the more it will alter a given solution. If the last point is altered,then that change will only affect the last segment. If the very first curve isaltered though, it will affect the placement of every other point, as the root ofall segments is the end of the previous segment. One avenue for further researchwould be to develop some form of counter-balanced mutation, where a changeis accompanied by changes to successive angles, in order to try and retain theirtraits. This could be as simple as an equal change in the opposite direction inthe N+1 point, or a gradual series of changes over the remaining points thatsums to the opposite of the mutation change.

10.3.2 Meta-Testing - Automation of Design Refinement?

Many of these proceeding tests highlighted benefits and shortcomings of partic-ular strategies. However, the intrinsic weakness of these are that the differentoptions (initiation, mutation and crossover strategies) do not work atomically.One cannot decide the best method of initiation, apply it, and then move on todiscover the best crossover strategy. These variables work in unison in incredi-bly complex ways, and present emergent behavior. Effectively they represent acombinatorial optimisation problem of their own.

Since GAs are a method of solving these an interesting hypothesis emerges -could a GA be devised that could discover the best settings for a particular GA?Theoretically this would accept a problem description as input, and generatea random population of GA settings. This strategy would present inherentproblems. The concept of GAs is that they are readily applicable to any problemwithin a certain scope. A GA designed to find the word ’Monkey’ could easilybe altered to evolve the word ’Simian’. However, running a GA to find the mostoptimum settings for a particular GA would be so computationally intensivethat it would become ineffective. The original GA would have to be run oncefor each combination of settings. In a simple program with 5 settings, eachwith 5 options this would require 5! runs of the original program. It would befar more efficient to run the original GA, even with inefficient settings, once inorder to solve the problem at hand.

It is theoretically possible that a metahuerisitc fitness function could be designedthat could evaluate the fitness of a GA without running it, although this wouldbe problem-specific. It has been hypothesized that random creation could beused to create complex programs entirely from scratch without human input,again this is theoretically possible. However, it could take a massively largeamount of attempts, and these would all need to be tested for correctness - atask that would take an enormous amount of time. In essence, an infinite amountof monkeys, sitting at an infinite amount of computers with a Java IDE, couldcreate an optimal GA strategy - but it would take an infinite amount of timeto assess which one it was.

39

Page 40: MSc Dissertation - Matthew Sparkes

Despite these issues it may be useful to discover whether this hypothesis istrue, whether a GA can be used to create the optimal settings for another GAsvariables. Having the optimum GA strategy could be useful knowledge. Itcould be used as a benchmark against which other strategies could be assessed.A GA could randomly generate settings, and if they fell within a certain fitnessthey could be used. It could be a metahuersitc for determining whether ametahueristic is appropriate - a metametahueristic.

10.3.3 Experiment in Metametahueristics

The basic strategy for the experiment would be to place the curve GA in aclass, and import that class into the text based GA program. From here thecode for the the text based GA would be altered. Instead of storing a word ineach solution, the program would store values for each variable in the curve GA.The fitness evaluation of the text based GA would involve feeding that solutionsvariables into the curve GA, running that algorithm, and storing the time takento complete the solution to the optimality requirements of that program. Thistime would then be used as the fitness value, and it would be the task of thenew meta-GA to reduce that value to a minimum. In this way it should bepossible to determine the best settings for that GA.

40

Page 41: MSc Dissertation - Matthew Sparkes

11 Conclusion

11.1 Project Results

The use of GAs was examined with a trivial problem, to find a certain string ofalphanumeric characters. This code was a success, and proved that GAs wouldbe feasible on my chosen platform.

The code was then created for skin and proximity effect problems, and theresults show that the solutions provided fit very closely with the results fromthe Hillen paper. [5] The fitness function therefore returns accurate values. Theinnovative approach to calculating fitness values without performing all of thecalculations outlined in the Hillen paper also worked.

This project was able to reduce the computational overhead inherent in solvingthis problem, and therefore speed up the calculation. It would be an interestingstudy to fully implement the calculations described in that paper, and performsome performance related tests on the two. This would enable a comparison,and therefore a mathematical analysis of the improvement.

11.2 Real-World Benefits

This research could be used in the design of circuits where applicable, andwould maximise the efficiency of that circuit. By reducing proximity and skineffect, the power consumption of the circuit would be reduced. In the currentenvironmental situation this is extremely pertinent. Metahueristic techniquescan and must be used to design electrical circuits as intelligently as possible,especially where a product will be mass-produced.

11.3 Adaptability to Other Problems Spaces

Can GAs solve other problems? Section 5 of this document shows that thereare many spaces where they are already working. They are adaptable to anyproblem where the fitness of a solution can be measured. There is nothing moreadaptable than evolution.

41

Page 42: MSc Dissertation - Matthew Sparkes

References

[1] Jaron Lanier, One-Half of a Manifesto: Why Stupid Software Will Save theFuture from Neo-Darwinian Machines. WIRED Magazine, Issue 8.12, pp.158-179, December 2000.

[2] Gautam Naik, Back to Darwin: In Sunlight and Cells, Science Seeks An-swers to High Tech Puzzle, The Wall Street Journal, January 16th 1996.

[3] A. H. M. Arnold, Proximity Effect. 1936.

[4] Bundy, Alan (Ed.), Artificial Intelligence Techniques; A ComprehensiveCatalogue. Springer Publishing, Section 104.

[5] Richard Dawkins, The Blind Watchmaker Penguin Books, 1986.

[6] Paul Murgatroyd, S. Hillen, Minimum loss sections of flat conductors. IEEProceedings, pp. 127-133, Vol. 136, Pt. A, No. 3, May, 1989.

[7] Sharon Begley, Gregory Beals, Software au Naturel. Newsweek, pp. 70-71,May 8th 1995.

[8] Ariel Dolan, GA Playground Documentation,www.aridolan.com/ga/gaa/gaa.html, 9th December 2006

[9] Jaron Lanier, One-Half of a Manifesto: Why Stupid Software Will Save theFuture from Neo-Darwinian Machines. WIRED Magazine, Issue 8.12, pp.158-179, December 2000.

[10] David Pescovitz, Monsters in a Box. WIRED Magazine, Issue 8.12, pp.340-347, December 2000.

[11] Davis, Lawrence, The Handbook of Genetic Algorithms. Van Nostrand Rein-hold, New York, 1991.

[12] Koza, John R., Jones, Lee W., Keane, Martin. A., Streeter, MatthewJ., and Al-Sakran, Sameer H. Towards Automated Dewsign of IndustrialStrength Analog Circuits by Means of Genetic Programming. Kluwer Aca-demic Publishing, Genetic Programming Theory and Practice 2, Chapter8, pp. 121-142, 2004.

[13] David E. Goldberg, Department of General Engineering, University of Il-lionois at Urbana-Champaign, From Genetic Design and Evolutionary Op-timization to the Design of Conceptual Machines. IlliGL Report No. 98008,May 1998.

[14] Michael R. Garey, David S. Johnson, ”Computers and Intractability - AGuide to the Theory of NP-Completeness”, Bell Laboratories, New Jersey,1979.

[15] Bryan Sykes, The Seven Daughters of Eve, Corgi Publishing, 2001.

[16] Wikipedia - The Free Encyclopedia, Entry for Genetic Algorithm,en.wikipedia.org/wiki/Genetic-algorithm, March 2006.

[17] Wikipedia - The Free Encyclopedia, Entry for Crossover Strategies,en.wikipedia.org/wiki/Crossover-genetic-algorithm, March 2006.

42

Page 43: MSc Dissertation - Matthew Sparkes

[18] Wikipedia - The Free Encyclopedia, Entry for Sequence Analysis,en.wikipedia.org/wiki/Sequence-alignment March 2006.

[19] Wikipedia - The Free Encyclopedia, Entry for Mutation Strategies,en.wikipedia.org/wiki/Mutation-genetic-algorithm, March 2006.

[20] Wikipedia - The Free Encyclopedia, Entry for Particle Swarm Optimisa-tion, en.wikipedia.org/wiki/Particle-swarm, March 2006.

[21] Gautam Naik, Back to Darwin: In Sunlight and Cells, Science Seeks An-swers to High Tech Puzzle, The Wall Street Journal, January 16th 1996.

[22] Biles, J, GenJam: A Genetic Algorithm for Generating Jazz Solos. Pro-ceedings of the 1994 International Computer Music Conference. Aarhus,Denmark: International Computer Music Association. 1994.

[23] George Papadopoulos and Geraint Wiggins, A Genetic Algorithm for theGeneration of Jazz Melodies, citeseer.ist.psu.edu/87682.html

[24] Ehrlich and Holm, The Process of Evolution McGraw-Hill Publications,1963.

[25] Bruce L Jacob, Composing With Genetic Algorithms, University of Michi-gan, International Computer Music Conference, Banff Alberta, September1995.

[26] Website for European Workshop on Evolutionary Music and Art,http://evonet.lri.fr/eurogp2006/

[27] BLAST Website, http://www.ncbi.nlm.nih.gov/BLAST/

[28] FASTA Documentation, University of Virginia,ftp://ftp.virginia.edu/pub/fasta/README

[29] Cedric Notredame & Desmond G. Higgins, SAGA: Sequence Alignmentby Genetic Algorithm, EMBL outstation, The European BioinformaticsInstitute, Cambridge, March 4, 1996.

[30] West Lafayette, Genetic Algorithms ’naturally Select’ Better Satellite Or-bits, http://www.spacemart.com/reports/Genetic Algorithms naturally Select Better Satellite Orbits.htmlOct 15, 2001.

[31] NASA Website, Exploring the Universe -Evolvable Systems,http://www.nasa.gov/centers/ames/research/exploringtheuniverse/exploringtheuniverse-evolvablesystems.html

43

Page 44: MSc Dissertation - Matthew Sparkes

12 Appendix

12.1 Source Code for GA Word Finder

This is the code listings for the word-finder Genetic Algorithm. This code isJava, and was developed on JEdit on a Unix/Mac OS platform.

44

Page 45: MSc Dissertation - Matthew Sparkes

12.2 Example output from GA Word Finder

The following is a list of the best (highest fitness values) of each generation ina typical run of the text based GA. The output is not extraordinary in anyway, and was of the type expected. The goal state is the word ’MONKEY’, andthe initial state was randomly generated. The best initial state happened to be’PENEEp’.

45

Page 46: MSc Dissertation - Matthew Sparkes

0:PENEEp 42:HENEEB 84:MCNTEB 126:MCNCEB 168:MWNKEP1:PENEEp 43:GENGEB 85:MCNTEB 127:MCNCEB 169:MWNKEP2:PENEEp 44:HENGEB 86:MCNTEB 128:MCNCEB 170:MWNKEP3:PENEEp 45:GENGEB 87:MCNLEB 129:MCNCEB 171:MWNKEP4:PENEEB 46:GENEEB 88:MCNLEB 130:MCNCEB 172:MWNKEP5:PENEEB 47:GENEEB 89:MCNPEB 131:MCNCEB 173:MWNKEO6:PENEEB 48:HENEEB 90:MCNPEB 132:MCNCEB 174:MLNKEO7:PENEEB 49:GENEEB 91:MCNQEB 133:MCNCEB 175:MLNKEO8:PENEEB 50:NENEEB 92:MCNQEB 134:MCNCEB 176:MUNKEO9:PENEEB 51:GENEEB 93:MCNPEB 135:MCNCEK 177:MUNKEP10:PENEEB 52:MMNEEB 94:MCNCEB 136:MCNCEK 178:MUNKEP11:PENEEB 53:MMNEEB 95:MCNCEB 137:MLNCEK 179:MUNKEP12:PENEEB 54:MMNEEB 96:MANCEB 138:MCNCEK 180:MUNKEW13:PENEEB 55:MMNEEB 97:MANCEB 139:MCNLEU 181:MUNKEP14:PENMEB 56:MMNEEB 98:MCNCEB 140:MLNLEU 182:MUNKEP15:PENMEB 57:MMNEEB 99:MANCEB 141:MTNLEU 183:MUNKEP16:PENMEB 58:MMNEEB 100:MCNCEB 142:MTNLEK 184:MUNKEP17:PENEEB 59:MMNEEB 101:MANCEB 143:MTNLEK 185:MUNKEP18:PENEEB 60:MMNLEB 102:MANCEB 144:MTNLEK 186:MUNKEY19:PENEEB 61:MMNLEB 103:MANCEB 145:MLNLEK 187:MUNKEY20:KENEEB 62:MMNLEB 104:MANCEB 146:MLNLEK 188:MUNKEY21:KENEEB 63:MMNLEB 105:MCNCEB 147:MLNLEK 189:MUNKEY22:KENEEB 64:MMNEEB 106:MCNCEB 148:MLNLEK 190:MUNKEY23:KENEEB 65:MMNEEB 107:MCNCEB 149:MLNLEK 191:MUNKEY24:KENEEB 66:MMNIEB 108:MCNCEB 150:MUNBEK 192:MUNKEY25:KENEEB 67:MCNIEB 109:MCNQEC 151:MUNBEK 193:MUNKEY26:KENEEB 68:MMNIEB 110:MCNQEC 152:MUNBEC 194:MUNKEY27:KENEEB 69:MMNIEB 111:MCNQEC 153:MUNCEC 195:MUNKEY28:KENEEB 70:MMNIEB 112:MCNQEC 154:MUNCEP 196:MUNKEY29:KENEEB 71:MCNIEB 113:MCNCEB 155:MUNCEP 197:MUNKEY30:HENEEB 72:MCNLEB 114:MCNCEB 156:MUNCEP 198:MUNKEY31:HENEEB 73:MCNIEB 115:MCNCEB 157:MUNCEC 199:MUNKEY32:HENEEB 74:MCNIEB 116:MCNCEB 158:MUNCEC 200:MHNKEY33:HENEEB 75:MCNIEB 117:MCNCEB 159:MUNCEC 201:MHNKEY34:HENEEI 76:MCNLEB 118:MCNCEB 160:MUNCEC 202:MHNKEY35:HENEEI 77:MCNLEB 119:MCNCEB 161:MUNCEC 203:MHNKEY36:HENEEB 78:MCNLEB 120:MCNCEB 162:MWNCEP 204:MONKEY37:HENEEB 79:MCNLEB 121:MCNCEB 163:MWNCEP38:HENEEB 80:MCNLEB 122:MCNCEB 164:MWNCEP39:HENEEB 81:MCNLEB 123:MCNCEB 165:MWNCEP40:HENEEB 82:MCNLEB 124:MCNCEB 166:MWNKEP41:HENEEB 83:MCNSEB 125:MCNCEB 167:MWNKEP

46

Page 47: MSc Dissertation - Matthew Sparkes

12.3 Source Code for GA

This is the code listing for the proximity and skin effect Genetic Algorithm. Thiscode is Java, and was developed on JEdit on a Unix/Mac OS platform.

47