Robert Ghanea-Hercock
Applied Evolutionary
Algorithms in Java
With 57 Illustrations INCLUDES CD-ROMSpringer
as these represent the main detailed pair of examples from mobile robot control. Chapters ctions in the field and some ocessing. Appendix A provides :s and software. Appendix B e used in the text and the Eos :ems laboratory at BTexact itial background knowledge in bot control example. Appendix )ile robot simulator, which has in evolution-based software at latics beyond basic algebra and to encourage use of the Java he power of these techniques. xtensive coverage of the theory : author welcomes suggestions
of the book contains the Java . It also contains a selection of evolutionary Applications and :he papers directory contains a mting. Installation instructions
Contents
who for various reasons were x>k. I must particularly thank ot simulator, which forms the 3 it was ideally suited to the onary algorithms in graduate iture Technologies group at I Tateson, Rob Shipman and the Eos toolkit and appendix le to work on this project. and Derek Hercock. Finally, est in artificial evolution.
Preface v
1 Introduction to Evolutionary Computing 1
1.1 Evolutionary Computation 1 1.2 History of Evolutionary Computing 2 1.3 Obstacles to Evolutionary Computation 3 1.4 Machine Learning 3 1.5 Problem Domains 4 7.5.7 Search Spaces 4 7.5.2 Optimisation Versus Robustness 6
1.5.3 Expert Systems and Al 6 1.5.4 Fuzzy Logic 7
7.5.5 Bayesian Networks 9
1.5.6 Artificial Neural Networks 10 1.5.7 Feedforward Networks 11
1.6 Applications 12
1.6.1 Problems 13
1.7 Evolution-Based Search 14 7.7.7 Languages for Evolutionary Computing 14
1.7.2 Cand C++ 14 1.7.3 Pascal and Fortran 15 1.7.4 Visual Basic 15 1.7.5 Java 15
7.7.6 Object-Oriented Design 16 7.7.8 Java and 00 Design 16 1.8 Summary 17
Further Reading 18
2 Principles of Natural Evolution 19
2.1 Natural Selection 19
2.1.1 Genes and Chromosomes 19
viii Contents
2.2 DNA Structure 20
2.2.1 Transcription -from DNA to RNA 21
2.2.2 Translation -from RNA to Protein 21
2.2.3 Genotype 21 2.2.4 No Lamarckianism! 22 2.2.5 Evolution and Variation 22 2.2.6 Redundancy 22 2.2.7 Self-Maintenance 22 2.2.8 Evolvability 23 2.2.9 Mutation 23 2.2.10 Sexual Recombination 24 2.2.11 Nonselectionist Issues 24 2.2.12 Epigenesis 24 2.2.13 Dynamics and Morphogenesis 25
2.3 Summary 25
Further Reading 26
3 Genetic Algorithms 27
3.1 Genetic Algorithms 27 3.2 GA Basics 27
3.2.1 Fitness and Evaluation Functions 27
3.3 GA Theory 30
3.3.1 Deception 31 3.3.2 Messy Genetic Algorithm 31
3.4 GA Operators 32 3.4.1 Mutation 32 3.4.2 Crossover 33 3.4.3 Multipoint Crossover 34 3.4.4 Selection 34 3.4.5 Fitness-Proportionate Selection 36 3.4.6 Disadvantages of Fitness-Proportionate Selection 37 3.4.7Rank Selection 37 3.4.8 Tournament Selection 38 3.4.9 Scaling Methods 39
3.5 Pros and Cons of Genetic Algorithms 39 3.6 Selecting GA methods 40 3.6.1 Encoding Choice 40 3.6.2 Operator Choice 42 3.6.3 Elitism 42 3.7 Example GA Application '. 42 3.8 Summary 45 Further Reading 46 4 Genetic Programming.... 4.1 Genetic Programming 4.2 Introduction to Geneti 4.2.7 Variable-length a, 4.2.2 GP Terminal Set. 4.2.3 GP Function Set. 4.2.4 Function Closure 4.2.5 Tree Structure Pr 4.2.6 Linear Structure < 4.2.7 Graph Structure \ 4.2.8 GP Initialisation, 4.3 GP Operators 4.3.1 GP Crossover.... 4.3.2 Mutation 4.3.3 Selection OperaU 4.3.4 Controlling Gene 4.4 Genetic Programming 4.4.1 Advances in GP • 4.5 Summary Further Reading 5 Engineering Examples \ 5.1 Introduction
5.2 Digital Image Proces 5.3 Basics of Image Prot
5.3.1 Convolution 5.3.2 Lookup Tables..
5.4 Java and Image Proc
5.4.1 Example Applici 5.4.2 Operator Seard 5.4.3 Implementation 5.5 Spectrographic Chrc 5.6 Results 5.6.1 GA Format 5.7 Summary - Evolved 5.8 Mobile Robot Conti
5.8.1 Artificial Intelli 5.8.2 Planning 5.8.3 Static WorUs.. 5.8.4 Reactive and B 5.8.5 Advantages of, 5.8.6 Alternative Strt 5.9 Behaviour Manage]
20 A 21 hi 21 21 22 22 22 22 23 23 24 24 24 25 25 26 27 27 27 27 30 31 31 32 32 33 34 34 36 mate Selection 37 37 38 39 39 40 40 42 42 ; 42 45 46 Contents ix 4 Genetic Programming 47 4.1 Genetic Programming 47
4.2 Introduction to Genetic Programming 47
4.2.1 Variable-length and Tree-Based Representations 49 4.2.2 GP Terminal Set 49 4.2.3 GP Function Set 49 4.2.4 Function Closure 50 4.2.5 Tree Structure Processing 50 4.2.6 Linear Structure Encoding 50 4.2.7Graph Structure Encoding 51 4.2.8 GP Initialisation 51
4.3 GP Operators 52
4.3.1 GP Crossover 52 4.3.2 Mutation 52 4.3.3 Selection Operators in GP 52 4.3.4 Controlling Genome Growth 53
4.4 Genetic Programming Implementation 54
4.4.1 Advances in GP — Automatically Defined Functions 54
4.5 Summary 55
Further Reading 56
5 Engineering Examples Using Genetic Algorithms 57
5.1 Introduction 57 5.2 Digital Image Processing 57 5.3 Basics of Image Processing 58
5.3.1 Convolution 58 5.3.2 Lookup Tables 59
5.4 Java and Image Processing 60
5.4.1 Example Application— VEGA 61 5.4.2 Operator Search Space 61 5.4.3 Implementation 61
5.5 Spectrographic Chromosome Representation 67 5.6 Results 68 5.6.7 GA Format 68 5.7 Summary - Evolved Image Processing 70 5.8 Mobile Robot Control 71 5.5.7 Artificial Intelligence and Mobile Robots 72
5.8.2 Planning 72 5.8.3 Static Worlds 73 5.8.4 Reactive and Bottom-up Control 74 5.8.5 Advantages of Reactive Control 76 5.8.6 Alternative Strategies 76
x Contents
5.9.1 Behaviour Synthesis Architecture 78 5.9.2 Standard Control Methods — PID 81
5.10 Evolutionary Methods 82
5.10.1 GAs and Robots 82 5.10.2 Inferencing Problem 82 5.10.3 Behaviour priorities: Natural Agents 83
5.11 Fuzzy logic Control 84
5.11.1 Fuzzy Control of Subsumption Architectures 87
5.12 Evolved Fuzzy Systems 87 5.13 Robot Simulator 89
5.13.1 The Robot Control Architecture 90 5.13.2 Related Work 93 5.13.3 Results 94
5.14 Analysis 98 5.15 Summary — Evolving Hybrid Systems 99
Further Reading 99
6 Future Directions in Evolutionary Computing 101
6.1 Developments in Evolutionary Algorithms 101 6.2 Evolvable Hardware 101 6.3 Speciation and Distributed EA Methods 103
6.3.1 Demetic Groups and Parallel Processing 103 6.3.2 Parallel Genetic Programming with Mobile Agents 104 6.3.3 Mobile Agents 104 6.3.5 EA Visualisation Methods 107
6.4 Advanced EA techniques 108
6.4.1 Multiobjective Optimisation 109 6.4.2 Methods: Weighted Sum Approach 109 6.4.3 Minimax Method 109 6.4.4 Parameter Control 110 6.4.5 Diploid Chromosomes 110 6.4.6 Self-Adaptation 110
6.5 Artificial Life and Coevolutionary Algorithms 111 6.6 Summary 113
Further Reading 114
7 The Future of Evolutionary Computing 115
7.1 Evolution in Action 115 7.2 Commercial value of Evolutionary Algorithms 115 7.3 Future Directions in Evolutionary Computing 116
7.3.1 Alife and Coevolution 116 7.3.2 Biological Inspiration 117 7.3.3 Developmental Biology 117 7.3.4 Adaptive Encoding and Hierarchy 118
7.3.5 Representation and & 7.3.6 Mating Choice 7.3.7 Parallelism
7.4 Conclusion
Bibliography
Appendix A
A.I Java-based EA Software A.2 C/C++ based EA Softw: A.3 General Evolution and I A.4 Java Reference Guides., A.5 Useful References
Appendix B
A Genetic Algorithm Exarm B.I Basic Genetic Algorithi B.2 Simple Java Genetic Al
Exercises
B.2.1 Vectors and Arrayl
B.3 Application Design B.4 Eos: An Evolutionary a
Authors: Erwin Bonsma, B.4.1 Introduction B.4.2 Design Overview.. B.4.3 Key Classes B.4.4 Configuration B.4.5 Illustrative Examp B.4.6 Aerial Placement] B.4.7 An Ecosystem Sim B.4.8 Coevolutionary Fi B.4.9 Telecommunicatic B.4.WNetGrow:ATele B.4.11 Eos Summary B.5 Traveling Salesman P B.5.1 EOS Traveling Sa B.6 Genetic Programming B.6.1 Observations fror, Eos References Appendix C
C.I Fuzzy Logic C.2 Fuzzy Set Theory
78 ) 81 82 82 82 •ents 83 84 rchitectures 87 87 89 90 93 94 98 ns 99 99 Hiting 101 hms 101 101 Is 103 cessing 103 th Mobile Agents. 104 104 107 108 109 : 109 109 110 110 110 3rithms I l l 113 114 115 115 orithms 115 puting 116 116 117 117 118 Contents xi
7.3.5 Representation and Selection 118 7.3.6 Mating Choice 118 7.3.7 Parallelism 118
7.4 Conclusion 119
Bibliography 121
Appendix A 133
A.I Java-based EA Software 133 A.2 C/C++ based EA Software 134 A.3 General Evolution and Robotics References 134 A.4 Java Reference Guides 136 A.5 Useful References 136
Appendix B 137
A Genetic Algorithm Example and the GPSYS GP Library 137 B.I Basic Genetic Algorithm 137 B.2 Simple Java Genetic Algorithm 137
Exercises 147 B.2.1 Vectors and Arraylists..,.. 147
B.3 Application Design 148 B.4 Eos: An Evolutionary and Ecosystem Research Platform 149
Authors: Erwin Bonsma, Mark Shackleton and Rob Shipman 149 B.4.1 Introduction 150 B.4.2 Design Overview 150 B.4.3 Key Classes 152 B.4.4 Configuration 153 B.4.5 Illustrative Example Systems 154 B.4.6 Aerial Placement for Mobile Networks 154 B.4.7 An Ecosystem Simulation Based on Echo 155 B.4.8 Coevolutionary Function Optimisation 156 B.4.9 Telecommunications Research using Eos 157 B.4.10 NetGrow: A Telecommunications Application 158 B.4.11 Eos Summary 158
B.5 Traveling Salesman Problem 159
B.5.I EOS Traveling Salesman Problem 159
B.6 Genetic Programming 163
B.6.1 Observations from Running GPsys • Lawnmower Problem:.... 164 Eos References 167
Appendix C 169
C.I Fuzzy Logic 169 C.2 Fuzzy Set Theory 170
xii Contents
C.2.1 Fuzzy Operators 171 C.2.2 Linguistic Variables 171 C.2.3 Fuzzy IF 172 C.2.4 Fuzzy Associative Memories 173 C.2.5 Fuzzy Control Systems 174 C.2.6 Defunification 175 C.2.7 Fuzzy Applications.... 178
C.3 Limitations of Fuzzy Control 178
C.3.1 Advantages of Fuzzy Systems 179
C.4 Summary 180
Further Reading 180
Appendix D 181
Introduction 181 System Overview 181 Use and License 181 Programming Language and Run-Time Environment 182 Top-Level Directory Files and Hierarchy 182 Units of Measure 183 The Client-Server Architecture 183
Network/Local Connections Versus Dynamically Loaded Clients 184 Why a Client-Server Architecture? 185 Client-Server Communications 185 Network and Local Connection Issues 186 Communication via Events and Requests 187 Keeping the RP1 Protocol Language-Independent 188
Configuration Elements and Properties Files 188
The "port" and "hostName" Properties 189 Overriding Properties 189 Loading RsProperties Files as a Resource 190
The Server 191
Server Properties Files 191 Accepting Clients 191 The Scheduler 192
The Floor Plan 194
Syntax and Semantics 194
Building a Virtual Robot 196
Introduction 196 Thinking About Client Design 196
The Demonstration Clients 196 Life Cycle of the Demonstration Clients 197 How CInMain Extends RsCUent and Implements RsRunnable 199
The RsRunnable Interface 200
Building RsRunnable and DemoMain Implements Rs The Execution of CInMain Uploading the Body Plan , Registering Event Handlet Running the Event Loop... How the Demo Clients We
Physical Layout of ClientZei The RsBody and RsBodyPai
RsBodyShape RsWheelSystem The Sensor Classes RsBodyTargetSensor RsBodyContactSensor
Events and Requests
171 171 172 173 174 175 178 178 179 180 180 181 181 181 181 wironment 182 182 183 183
lamically Loaded Clients 184
185 185 186 s 187 dependent 188 es 188 1 189 189 ce 190 191 191 191 192 194 194 196 196 196 196 197 ments RsRunnable 199 200 Contents xiii
Building RsRunnable and RsClient into ClnMain 201 DemoMain Implements RsRunnable, But Does Not Extend RsClient. 202 The Execution of ClnMain 202 Uploading the Body Plan 204 Registering Event Handlers 204 Running the Event Loop 205 How the Demo Clients Work 205
Physical Layout of ClientZero 207 The RsBody and RsBodyPan Classes 207
RsBodyShape 209 RsWheelSystem 210 The Sensor Classes 212 RsBodyTargetSensor 213 RsBodyContactSensor 213
Events and Requests 214 Index 216