μ8
CodeBullets amazing video on the subject.
Genetic algorithm for machine learning. Inspired byThis is a work in progress
Steps
- Natural selection.
- Mate.
- Mutate babies.
- Rinse and repeat.
Info
mu8.go
Genome
andGene
interface definitions. Users should implementGenome
interface and useGene
implementations fromgenes
package.genetic
directory contains genetic algorithm implementationgenes
contains usefulGene
interface implementations.
μ8 examples
See rocket
for a demonstration on rocket stage optimization. Below is the output of said program
champHeight:101.619km
champHeight:138.558km
champHeight:141.474km
champHeight:141.474km
champHeight:141.474km
champHeight:141.474km
champHeight:141.474km
champHeight:141.478km
champHeight:141.478km
champHeight:141.538km
our champion:
Stage 0: coast=135.2s, propMass=195.4kg, Δm=99.77kg/s, totalMass=395.4
Stage 1: coast=145.9s, propMass=1.2kg, Δm=0.14kg/s, totalMass=21.2
CodeBullet's example
The following command will run an example of what genetic algorithm is possible of doing. It is solving CodeBullet's proposed problem of moving points towards a goal point.
go run ./examples/dotforces/
elitescore
is the fitness or "score" of the best child in the generation. As you can see it gets larger.
gen 10: totalfitness=1032.37, elitescore=10.24671
gen 20: totalfitness=1325.90, elitescore=11.98153
gen 30: totalfitness=1374.32, elitescore=11.98153
... ten seconds later...
gen 300: totalfitness=2169.45, elitescore=16.26937
The score went from 10 to 16 with help of a genetic algorithm.