Code covered by the BSD License  

Highlights from
SpeedyGA: A Fast Simple Genetic Algorithm

4.25

4.2 | 9 ratings Rate this file 149 Downloads (last 30 days) File Size: 4.13 KB File ID: #15164
image thumbnail

SpeedyGA: A Fast Simple Genetic Algorithm

by Keki Burjorjee

 

31 May 2007 (Updated 21 Nov 2010)

A vectorized implementation of a simple genetic algorithm in Matlab

| Watch this File

File Information
Description

SpeedyGA is a vectorized implementation of a genetic algorithm in the Matlab programming language. Without bells and whistles, it faithfully implements the specification for a Simple GA given on pgs 10, 11 of M. Mitchell's GA book. See comments in code for details.

This script has played a crucial part in the development of a new, unified explanation for the adaptive capacity of genetic algorithms (including ones with uniform crossover) called the Generative Fixation Hypothesis. See http://cs.brandeis.edu/~kekib/dissertation.html

Matlab is optimized for performing operations on arrays. Loops, especially nested loops, tend to run slowly in Matlab. It is possible to significantly improve the performance of Matlab programs by converting loops into array operations. This process is called vectorization. Matlab provides a rich set of functions and many expressive indexing schemes that make it possible to vectorize code. Such code not only runs faster, it is also shorter, and simpler to understand and change (provided that you know a little about Matlab of course).

Genetic Algorithms that are implemented in C/C++ or Java typically have multiple nested loops. Therefore direct ports of such implementations to Matlab will run very slowly. Many of the nested loops found in a typical GA implementation have been eliminated from SpeedyGA. The resulting code is short, fast and simple. It is indeed a delightful coincidence when the constructs of a programming language match a programming task so well that a program can be written this succinctly.

SpeedyGA is proof that Matlab is a useful language for the rapid prototyping of Genetic Algorithms. This, in addition to Matlab's extensive data visualization capabilities, make Matlab an extremely useful platform for the experimental analysis of GAs.

SpeedyGA has been created and tested under Matlab 7 (R14). Out of the box it evolves a population against the one-max fitness function. The royal-roads fitness function has also been included but is not currently being called. If you find SpeedyGA useful or find any bugs please let me know.

Enjoy!

p.s. For an experimental genetic algorithm which might significantly improve the quality of the solutions returned check out TurboGA (http://www.mathworks.com/matlabcentral/fileexchange/24053 )

Acknowledgements
This submission has inspired the following:
TurboGA: A Simple Genetic Algorithm With a Powerful Performance Enhancing Tweak
MATLAB release MATLAB 7 (R14)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (10)
11 Jun 2007 Krish Reddy

very helpful. Thanks!

21 Oct 2008 samaksh kumar

awesome!!!!!!!!!

19 Dec 2008 Shahab Anbarjafari

Good work, but can be improved more,

08 Jul 2010 Eastor Lee

good thanks

06 Aug 2010 jia  
09 Aug 2010 karthikeyan kumaravel  
13 Jan 2011 mohan l  
13 Jan 2011 mohan l  
23 Jun 2011 Jose

Very nice work!!

27 Sep 2011 Aji D

super....

Please login to add a comment or rating.
Updates
09 Jul 2008

different titme

15 Dec 2008

pre-generated crossover and mutation masks, which significantly improves performance

16 Dec 2008

Added the option of visualizing bit frequencies (handy for studying GA dynamics)

19 Dec 2008

corrected a typo in the description field

31 Dec 2008

1) The best individual of each generation is no longer displayed
2) Plots the maximum and average fitness of each generation at the end of a run
3) Upon completion, returns the best individual of a run, and its fitness

04 Jan 2009

.

04 Feb 2009

SpeedyGA now runs as a script (easier to work with for research purposes). Without bells and whistles, it now faithfully implements the specification for a Simple GA given on pgs 10, 11 of M. Mitchell's GA book. See comments in code for details.

11 May 2009

Updated description

15 May 2009

updated description

21 Nov 2010

No updates to the code. Changed the description to mention the Generative Fixation Hypothesis

Tag Activity for this File
Tag Applied By Date/Time
optimization Keki Burjorjee 22 Oct 2008 09:14:07
genetic algorithm Keki Burjorjee 22 Oct 2008 09:14:07
matlab Keki Burjorjee 22 Oct 2008 09:14:07
vectorized Keki Burjorjee 22 Oct 2008 09:14:07
evolutionary algorithm Keki Burjorjee 16 Dec 2008 14:39:36
combinatorial optimization Keki Burjorjee 16 Dec 2008 14:39:36
ga Keki Burjorjee 17 Dec 2008 16:55:33
optimization sabarees waran 20 Jan 2009 02:42:27
combinatorial optimization ahmed huss 18 Mar 2009 07:05:55
combinatorial optimization Renato Miyagusuku RĂ­os 02 Jun 2010 14:14:50
evolutionary algorithm Kavi Niranjana Kali Kutty 20 Jun 2010 21:55:41
ga Kavi Niranjana Kali Kutty 20 Jun 2010 21:55:47
vectorized RAVI KANTH KOTHA 12 Oct 2010 01:39:18
genetic algorithm Binquan ZHAO 21 Oct 2010 21:56:36
evolutionary algorithm bhavesh shukla 28 Nov 2010 13:17:09
genetic algorithm bhavesh shukla 28 Nov 2010 13:17:19
ga bhavesh shukla 28 Nov 2010 13:17:21
genetic algorithm Ricardo 01 Dec 2010 18:45:30
combinatorial optimization Ku 15 May 2011 12:58:21
evolutionary algorithm Ku 15 May 2011 12:58:25

Contact us at files@mathworks.com