You are on page 1of 47

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 matt.sparkes@gmail.com

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

Contents

1 Acknowledgments and Foreword

 

4

2 Introduction to Genetic Algorithms

 

5

2.1 What is a Genetic Algorithm? .

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

5

2.2 Natural Selection and Mutation in Nature

 

6

2.3 Evolution as a Paradigm for Problem Solving

 

.

.

.

.

.

.

.

.

.

.

.

7

3 The History of Genetic Algorithms

 

8

3.1 The Birth of GA

 

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

8

3.2 Problems Associated with Genetic Algorithms

 

8

3.2.1 Complexity and Reliability

 

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

8

3.2.2 Legal, Ethical and Moral Issues

 

9

4 Anatomy of a Genetic Algorithm

 

10

4.1 Encoding and Population Size .

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

10

4.2 Crossover Operations

 

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

11

4.2.1 Single Point Crossover

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

11

4.2.2 Double Point Crossover

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

12

4.2.3 Cut and Splice Crossover

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

12

4.2.4 Uniform Crossover

 

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

12

4.3 Mutation Operations

 

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

14

4.4 Fitness Evaluation

 

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

15

4.5 Population Initialisation

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

16

4.5.1 Pre-Defined Variance

 

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

16

4.5.2 Randomly Generated Solutions

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

17

4.5.3 Evenly Spaced Solutions . .

.

4.6 Halting

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

17

18

4.6.1 Resource Based Halting

 

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

18

4.6.2 Solution Fitness Based Halting

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

18

4.6.3 Progress Based Halting

 

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

19

5 Current Applications of Genetic Algorithms

 

20

5.1 Code/Cipher Decryption .

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

20

5.2 Resource Allocation in Communication Infrastructures

 

20

5.3 Neuro-Evolution

 

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

20

5.4 Electrical Circuit Design .

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

20

5.5 The Arts

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

21

5.6 Gene Sequence Analysis

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

21

5.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

 

24

7.1 The Chosen Application

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

24

7.2 Representation in GA

 

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

24

7.2.1 Representation of Bars .

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

25

7.2.2 Converting Angles to Cartesian Coordinates

 

25

7.3 Calculating Fitness Values .

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

26

2

8 Aim of Project

 

27

9 Design

 

28

9.1 Fitness Function

 

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

28

9.2 Population Initiation

 

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

29

9.3 Population Size

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

30

9.4 Halting

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

30

9.5 Selection .

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

30

Mutation

9.6 .

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

31

 

9.6.1

Variable Mutation Rate

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

31

9.7 Logging Features

 

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

32

9.8 Implementation Language Choice

 

32

9.9 GUI Design

 

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

32

 

9.9.1 Drawing the solutions

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

32

9.9.2 Colour Use

 

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

32

10 Implementation

 

33

10.1

GA Prototype - Word Finder

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

33

10.1.1 Introduction

 

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

33

10.1.2 Design

 

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

33

10.1.3 Implementation .

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

33

10.1.4 Results

 

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

34

10.2

Proximity and Skin Effect Genetic Algorithm

.

.

.

.

.

.

.

.

.

.

.

36

10.2.1 Solution/Curve Representation

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

36

10.2.2 Implementation Plan

 

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

36

10.2.3 Results

 

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

37

10.2.4 Possible Improvements .

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

38

10.3

Further Research

 

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

39

10.3.1

Counter-Balanced Mutation

 

39

10.3.2

Meta-Testing - Automation of Design Refinement?

 

39

10.3.3

Experiment in Metametahueristics

 

.

.

.

.

.

.

.

.

.

.

.

.

.

40

11 Conclusion

 

41

11.1 Project Results

 

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

41

11.2 Real-World Benefits

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

41

11.3 Adaptability to Other Problems Spaces

.

.

.

.

.

.

.

.

.

.

.

.

.

.

41

12 Appendix

 

44

12.1 Source Code for GA Word Finder

 

44

12.2 Example output from GA Word Finder

 

.

.

.

.

.

.

.

.

.

.

.

.

.

.

45

12.3 Source Code for GA

 

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

47

3

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 providing the 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 on evolutionary algorithms. [4]

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

4

2 Introduction to Genetic Algorithms

2.1 What is a Genetic Algorithm?

A Genetic Algorithm (GA) is a type of metahueristic algorithm, designed to

operate on optimisation problems. Optimisation problems typically demand that a certain variable be either minimised or maximised, whilst remaining

legal within some set of constraints. These problems are often extremely large

in their nature, usually to the point of NP-hardness, which effectively means

that finding the exact or optimum solution is infeasably difficult. To enumerate every possible solution and evaluate them to determine which is the optimum would take an inordinate amount of time.

In certain applications, where optimality is not necessary, metahueristics can

be 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 the

space of all possible solutions. One such example of a metahueristic approach

is

GAs [3]. Other metaheuristic techniques are detailed in section 6. It must

be

emphasised that they are only suitable for applications where a good solu-

tion is adequate, where an optimum solution is not essential. Metahueristics do not guarantee to find the best solution, although they may fortuitously stum- ble upon optimality. This may sound like an unacceptable compromise, but

the massive reduction in computing time makes metahueristics very desirable

in some situations. [4]

GAs are a special subset of metahueristics, which use a form of biological mimicry 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; to

model 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 they

find solutions to hard problems, possibly even NP-hard, where it is not feasible

to enumerate all possibilities in order to find the best solution.

GAs work by creating a selection of possible problems, called the population, and breeding them with each other. [10] This alone would not refine the solutions

in any way, so the process of natural selection is used to ’kill off’ a section of

the least efficient solutions in each generation. Each solution is evaluated by

a ’fitness method’ which uses some problem-specific algorithm to calculate the

’goodness’ of that solution. The best solutions from each generation are used

to create the next, and the worst are deleted, in a simple model of natural

selection.

To create the next generation, a combination of mutation and crossover is used. Crossover takes some qualities from two solutions and creates another - this models 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

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

by neighboring solutions of a less desirable nature. Figure 1: An example of a local optimum.

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, with occasional 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 little or no effect, but equally may have large repercussions - entirely dependent on its role within the body. It is often the case that combinations of genes affect

a certain characteristic so that the alteration of a gene may have no obvious effect, but actually subtly alter many charecteristics.

Mutation can occur within any cell in the body, and usually occurs during

replication. There are mechanisms which reduce the amount of mutation that

is allowed to occur, but they are not infallible. There are two types of cell in

living 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 cells then it will be passed onto offspring - provided the organism isn’t detrimentally affected to the point of not surviving to procreation. [14]

These mutations can be beneficial or harmful, and can provide the animal with

an advantage over the other members of the species, or cause it to be less capable

of survival than others. As Dawkins explains in ’The Blind Watchmaker’, these

mutations are more than likely to be detrimental than beneficial, as ’there are more ways of being dead than being alive’. By this he means that within the vast space of possible gene sequences, there are few that represent living and surviving organisms, and an almost limitless amount of pools of non-living amino acids. [4]

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

6

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

There is little doubt

to regulate the size of populations. [23]

that usually feedback mechanisms operate

2.3 Evolution as a Paradigm for Problem Solving

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

By creating a model of an environment, where the organisms become potential solutions to the problem, and genes become variables modeling that solution, we can recreate natural selection to ’breed’ solutions that increase in fitness with each generation. We can simulate all processes of evolution; procreation can be modeled by combining two or more solutions in certain ways, mutation can be modeled using random number generators, natural selection and death can be modeled 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 avoiding local optimums by including random mutation - some of which will be detri- mental and not survive to procreation, and some which is beneficial and will steer the solutions towards unexplored space.

7

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 of using GAs to solve problems inherent in engineering, wherever they constituted optimisation problems. [15]

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

US West uses GA sto design fiber-optic cable networks, cutting design times from two months to two days, and saving US West $1 million to $10 million on each network design. [6] Genetic Algorithm derived designs have now even been used in satellites by NASA, with the development of an aerial being taken completely out of engineers hands. The orbit of those same satellites is now even 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 and mutation to write functional code, are by no means a ’silver bullet’. There are several reasons for which they are not suited to all problems, and these are examined here.

3.2.1 Complexity and Reliability

Sometimes GAs or genetic programming provide solutions that are so complex or convoluted that no human programmer could decipher what is being performed within. Because they do not follow any logical examination of the problem, as

a human designer would, they may find an extremely counter-intuitive way to

achieve a certain task. No design of any kind is actually performed in order to find a solution, so apparent logic in the result is not guaranteed.

The methods that GAs use to design systems are not necessarily logical so the finished 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 that appears to work completely cannot be proven to work in all examples. Goldberg talks of the difference between conceptual machines and material machines, i.e. an algorithm and a vehicle engine respectively. [12]One is fully testable, but the other is not necessarily so.

Although this is a normal problem with testing; not all cases can be tested, but

if the code is readable then a talented tester can devise test cases that will likely

trip the system up which is not possible with highly complex code. This creates

8

ethical problems with implementing GA derived designs in mission critical or real time applications. Bearing in mind that a failure in air traffic control, life support hardware etc could be fatal, or that failure in a financial institution could be disastrous in other ways, but that GA is also used to develop actual mechanical devices. Goldberg tells an amusing story about an airline passenger worrying about the design and its testing. If you were to imagine a plane as a GA, and the passenger as a GA user, then you could imagine the stress that the 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 is the moral or ehtical implications arising from a design that is not of human derivation. If there is a fundamental flaw in a human design, and this leads to a failure involving financial loss or human injury then blame is aportioned to the engineer responsible for the negligent design. However, if a GA designs a system that leads to a failure (possible due to unforeseen emergent behaviour as a result of massive complexity) then it is difficult to find the root cause of this issue.

9

4 Anatomy of a Genetic Algorithm

This section outlines the basic structure and components of a GA. It will become clear that each section is indeed an algorithm in its own right, and that there are numerous choices of strategy for each. A GA is simply an abstraction

of a subset of algorithms. It should also be noted that the huge variation of

approaches possible for each of the several components of a GA mean that there is a vast number of programs that fall under this catch-all title. A taxonomy of different 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 between the computational power of each generational iteration, and the computational

intensity of each iteration. A small number of solutions allows a greater number

of generations to iterate in a given time, because each generation will be less

computationally intensive.

A large population size will provide more variety in each generation, which

means 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 amount

of generations the solutions will begin to converge on a similar solution. The

amount of variation on average will decrease as the generation number increases, although the rate will vary on the magnitude of the mutation. Therefore it may

be beneficial to choose a smaller value for the population size.

Small variations, if beneficial, will propagate through a small population just

as they will through a larger one. Although a large population size means that

there is more mutation per generation, the faster computation of a smaller pop- ulation size would be capable of allowing a similarly large amount of mutation over a small number of solutions within the same time period [4]. The only constraint on population size is that the initial population needs to be at least 2 solutions large, as with any smaller amount no crossover operations would be possible, and it would be impossible to derive any more beneficial solutions in this way.

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

10

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 combining solutions, 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 were used alone then it would essentially be a random solution generator, but would still work. Crossover allows the retention of desirable traits, without the need to 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 close to 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-intelligent manner. [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 to represent a single solution needs to be paired to crossover. For example, if a solution 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 the program would be greatly reduced. Any time that a good value for the middle variable was found there is a good chance that it would be overwritten by the next generation. However, if the crossover was designed with the solution in mind, then the solutions could be trisected and recombined to preserver the value of individual variables. This would be more likely to arrive at a solution in a reasonable length of time.

to arrive at a solution in a reasonable length of time. Figure 2: An example of

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 simply takes the genes of a pair of solutions, and bisects them at the same arbitrary

11

point, the tail or head sections are then exchanged. (See figure 4.2.1) In this way the pair of parent solutions can create a pair of children that share certain aspects of both solutions. If the two sections that make up the new child both contain 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 the transferred 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 also provides all genes with an equal chance of exchange, whereas in the single point strategy any point chosen is guaranteed to swap the end gene, and will favor genes towards the edge of the solution. [16]

and will favor genes towards the edge of the solution. [16] Figure 3: An example of

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, which means that it is not acceptable for all GAs. In both double and single point crossover 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 possible engine parts each gene could represent a quality of that part such as height or thickness. In single and double point crossover these values would be swapped around, but maintain their context and meaning, but in a strategy which varies solution length this is not possible. Instead, cut and splice is more fitting to problems 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 upon a probability. In half uniform crossover the number of differing bits between

12

Figure 4: An example of cut and splice crossover. the two parents is calculated, and

Figure 4: An example of cut and splice crossover.

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

13

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 and mutation 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 quickly propagate through the solutions in use, and stall the algorithm. With a mu- tation operation involved as well, random solutions are thrown into contention throughout the cycle of finding a solution, and this may eventually enable an algorithm to branch out from underneath a local optimum, in order to pursue other avenues. [4]

Mutation is an essential part of any successful genetic algorithm. Without mutation an algorithm would simply combine the fittest solutions. This would mean that the generations would quickly converge into an amalgam of good solutions, and cease to improve. Mutation can be performed in a number of ways, 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 population of only one solution, that only operates upon the solution with mutation. After each generation the solution is either better or worse than the previous one, and either fulfills the halting algorithm, or does not. It will eventually stumble upon a good enough solution. However, with a well designed GA we can reach a satisfactory result far quicker. It should be noted however that it can often be useful to create a simple algorithm such as this in order to get started in development of a more complex and intelligent system.

while (solution is not optimal)

(

create random change check for improvement

if (improvement has occurred)

(

save change

go back to start of loop

)

else

(

discard change

go back to start of loop

)

)

14

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 calculate how good a certain solution is. Once each generation has been created, the fitness of each solution is evaluated and ranked.

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

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

15

4.5 Population Initialisation

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

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

With an entirely homogenous population, the algorithm would rely on mutation in order to provide variance in early generations, as crossover between similar solutions achieves little. By creating a varied initial population it is conceivable that good solutions would be found quicker, and the algorithm would complete faster.

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

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

4.5.1 Pre-Defined Variance

One possible approach would be to have designed, pre-defined variance in the solutions. These could be identical for each run of the algorithm, or designed for 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 the scenario 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 of the binary string which makes up the solution representation, and returns the difference of that value from the optimum inverted. The table below shows a possible instance of this problem.

Binary String

Integer Representation

Fitness Value

0000

0

-8

0011

3

-5

0110

6

-2

1001

9

-1

1100

12

-4

1111

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

optimal solution. However, by approximating the optimum with the initializa- tion, this process can be speeded up. The amount of effort required to tailor

a good range of solutions around an approximation would not be beneficial

however, 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 population with 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 benefit

of this approach.

4.5.2 Randomly Generated Solutions

A very simple method of initializing solutions would be to randomly generate

them. As a GA would have code to create random variation in the mutation method, it would be a trivial matter to adapt this to fully populate the initial designs. The scenario below shows an instance of the same GA as in section 4.5.1, but where the population is randomly created.

Binary String

Integer Representation

Fitness Value

1010

10

-2

0011

3

-5

0110

6

-2

1101

13

-5

0010

2

-6

1001

9

-1

4.5.3 Evenly Spaced Solutions

Another method would be to take the search space, and the number of solutions

in the population, and to calculate an even spread throughout.

17

4.6

Halting

Halting is an important and difficult problem in GAs. Without some form of halting criteria, that is checked at every generation, the program would continue to run, even once significant gains in fitness where no longer being generated by new generations. There are many techniques that are used to halt GAs, and their appropriateness depends entirely on the application, but they fall into two main categories; those that are based on the runtime of the algorithm, and those that 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 a resource, specifically time or computing cycles, to complete. In real time critical systems it may be vital to arrive at a solution within a given period, and in this case it is the role of the algorithm to find the best solution possible in that time. Even in non-critical systems such as GPS route planners it is necessary to impose some time constraints to avoid annoying the user; it is unlikely that a user would be willing to wait hundreds of hours to find the optimal route when 5 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 algorithm will check, at the end of every generation cycle, to see if it has exceeded its allocated time, or if it is likely to in the next cycle, and the algorithm can then be halted. In extremely time critical systems this anticipation of possible time overruns can be used to avoid the algorithm exceeding its time constraints in- between halting checks. The number of generations can also be the limiting factor, in a very loose time sensitive case, which although not accurate in terms of 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 the solutions. This is more desirable from a reliability point of view, as the output can 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 there is no way to find optimality for a problem, without enumerating all possible solutions, which can be a very time intensive procedure. A large traveling salesman problem would demand that an enormous number of different solutions be enumerated and evaluated in order to find an optimal solution, where as a GA could be run for an arbitrary amount of time, and with each iteration reach a 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 evaluation method. In this way the algorithm can check at each generation, to see if the best solution of that generation exceeds the acceptability levels, and halt if it

18

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

4.6.3 Progress Based Halting

Another method that can be used is to monitor the progress that the algorithm is making, in terms of numerical improvements correlating to the fitness of the best solution of each successive generation. This progress can be recorded and analyzed, 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 phase of confusion, especially if the initial population was randomly generated and extremely varied, and then go through a period of rapid improvement, before tailing off in a curve.

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

19

5 Current Applications of Genetic Algorithms

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

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

5.1 Code/Cipher Decryption

The set of all possible decryptions can be thought of as a search space, containing one correct decryption, and therefore can be made suitable for solving with a genetic 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 function may 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 performance by devices designed by genetic algorithms, showing that these algorithms are capable of producing the same output as educated engineers. In fact 2 devices have been created that are original, and would be patentable if not for the fact that a computer designed them. There are patent laws that forbid the submission of applications for designs that have been derived by a computer.

[11]

20

5.5 The Arts

Genetic algorithms have also been used extensively in research into artistic endeavors. 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 than programmed. This is very useful when the criteria for ’good’ art are so vague and subjective, as the fitness evaluation can be replaced by a human evaluator initially. There has even been work to connect the fitness function directly to physiological signals given off by the brain, which would allow rapid evaluation.

[25]

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

Better output has been achieved in other systems, where the fitness evaluators are 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 where they can generate short pieces in real time, and take a real players response as input, to dynamically update the fitness function. Computer generated music has received much media attention in the past, which will undoubtedly lead to increased funding for research, and consequently an improvement in the quality of artificial composition software. One example is a competition run by BBC Radio 3 where 3 pieces of music were played; one was genuine Bach, one was imitation Bach written by a professor of music, and one was generated by a GA.

5.6 Gene Sequence Analysis

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

21

5.7 Physical Engineering Design

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

5.7.1 JET/ITER Fusion Reactors

Experiments in fusion reaction have heavily used GAs. THe extreme conditions created by the experiements are unprecedented, and created many optimisation problems. To contain the plasma created in fusion, massive magnets are used as the heat of the plasma prohibits its interaction with any material. These enormous magnets distort the machine itself. Two schools of thought existed to overcome this problem; one was to sink the entire machine into a vast concrete anchor, prohibiting magnetic distortion, and the other was to use GAs to de- termine the optimum shape to avoid this distortion - make the ring the shape it wants to be under distortion. ITER/JET fusion experiment toroidal section shape

be under distortion. ITER/JET fusion experiment toroidal section shape Figure 5: An example of single point

Figure 5: An example of single point crossover.

22

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. One each heating and cooling cycle the metal becomes slightly stronger, and the crystalline structure slightly larger. This can be thought of as repeated escapes from a local optimum, where the variable to be maximised is the strength of the 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) is more 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. The definition of neighbour is problem-specific, but would normally involve a slight deviation.

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

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

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

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

23

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 and skin effect in conductors.

In DC there is no such problem, as current is evenly distributed throughout the conductor. But in AC there is a skin effect, which distorts the distribution of current. In the conductor, the current density is non-uniform due to this phenomenon, conventionally denoted as S. The current density, J, is strongest on the surface and drops off towards the centre.

strongest on the surface and drops off towards the centre. Figure 6: Current density in a

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

Proximity effect works in much the same way, but is the force that distorts current distribution in a nearby conductor, rather than the surface of one. Both of these effects are caused by the electromagnetic forces present in a circuit. [5] The equations necessary to calculate the effect of skin and proximity effect in a pair of DC conductors has been calculated in a paper by Murgatroyd and Hillen, 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 will not be as complex as in the paper, but will be a new approach, using a range from the best to worst points on each solution. In this way the current density can be caused to become more uniform, without having to perform much of the calculations. This should greatly increase the implementation speed, and also the computation speed as the code will be less computationally intensive.

The English engineer Arnold proved that if conductors were thin tapes, then they 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 optimal solutions using GAs. [?]

24

7.2 Representation in GA

The problem of how to represent the problem within the system is invariably one with many constraints and compromises. The model, when simulated in

a digital environment, has to be measured in finite and discrete amounts. For

example, the curve of one of the bars could be modelled exactly using vectors

or an equation.

However, to calculate the fitness, the distance from each point on one bar has

to

be measured to each point on the other. To do this with an infinite amount

of

discrete points would take an infinite amount of time. Therefore some ap-

proximation must take place, to allow the program to run effectively. Some happy medium between time and computational efficiency, and accuracy must be 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, with

a constant and fixed central bar on the X axis, and N bars extending below, and

above that section. By altering the value of N it wil be possible to increase or decrease the accuracy or fidelity of the solutions, and to fine tune the balance

between 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 points

on a cartesian graph, but that would require 2 variables for each of every 2N+1 points. 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 can then be calculated from this one number. Using this representation reduces the amount of data to be held in the solution, simplifying the evolution process. This simplification can be further achieved by maintaining symmetry along the

X

axis.

If

the two bars (of equal or unequal length) are placed with their centre points

on the Y axsis at 0 then the optimum solution will be symetrical on the X axis. Therefore data need only be held on one half of each bar. As the centre point will always be placed on the Y axis at 0, and will always be placed at the vertical, it is only necesary to store the remaining N angles. The point used will

actually be the centre point of each section, rather than the edge, this allows the first centre point to be on the X axis and for the solution to start from 0 on the Y axis.

7.2.2 Converting Angles to Cartesian Coordinates

The internal representation of the bars is based on angles of derivation and fixed section length, however, the system will need to have cartesian values for 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 to point on each bar, and the GUI will also need cartesian coordinate figures to

25

plot the solutions as output. Therefore some method will need to be developed that can take a solution, with angle derivation figures for only half of the arc minus the centre section, and convert that into a full set of points for every section. To calculate these points will make use of trigonometry, as shown here.

Point

Equation

Point

Equation

X

0

symbol*w/2

Y

0

0

X

1

X 0 +symbol*w/2 X 1 +symbol*w/2 X ( N 1)+symbol*w/2

Y

1

2

X

2

Y

2

2

X

N

Y

N

2

7.3 Calculating Fitness Values

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

26

8 Aim of Project

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

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

27

9

Design

9.1 Fitness Function

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

Whilst the mathematics used in the fitness function are pre-determined, the actual value to use in the GA is not. The chosen value is the range between the values calculated for each point. In an optimal solution each point will have the same value, or as close as possible to the same. Therefore, by assigning a range value to each solution, and minimizing this, an optimal solution should be the target. This approach will also offer significant performance benefits, but has not been attempted on this problem before, even though GAs have been applied to 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, then these 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 on the same curve (Si) and the opposite curve (Ri).

point i on the same curve (Si) and the opposite curve (Ri). Figure 7: Example of

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 of the 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 same value 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) is calculated.

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

28

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

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

G and M are constants used to replace the instance where the distance from

one point to itself needs to be calculated. Otherwise a divide by zero error may

be

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 would

be redundant as there is symmetry and the values would be the same. In the

Hillen paper there is further mathematics to determine the effect of the skin and

proximity 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 as current density becomes less uniform, and vice versa.

By taking the absolute value of this, we can reduce the variance in current

density, without ever fully calculating what the current density is. The aim

of the GA will simply be to get the same range value for each point on a

curve.

9.2 Population Initiation

The population of solutions must be ’seeded’, or instantiated in order to give the program a starting point. from which to derive better solutions. The loop

of fitness evaluation and generation creation must be started by evaluating the

fitness 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 solutions with the maximum variance. This would be a set of solutions that occupy a wide range of the solution space. One benefit to the human-designed method is

that many solutions could be placed, with deliberate qualities that are designed

to 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 problem had a quality that would prove to be ultimately desirable, it would still be culled in the presence of a fitter solution - no matter how local an optimum this replacement may occupy.

There could also be many ways in which to automatically generate a wide range

of 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 code that 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 some constant. Solution 2 could be (n*(2*m)), and so on. This would automatically

generate a wide range of initial solutions.

29

Solution Number

Equation

1

(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 order to examine which technique for initializing the solutions is most effective, it would be beneficial to have an easy method to change the data. To this end the program will read in the initial solutions from a text file. This will allow faster experimentation than with altering hard-coded values and re-compiling. If calculation is required in order to determine initial values then this file input can 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 size would be determined by the user, or by some algorithm that would analyze the problem 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 a method, 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 one generation to the next. For example, if the best solution from each generation remains in the subsequent one, then there is an inherent guarantee that each generation will be an improvement, which means that the algorithm can only move towards optimality in the sense of the best solution. Other solutions may mutate and output a lower fitness value however.

30

9.6

Mutation

9.6.1 Variable Mutation Rate

The mutation rate is an important setting in a GA. With a mutation rate that

is too low, there will be a very short amount of random jumps in the solutions.

Although the crossover method will create ’intelligent’ changes, taking desirable traits from each preceding generation, there can be no improvement on what is

already there.

Mutation is needed to duck from under local optimums and find new strategies that may or may not be included in solutions. If the mutation rate is too low then you 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 towards optimality.

However, with a mutation rate that is too high there are equally important problems. If mutation is excessive then all of the promising solutions in a generation may be changed, causing a backwards movement in optimality. This can be prevented to some extent, by retaining a copy of the best solutions, and making them except from mutation. However, the risk of promising solutions being 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 chance to propagate through into other solutions within the population. This is the price of evolution, and is present in natural evolution as much as simulated algorithms. 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 happy medium, reducing the loss from overwriting to a minimum, but retaining the powerful ability to find new strategies. One anticipated issue is the mutation rate 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 only mutate 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 in these 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 algorithm progressed, the mutation rate would decrease to allow finer solutions. The rate at which this is decreased could be controlled in numerous ways, such as by generation number, or run-time.

However, the best method is expected to be linked to fitness, as this provides

a concrete link to the revealing of a better solution. As the algorithm reaches

a better solution, the mutation rate is decreased. It should be noted that by

mutation rate, it is meant the discrete size of each mutation, rather than the frequency at which mutation should occur.

31

9.7 Logging Features

Logging is a feature that can be implemented relatively simply, but choosing the information to be logged is not so trivial. Storing all available information is not 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 to see them helps, SHould all solutions be shown? Dependent upon solution size there could be many, but at least 8ish. Decided that the best solution only should be shown, as solutions would become similar within a few generations anyway. Other essential elements of the GUI are the generation number, and metrics 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 from the vertical of that segment. Therefore, before the solutions can be drawn to the screen, this data must be converted into cartesian coordinates. Each segment can be calculated using trigonometry, as the length of each segment and one angle is known. This can then be added to the coordinates of the previous point, in order to create a chain of points. The table below shows how each point will be calculated, where d is the required spacing between the Y axis and the apex of the curve, and c is the length of each segment.

Point

X Value

Y Value

1

d

c/2

2

x value of point 1 + c sin angle

y value of point 1 + c cos angle y value of point 1 + c cos angle y value of point n-1 + c cos angle

3

x value of point 2 + c sin angle

n

x value of point n-1 + c sin angle

9.9.2 Colour Use

Colour use could be important, and the solution arc could be coded, with bad points 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, for example the N/3 hottest points, where N is the number of points in a solution arc could be red, and the same amount blue, with the other third black.

32

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 complex

proximity effect GA. The program simply used text strings as solutions, and aimed to create a specific string. It was initialized with a random population, and attempted to create a pre-determined word by using single point crossover and mutation.

10.1.2 Design

The design of the program was very simple; there would be 10 solutions in a

population (this size was chosen arbitrarily, but was even to allow crossover operations to be paired). At each generation all 10 would be analysed by a fitness 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 that match 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’ would

have a fitness value of 2.

10.1.3 Implementation

The program was implemented with a fitness value that compared each solution

to the optimal, and calculated the number of matching characters. The halting

algorithm simply stopped the program once the fitness value matched that of the character length of the optimal string (and therefore also the length of each problem 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 characters int matches = 0;

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

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

matches++;

33

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

// Return fitness value return 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, single point crossover was used. The length of solutions was set at 6 characters, and crossover took 3 characters from each solution to be altered. The program took the best 2 solutions, and created two new solutions from them which were placed in the positions previously used by the two worst performing solutions. This approach achieved two things; firstly it acted as natural selection, removing the least desirable solutions, and secondly it allowed the previous two best solutions to remain. These should never be overwritten, as it would allow the algorithm to 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 typical output from this test program.

Figure 10 shows typical output from this test program. Figure 8: Example output from the text

Figure 8: Example output from the text GA prototype.

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

34

to the layout and organisation of the program, as well as improvements upon

the actual algorithm.

A

GUI was added at this point, as having one in place that was proven to

be

functional would be a massive advantage in programming the next stage of

implementation.

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

35

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 would be broken down into modular sections, consistent in size and area. These would form 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 the program. Once a working system had been proven then the modules could be reduced in size to the point where the loss of information in the approximation became negligible, and hopefully smaller than the gain in efficiency arising from using a GA, in order to provide an overall improvement in circuit conduction efficiency.

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 be used to store the direction information, as one number can be used instead of two sets of cartesian coordinates, as would be needed under a graph based representation.

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 of N-1 integers. This is a very sparse representation to a complex solution, which is beneficial in the case of GAs, in order to reduce the complexity of the fitness evaluation 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 human readable, as the representation was plain text. Therefore judging the progress of the program was extremely intuitive. However, the final implementation, where the GA would be adapted to solve the skin and proximity effect problem, would be very different in this respect.

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

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

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

36

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

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

10.2.3

Results

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

expect from the previous work on proximity and skin effect. Figure 9: Example output from the

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. The optimal configuration for a single conductor is a closed circle, and the larger the distance between the two, the more closely the solution should resemble this.

[5]

37

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

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 to produce 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 of a solution. A larger amount of points could be used, and this would increase the accuracy of the solution. This work has actually been undertaken, and the code 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 a certain point, when the solution folds in on itself. Often, the points that exceed the initial six overlay the solution one would expect from a solution represented by 6 points. Obviously the fitness function would also need some adjustment in order to function properly, and a simple piece of code that doesn’t allow more than one point to occupy the same space would suffice to stop this from occurring.

Another improvement which could be very useful would be the ability to import problems 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 the code itself, even if there was a time overhead in re-compiling and running. One possible method that could overcome this would be to use an XML file, and to create 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