|mike 3d3d880133||1 year ago|
|Breeder.cpp||2 years ago|
|Breeder.h||2 years ago|
|Chromosome.cpp||2 years ago|
|Chromosome.h||2 years ago|
|Defines.h||2 years ago|
|Enums.h||2 years ago|
|ForwardDeclarations.h||2 years ago|
|Includes.h||2 years ago|
|LICENSE||1 year ago|
|Makefile||2 years ago|
|Population.cpp||2 years ago|
|Population.h||2 years ago|
|README.md||1 year ago|
|Random.cpp||2 years ago|
|Random.h||2 years ago|
|RouletteWheel.cpp||2 years ago|
|RouletteWheel.h||2 years ago|
This library is intended to help you apply a genetic algorithm to any number of your own projects.
This software is licensed under GPLv3
The general process is quite simple:
Decide what thing of your own you'd like to evolve. This could be anything that can be represented with a binary string:
Write an encoder function which will convert your thing into a string of bits
Write a decoder function which will convert a string of bits into your thing
Write a fitness function that will give your thing a score based on how well it performs (using whatever arbitrary rules and tests you care to).
Include this library in your program; Use the Population classes to manage and evolve your Chromosome classes.
A typical workflow where you repeatedly evolve your things could be something like:
Note that you don't actually need to write an encoder if you decide to do it this way.
Simple Example Suppose you wanted to evolve an unsigned integer using only one byte (ranging from 0 to 255). Suppose at some point your unsigned integer is the number 11. Your encoder should produce the bit string 00001011, since that's just 11 in binary. Your decoder should be able to turn 00001011 back into the number 11.
Slightly Less Simple Example Suppose you wanted to evolve a program. For simplicity, we'll start by saying this is a simple language that can only print and exit. You might represent this by saying an instruction starts with four bits, followed by an eight bit number. Suppose we assign 0000 to the instruction exit, and 0001 to the instruction print. Now take the following simple program:
print 5 exit 0
Our encoder would then represent this program with the following bit string:
The following features have been implemented thus far:
Sexual Reproduction Two parent Chromosomes are selected, and a simple crossover operator is used to combine their bits into a single child Chromosome, before applying mutation.
Asexual Reproduction One parent Chromosome duplicates itself exactly into a child Chromosome, before applying mutation
Roulette Wheel Selection When choosing parent Chromosomes to produce offspring, a method is used to allow Chromosomes that have higher fitness to reproduce more often, yet without guaranteeing any fit Chromosome will reproduce. Less fit Chromosomes will have less chance to reproduce, but aren't guaranteed not to reproduce.
Elitism Before evolving a population of Chromosomes, a few of the most fit Chromosomes are copied directly into the next population without modification, in an attempt to ensure that a population's Champions (most fit Chromosomes) never get worse as a result of evolution. Elitism has two modes, currently:
I would like to thank my old professor, Christopher Ryu, Ph.D., for teaching a great Artificial Intelligence class and inspiring me to create this project while taking his class.