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 optimal 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 2.1 What is a Genetic Algorithm? . . . . . . . . . . . . . . . . . . . . 2.2 Natural Selection and Mutation in Nature . . . . . . . . . . . . . 2.3 Evolution as a Paradigm for Problem Solving . . . . . . . . . . .
5 5 6 7
3 The History of Genetic Algorithms 3.1 The Birth of GA . . . . . . . . . . . . . . . . 3.2 Problems Associated with Genetic Algorithms 3.2.1 Complexity and Reliability . . . . . . 3.2.2 Legal, Ethical and Moral Issues . . . .
. . . .
. . . .
. . . .
. . . .
. . . .
. . . .
. . . .
. . . .
. . . .
. . . .
. . . .
8 8 8 8 9
4 Anatomy of a Genetic Algorithm 4.1 Encoding and Population Size . . . . . 4.2 Crossover Operations . . . . . . . . . . 4.2.1 Single Point Crossover . . . . . 4.2.2 Double Point Crossover . . . . 4.2.3 Cut and Splice Crossover . . . 4.2.4 Uniform Crossover . . . . . . . 4.3 Mutation Operations . . . . . . . . . . 4.4 Fitness Evaluation . . . . . . . . . . . 4.5 Population Initialisation . . . . . . . . 4.5.1 Pre-Defined Variance . . . . . . 4.5.2 Randomly Generated Solutions 4.5.3 Evenly Spaced Solutions . . . . 4.6 Halting . . . . . . . . . . . . . . . . . 4.6.1 Resource Based Halting . . . . 4.6.2 Solution Fitness Based Halting 4.6.3 Progress Based Halting . . . .
. . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . .
10 10 11 11 12 12 12 14 15 16 16 17 17 18 18 18 19
5 Current Applications of Genetic Algorithms 5.1 Code/Cipher Decryption . . . . . . . . . . . . . . . . . 5.2 Resource Allocation in Communication Infrastructures 5.3 Neuro-Evolution . . . . . . . . . . . . . . . . . . . . . 5.4 Electrical Circuit Design . . . . . . . . . . . . . . . . . 5.5 The Arts . . . . . . . . . . . . . . . . . . . . . . . . . 5.6 Gene Sequence Analysis . . . . . . . . . . . . . . . . . 5.7 Physical Engineering Design . . . . . . . . . . . . . . . 5.7.1 JET/ITER Fusion Reactors . . . . . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
20 20 20 20 20 21 21 22 22
. . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . .
6 Competing Techniques to Genetic Algorithms 7 Introduction to Skin and Proximity Effect 7.1 The Chosen Application . . . . . . . . . . . . . . . 7.2 Representation in GA . . . . . . . . . . . . . . . . 7.2.1 Representation of Bars . . . . . . . . . . . . 7.2.2 Converting Angles to Cartesian Coordinates 7.3 Calculating Fitness Values . . . . . . . . . . . . . . 2
23
. . . . .
. . . . .
. . . . .
. . . . .
. . . . .
. . . . .
. . . . .
. . . . .
24 24 24 25 25 26
8 Aim of Project
27
9 Design 9.1 Fitness Function . . . . . . . . . 9.2 Population Initiation . . . . . . . 9.3 Population Size . . . . . . . . . . 9.4 Halting . . . . . . . . . . . . . . 9.5 Selection . . . . . . . . . . . . . . 9.6 Mutation . . . . . . . . . . . . . 9.6.1 Variable Mutation Rate . 9.7 Logging Features . . . . . . . . . 9.8 Implementation Language Choice 9.9 GUI Design . . . . . . . . . . . . 9.9.1 Drawing the solutions . . 9.9.2 Colour Use . . . . . . . .
. . . . . . . . . . . .
. . . . . . . . . . . .
. . . . . . . . . . . .
. . . . . . . . . . . .
. . . . . . . . . . . .
28 28 29 30 30 30 31 31 32 32 32 32 32
10 Implementation 10.1 GA Prototype - Word Finder . . . . . . . . . . . . . . . . 10.1.1 Introduction . . . . . . . . . . . . . . . . . . . . . 10.1.2 Design . . . . . . . . . . . . . . . . . . . . . . . . . 10.1.3 Implementation . . . . . . . . . . . . . . . . . . . . 10.1.4 Results . . . . . . . . . . . . . . . . . . . . . . . . 10.2 Proximity and Skin Effect Genetic Algorithm . . . . . . . 10.2.1 Solution/Curve Representation . . . . . . . . . . . 10.2.2 Implementation Plan . . . . . . . . . . . . . . . . . 10.2.3 Results . . . . . . . . . . . . . . . . . . . . . . . . 10.2.4 Possible Improvements . . . . . . . . . . . . . . . . 10.3 Further Research . . . . . . . . . . . . . . . . . . . . . . . 10.3.1 Counter-Balanced Mutation . . . . . . . . . . . . . 10.3.2 Meta-Testing - Automation of Design Refinement? 10.3.3 Experiment in Metametahueristics . . . . . . . . .
. . . . . . . . . . . . . .
. . . . . . . . . . . . . .
. . . . . . . . . . . . . .
. . . . . . . . . . . . . .
33 33 33 33 33 34 36 36 36 37 38 39 39 39 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 Watchmaker, 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 2.1
Introduction to Genetic Algorithms 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. Metaheuristics 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 solution is adequate, where an optimum solution is not essential. Metahueristics do not guarantee to find the best solution, although they may fortuitously stumble 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 powerful 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, randomly to change these solutions in the hope that a desirable feature is introduced. [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.
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. Procreation creates offspring which are a combination of the two parents, with occasional mutation also operating on the genes. This mutation does not necessarily 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 ... that usually feedback mechanisms operate to 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 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 detrimental and not survive to procreation, and some which is beneficial and will steer the solutions towards unexplored space.
7
3 3.1
The History of Genetic Algorithms 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 human 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 generation 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 population 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 emergent 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 infinitesimally 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 previous 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 dependent 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 occupies 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 another, 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.
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]
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 specific 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 problem 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 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 optimality within a given time it is desirable to use a combination of crossover and mutation operations. With solely crossover operations there is a distinct possibility 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 mutation 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 solution, 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 algorithm. 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, possible ’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 optimum 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 0000 0011 0110 1001 1100 1111
Integer Representation 0 3 6 9 12 15
Fitness Value -8 -5 -2 -1 -4 -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 initialization, 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 comparison. It is conceivable that a system could be developed where a user inputs an approximate solution, and the program randomly generates the initial population with slight derivations from this. This would reduce the amount of time necessary 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 1010 0011 0110 1101 0010 1001
4.5.3
Integer Representation 10 3 6 13 2 9
Fitness Value -2 -5 -2 -5 -6 -1
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 inbetween 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 information 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 problems 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 bandwidth.
5.3
Neuro-Evolution
Training artificial neural networks when pre-classified training data is not available 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 selection 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 determine 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
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 repeatedly 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 reduced. 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 optimization 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 7.1
Introduction to Skin and Proximity Effect The Chosen Application
This project takes the GA method of solving combinatorial optimisation problems, 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.
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 approximation 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 algorithms 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 X0 symbol*w/2 Y0 0 X1 X0 +symbol*w/2 Y1 2 X2 X1 +symbol*w/2 Y2 2 XN 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 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 9.1
Design 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 between 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).
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 cartesian 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, irrespective 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 equation 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 algorithm 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 represented 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 1 2 3 4 5 6 7 8 9 10
Equation (n*m) (n*(2*m)) (n*(3*m)) (n*(4*m)) (n*(5*m)) (n*(6*m)) (n*(7*m)) (n*(8*m)) (n*(9*m)) (n*(10*m))
Does it even make much difference? Random population, designed variant population, 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 population 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 algorithm 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 strategy, 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 strategies 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 9.6.1
Mutation 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 1 2 3 n
9.9.2
X Value d x value of point 1 + c sin angle x value of point 2 + c sin angle x value of point n-1 + c sin angle
Y Value c/2 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
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 unimportant 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 demonstrated 100% success rate in achieving optimality. This was expected however, given the trivial nature of the problem, and the indiscrete nature of the representation - an optimal solution can have only one value. Figure 10 shows typical output from this test program.
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 10.2.1
Proximity and Skin Effect Genetic Algorithm Solution/Curve Representation
The solution would represent a curve, which would be the shape of the conductor. 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 allow 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 location 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 information 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 understand 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.
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
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
10.3 10.3.1
Further Research Counter-Balanced Mutation
If one point on one solution is mutated, then the magnitude of that change varies depending on where that point lies. The closer to the centre of the curve the 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 is altered though, it will affect the placement of every other point, as the root of all segments is the end of the previous segment. One avenue for further research would be to develop some form of counter-balanced mutation, where a change is accompanied by changes to successive angles, in order to try and retain their traits. This could be as simple as an equal change in the opposite direction in the N+1 point, or a gradual series of changes over the remaining points that sums 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 particular strategies. However, the intrinsic weakness of these are that the different options (initiation, mutation and crossover strategies) do not work atomically. One cannot decide the best method of initiation, apply it, and then move on to discover the best crossover strategy. These variables work in unison in incredibly complex ways, and present emergent behavior. Effectively they represent a combinatorial 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 generate a random population of GA settings. This strategy would present inherent problems. The concept of GAs is that they are readily applicable to any problem within a certain scope. A GA designed to find the word ’Monkey’ could easily be altered to evolve the word ’Simian’. However, running a GA to find the most optimum settings for a particular GA would be so computationally intensive that it would become ineffective. The original GA would have to be run once for each combination of settings. In a simple program with 5 settings, each with 5 options this would require 5! runs of the original program. It would be far more efficient to run the original GA, even with inefficient settings, once in order to solve the problem at hand. It is theoretically possible that a metahuerisitc fitness function could be designed that could evaluate the fitness of a GA without running it, although this would be problem-specific. It has been hypothesized that random creation could be used to create complex programs entirely from scratch without human input, again this is theoretically possible. However, it could take a massively large amount of attempts, and these would all need to be tested for correctness - a task that would take an enormous amount of time. In essence, an infinite amount of monkeys, sitting at an infinite amount of computers with a Java IDE, could create an optimal GA strategy - but it would take an infinite amount of time to assess which one it was. 39
Despite these issues it may be useful to discover whether this hypothesis is true, whether a GA can be used to create the optimal settings for another GAs variables. Having the optimum GA strategy could be useful knowledge. It could 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 fitness they could be used. It could be a metahuersitc for determining whether a metahueristic is appropriate - a metametahueristic. 10.3.3
Experiment in Metametahueristics
The basic strategy for the experiment would be to place the curve GA in a class, and import that class into the text based GA program. From here the code for the the text based GA would be altered. Instead of storing a word in each 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 solutions variables into the curve GA, running that algorithm, and storing the time taken to complete the solution to the optimality requirements of that program. This time would then be used as the fitness value, and it would be the task of the new meta-GA to reduce that value to a minimum. In this way it should be possible to determine the best settings for that GA.
40
11 11.1
Conclusion Project Results
The use of GAs was examined with a trivial problem, to find a certain string of alphanumeric characters. This code was a success, and proved that GAs would be feasible on my chosen platform. The code was then created for skin and proximity effect problems, and the results show that the solutions provided fit very closely with the results from the Hillen paper. [5] The fitness function therefore returns accurate values. The innovative approach to calculating fitness values without performing all of the calculations outlined in the Hillen paper also worked. This project was able to reduce the computational overhead inherent in solving this problem, and therefore speed up the calculation. It would be an interesting study to fully implement the calculations described in that paper, and perform some 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, and would maximise the efficiency of that circuit. By reducing proximity and skin effect, the power consumption of the circuit would be reduced. In the current environmental situation this is extremely pertinent. Metahueristic techniques can 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 there are many spaces where they are already working. They are adaptable to any problem where the fitness of a solution can be measured. There is nothing more adaptable than evolution.
41
References [1] Jaron Lanier, One-Half of a Manifesto: Why Stupid Software Will Save the Future 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 Answers 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 Comprehensive Catalogue. Springer Publishing, Section 104. [5] Richard Dawkins, The Blind Watchmaker Penguin Books, 1986. [6] Paul Murgatroyd, S. Hillen, Minimum loss sections of flat conductors. IEE Proceedings, 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 the Future 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 Reinhold, New York, 1991. [12] Koza, John R., Jones, Lee W., Keane, Martin. A., Streeter, Matthew J., and Al-Sakran, Sameer H. Towards Automated Dewsign of Industrial Strength Analog Circuits by Means of Genetic Programming. Kluwer Academic Publishing, Genetic Programming Theory and Practice 2, Chapter 8, pp. 121-142, 2004. [13] David E. Goldberg, Department of General Engineering, University of Illionois at Urbana-Champaign, From Genetic Design and Evolutionary Optimization to the Design of Conceptual Machines. IlliGL Report No. 98008, May 1998. [14] Michael R. Garey, David S. Johnson, ”Computers and Intractability - A Guide 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
[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 Optimisation, en.wikipedia.org/wiki/Particle-swarm, March 2006. [21] Gautam Naik, Back to Darwin: In Sunlight and Cells, Science Seeks Answers to High Tech Puzzle, The Wall Street Journal, January 16th 1996. [22] Biles, J, GenJam: A Genetic Algorithm for Generating Jazz Solos. Proceedings of the 1994 International Computer Music Conference. Aarhus, Denmark: International Computer Music Association. 1994. [23] George Papadopoulos and Geraint Wiggins, A Genetic Algorithm for the Generation 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 Michigan, International Computer Music Conference, Banff Alberta, September 1995. [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 ftp://ftp.virginia.edu/pub/fasta/README
of
Virginia,
[29] Cedric Notredame & Desmond G. Higgins, SAGA: Sequence Alignment by Genetic Algorithm, EMBL outstation, The European Bioinformatics Institute, Cambridge, March 4, 1996.
[30] West Lafayette, Genetic Algorithms ’naturally Select’ Better Satellite Orbits, http://www.spacemart.com/reports/Genetic Algorithms naturally Select Better Satellite Orbits.ht Oct 15, 2001. [31] NASA Website, Exploring the Universe -Evolvable Systems, http://www.nasa.gov/centers/ames/research/exploringtheuniverse/exploringtheuniverseevolvablesystems.html
43
12 12.1
Appendix Source Code for GA Word Finder
This is the code listings for the word-finder Genetic Algorithm. This code is Java, and was developed on JEdit on a Unix/Mac OS platform.
44
12.2
Example output from GA Word Finder
The following is a list of the best (highest fitness values) of each generation in a typical run of the text based GA. The output is not extraordinary in any way, and was of the type expected. The goal state is the word ’MONKEY’, and the initial state was randomly generated. The best initial state happened to be ’PENEEp’.
45
0:PENEEp 1:PENEEp 2:PENEEp 3:PENEEp 4:PENEEB 5:PENEEB 6:PENEEB 7:PENEEB 8:PENEEB 9:PENEEB 10:PENEEB 11:PENEEB 12:PENEEB 13:PENEEB 14:PENMEB 15:PENMEB 16:PENMEB 17:PENEEB 18:PENEEB 19:PENEEB 20:KENEEB 21:KENEEB 22:KENEEB 23:KENEEB 24:KENEEB 25:KENEEB 26:KENEEB 27:KENEEB 28:KENEEB 29:KENEEB 30:HENEEB 31:HENEEB 32:HENEEB 33:HENEEB 34:HENEEI 35:HENEEI 36:HENEEB 37:HENEEB 38:HENEEB 39:HENEEB 40:HENEEB 41:HENEEB
42:HENEEB 43:GENGEB 44:HENGEB 45:GENGEB 46:GENEEB 47:GENEEB 48:HENEEB 49:GENEEB 50:NENEEB 51:GENEEB 52:MMNEEB 53:MMNEEB 54:MMNEEB 55:MMNEEB 56:MMNEEB 57:MMNEEB 58:MMNEEB 59:MMNEEB 60:MMNLEB 61:MMNLEB 62:MMNLEB 63:MMNLEB 64:MMNEEB 65:MMNEEB 66:MMNIEB 67:MCNIEB 68:MMNIEB 69:MMNIEB 70:MMNIEB 71:MCNIEB 72:MCNLEB 73:MCNIEB 74:MCNIEB 75:MCNIEB 76:MCNLEB 77:MCNLEB 78:MCNLEB 79:MCNLEB 80:MCNLEB 81:MCNLEB 82:MCNLEB 83:MCNSEB
84:MCNTEB 85:MCNTEB 86:MCNTEB 87:MCNLEB 88:MCNLEB 89:MCNPEB 90:MCNPEB 91:MCNQEB 92:MCNQEB 93:MCNPEB 94:MCNCEB 95:MCNCEB 96:MANCEB 97:MANCEB 98:MCNCEB 99:MANCEB 100:MCNCEB 101:MANCEB 102:MANCEB 103:MANCEB 104:MANCEB 105:MCNCEB 106:MCNCEB 107:MCNCEB 108:MCNCEB 109:MCNQEC 110:MCNQEC 111:MCNQEC 112:MCNQEC 113:MCNCEB 114:MCNCEB 115:MCNCEB 116:MCNCEB 117:MCNCEB 118:MCNCEB 119:MCNCEB 120:MCNCEB 121:MCNCEB 122:MCNCEB 123:MCNCEB 124:MCNCEB 125:MCNCEB
46
126:MCNCEB 127:MCNCEB 128:MCNCEB 129:MCNCEB 130:MCNCEB 131:MCNCEB 132:MCNCEB 133:MCNCEB 134:MCNCEB 135:MCNCEK 136:MCNCEK 137:MLNCEK 138:MCNCEK 139:MCNLEU 140:MLNLEU 141:MTNLEU 142:MTNLEK 143:MTNLEK 144:MTNLEK 145:MLNLEK 146:MLNLEK 147:MLNLEK 148:MLNLEK 149:MLNLEK 150:MUNBEK 151:MUNBEK 152:MUNBEC 153:MUNCEC 154:MUNCEP 155:MUNCEP 156:MUNCEP 157:MUNCEC 158:MUNCEC 159:MUNCEC 160:MUNCEC 161:MUNCEC 162:MWNCEP 163:MWNCEP 164:MWNCEP 165:MWNCEP 166:MWNKEP 167:MWNKEP
168:MWNKEP 169:MWNKEP 170:MWNKEP 171:MWNKEP 172:MWNKEP 173:MWNKEO 174:MLNKEO 175:MLNKEO 176:MUNKEO 177:MUNKEP 178:MUNKEP 179:MUNKEP 180:MUNKEW 181:MUNKEP 182:MUNKEP 183:MUNKEP 184:MUNKEP 185:MUNKEP 186:MUNKEY 187:MUNKEY 188:MUNKEY 189:MUNKEY 190:MUNKEY 191:MUNKEY 192:MUNKEY 193:MUNKEY 194:MUNKEY 195:MUNKEY 196:MUNKEY 197:MUNKEY 198:MUNKEY 199:MUNKEY 200:MHNKEY 201:MHNKEY 202:MHNKEY 203:MHNKEY 204:MONKEY
12.3
Source Code for GA
This is the code listing for the proximity and skin effect Genetic Algorithm. This code is Java, and was developed on JEdit on a Unix/Mac OS platform.
47