I'm pretty sure I have this working correctly. Please fiddle with the GA inputs to tweak the speed of convergence, etc. And let me know if it runs correctly.
I'm really new to MATLAB (and all programming really). This Genetic Algorithm (GA) was used to validate the one I used in my university final year project (I will update that when it's done, just having difficulties with penalty functions or equivalent procedures).
**For those unfamiliar with genetic algorithms...**
My humble offering is one of the most basic genetic algorithms, a foundation to what's being researched at the moment. [You can learn the basics of GAs in 5-minutes](http://www.obitko.com/tutorials/genetic-algorithms/). There are many more advanced tweaks which have been developed through the years (One of the most established adapted GAs goes by the name NSGA-II by [Deb, et al](http://www.iitk.ac.in/kangal/deb_research.shtml). If you would like to see more current GA (and more generally Multi-Objective Evolutionary Algorithms) I recommend looking at [Coello Coello's Repository](http://delta.cs.cinvestav.mx/~ccoello/EMOO/EMOOsoftware.html)
Shaffer's F6 function is a testing function which includes many oscillations/peaks which is difficult for hill-climbing techniques to converge to (the peaks are known as local optima). The F6 function is designed to have its peak at the origin with a value of one. Included in the download is 'f6Surfaces.m' which includes a 3D surface (x-parameter, y-parameter and evaluation function values) as well as a 2D plot (y-value set to equal it's optimal zero, with x-values being plotted against evaluation function values).
Please, if anyone can find an error or a way to speed up my code, I'd be very grateful. Any questions, I'll try my best to answer. If there's anything I've left out or you would like me to include, please let me know and I'll update this description or get in contact with you.
**EDIT** Code updated to include subplots (just worked it out) so everything looks a little more suave (**as can be seen in the snapshot or accessed as part of the submission**). I have also plotted each population and evaluation function values with reference to the 2D and 3D evaluation function surface plot so you can see how the population evolves over the generations.
Dean Kayton (2023). Genetic Algorithm to Optimise Schaffer's F6 Function (https://www.mathworks.com/matlabcentral/fileexchange/41252-genetic-algorithm-to-optimise-schaffer-s-f6-function), MATLAB Central File Exchange. Retrieved .
MATLAB Release Compatibility
Platform CompatibilityWindows macOS Linux
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!