Upload
lamque
View
219
Download
2
Embed Size (px)
Citation preview
Accessible Cartesian Genetic
Programming in Java
Eduardo Pedroni
MEng Project Report
Department of Electronics
University of York
May 22, 2014
Abstract
Cartesian Genetic Programming (CGP) is a form of genetic programming which
uses a grid of nodes as a genotype. While academically it is considered a promising
technique, like most genetic programming it is not widely known or used by the
average computer user. This report outlines the Agile development process of a
CGP tool with a focus on accessibility and flexibility. It was developed in Java
with a strong focus on object-oriented software design. The final product is found
to be a reasonable implementation of CGP, and the flexibility goal was met.
Acknowledgements
Id like to thank my supervisor Julian Miller for taking on the project and providing
invaluable guidance with genetic programming and report writing alike.
Id also like to thank my parents and sister for their support and patience at the
long radio silence.
A big thanks goes to Elly as well for all the late night hangouts.
I feel I should also acknowledge Angra, Devin Townsend and Ensiferum for providing
the soundtrack that saw me through all the long nights. My sincerest thanks also
go to Daedalus, for the joy of Nidhogg.
Finally, my regards to the 4th floor lab gang that made it worth the trip from home.
Its been well gas!
Contents
1 Introduction 1
1.1 Genetic Programming . . . . . . . . . . . . . . . . . . . . . . . . . 2
1.2 Project Aim . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
1.3 Report Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
2 Background Research 6
2.1 Cartesian Genetic Programming . . . . . . . . . . . . . . . . . . . . 6
2.2 Flexible and Accessible GP Implementations . . . . . . . . . . . . . 9
2.2.1 Mixed-Type CGP . . . . . . . . . . . . . . . . . . . . . . . . 9
2.2.2 ECJ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
2.2.3 CGP for ECJ . . . . . . . . . . . . . . . . . . . . . . . . . . 10
2.2.4 JCLEC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
2.3 Software Engineering . . . . . . . . . . . . . . . . . . . . . . . . . . 12
2.3.1 Object-oriented Programming . . . . . . . . . . . . . . . . . 12
2.3.2 The Java Programming Language . . . . . . . . . . . . . . . 15
2.3.3 JavaFX . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
2.3.4 Software Design Patterns . . . . . . . . . . . . . . . . . . . . 16
2.3.5 Agile Methodologies . . . . . . . . . . . . . . . . . . . . . . 19
2.3.6 Code Maintainability . . . . . . . . . . . . . . . . . . . . . . 20
2.3.7 Version Control . . . . . . . . . . . . . . . . . . . . . . . . . 21
3 Methodology 24
3.1 Agile Development Cycle . . . . . . . . . . . . . . . . . . . . . . . . 24
3.2 Version Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
3.2.1 Spikes Repository . . . . . . . . . . . . . . . . . . . . . . . . 25
3.2.2 Development Repository . . . . . . . . . . . . . . . . . . . . 25
3.2.3 Documentation Repository . . . . . . . . . . . . . . . . . . . 26
3.2.4 Bitbucket . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
3.3 Time Management . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
3.4 Project Documentation . . . . . . . . . . . . . . . . . . . . . . . . . 27
iii
Contents Contents
4 Product Specifications 28
4.1 Phase 1 - Back End . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
4.1.1 Fundamental Operation . . . . . . . . . . . . . . . . . . . . 28
4.1.2 Flexibility . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
4.2 Phase 2 - Front End . . . . . . . . . . . . . . . . . . . . . . . . . . 32
4.2.1 Chromosome Pane . . . . . . . . . . . . . . . . . . . . . . . 32
4.2.2 Control Pane . . . . . . . . . . . . . . . . . . . . . . . . . . 34
4.2.3 Console . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
4.3 Phase 3 - Extra Features . . . . . . . . . . . . . . . . . . . . . . . . 36
4.3.1 Statistics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
4.3.2 Multi-Chromosome Genotype . . . . . . . . . . . . . . . . . 36
4.3.3 Algorithm Scripting . . . . . . . . . . . . . . . . . . . . . . . 36
4.3.4 Crossover . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
4.4 Documentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
5 Back End Development 38
5.1 Cartesian Node Grid . . . . . . . . . . . . . . . . . . . . . . . . . . 38
5.1.1 New Components . . . . . . . . . . . . . . . . . . . . . . . . 39
5.2 Chromosome Genes . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
5.2.1 Refactorings . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
5.2.2 New Components . . . . . . . . . . . . . . . . . . . . . . . . 39
5.3 Chromosome Decoding . . . . . . . . . . . . . . . . . . . . . . . . . 40
5.3.1 Refactorings . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
5.4 The Population Proper . . . . . . . . . . . . . . . . . . . . . . . . . 42
5.5 Experiment Parameters . . . . . . . . . . . . . . . . . . . . . . . . . 43
5.5.1 New Components . . . . . . . . . . . . . . . . . . . . . . . . 43
5.6 Random Number Generation . . . . . . . . . . . . . . . . . . . . . . 44
5.6.1 Refactorings . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
5.7 Evolutionary Strategy . . . . . . . . . . . . . . . . . . . . . . . . . 44
5.7.1 Refactorings . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
5.7.2 New Components . . . . . . . . . . . . . . . . . . . . . . . . 46
5.8 Mutation Operator . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
5.8.1 Refactorings . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
5.8.2 New Components . . . . . . . . . . . . . . . . . . . . . . . . 52
5.9 Fitness Evaluations . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
5.9.1 Refactorings . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
5.9.2 New Components . . . . . . . . . . . . . . . . . . . . . . . . 53
5.10 Basic CGP Implementation . . . . . . . . . . . . . . . . . . . . . . 58
5.10.1 Refactorings . . . . . . . . . . . . . . . . . . . . . . . . . . . 58
iv
Contents Contents
5.10.2 New Components . . . . . . . . . . . . . . . . . . . . . . . . 58
5.11 Allelic Constraints . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
5.11.1 Refactorings . . . . . . . . . . . . . . . . . . . . . . . . . . . 60
5.12 Function Availability . . . . . . . . . . . . . . . . . . . . . . . . . . 60
5.12.1 Refactorings . . . . . . . . . . . . . . . . . . . . . . . . . . . 60
5.13 Loading CGP Files . . . . . . . . . . . . . . . . . . . . . . . . . . . 61
5.13.1 New Components . . . . . . . . . . . . . . . . . . . . . . . . 61
5.14 Algorithm Selection . . . . . . . . . . . . . . . . . . . . . . . . . . . 63
5.14.1 New Components . . . . . . . . . . . . . . . . . . . . . . . . 63
5.14.2 Refactorings . . . . . . . . . . . . . . . . . . . . . . . . . . . 64
5.15 Problem Selection . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65
5.15.1 New Components . . . . . . . . . . . . . . . . . . . . . . . . 65
5.15.2 Refactorings . . . . . . . . . . . . . . . . . . . . . . . . . . . 66
5.16 Component Development . . . . . . . . . . . . . . . . . . . . . . . . 66
5.16.1 Refactorings . . . . . . . . . . . . . . . . . . . . . . . . . . . 67
5.16.2 New Components . . . . . . . . . . . . . . . . . . . . . . . . 67
5.17 Chromosome Activity . . . . . . . . . . . . . . . . . . . . . . . . . . 67
5.17.1 Refactorings . . . . . . . . . . . . . . . . . . . . . . . . . . . 68
5.18 Experiment Statistics . . . . . . . . . . . . . . . . . . . . . . . . . . 68
5.18.1 New Components . . . . . . . . . . . . . . . . . . . . . . . . 69
5.18.2 Refactorings . . . . . . . . . . . . . . . . . . . . . . . . . . . 69
6 Front End Development 70
6.1 Chromosome Component Visualisation . . . . . . . . . . . . . . . . 70
6.1.1 Refactorings . . . . . . . . . . . . . . . . . . . . . . . . . . . 70
6.1.2 New Components . . . . . . . . . . . . . . . . . . . . . . . . 71
6.2 Chromosome Connection Lines . . . . . . . . . . . . . . . . . . . . 73
6.2.1 Refactorings . . . . . . . . . . . . . . . . . . . . . . . . . . . 73
6.2.2 New Components . . . . . . . . . . . . . . . . . . . . . . . . 75
6.3 Chromosome Activity Visualisation . . . . . . . . . . . . . . . . . . 77
6.3.1 Refactorings . . . . . . . . . . . . . . . . . . . . . . . . . . . 77
6.4 Chromosome Manipulation . . . . . . . . . . . . . . . . . . . . . . . 79
6.4.1 Refactorings . . . . . . . . . . . . . . . . . . . . . . . . . . . 80
6.4.2 New Components . . . . . . . . . . . . . . . . . . . . . . . . 81
6.5 Chromosome Evaluation Display . . . . . . . . . . . . . . . . . . . . 83
6.5.1 Refactorings . . . . . . . . . . . . . . . . . . . . . . . . . . . 83
6.5.2 New Components . . . . . . . . . . . . . . . . . . . . . . . . 83
6.6 Experiment Flow Control . . . . . . . . . . . . . . . . . . . . . . . 84
6.6.1 New Components . . . . . . . . . . . . . . . . . . . . . . . . 84
v
Contents Contents
6.7 Base Parameter Display . . . . . . . . . . . . . . . . . . . . . . . . 85
6.7.1 New Components . . . .