

Show HN: My first Genetic Algorithm program - dragonbonheur

Wrote a program in FreeBASIC to try and find out how Genetic Algorithms work. It&#x27;s a quick hack that I wrote to try some theories with because the Wikipedia Article on GAs reads like greek to me. So  I built it from the general principles i knew at the time.<p>The &quot;genome&quot; per individual is an array of 9000 integers but I used only monochrome pictures with either black or white; An individual also has a fitness score.<p>There are 1000 individuals in the population and only two are selected to reproduce. So that makes 9 million (yes, MEELION as El Reg would write) data points and the scoring information being processed every time.<p>There&#x27;s a 0.002% mutation rate just to keep things going because things tend to stall with monochrome data. A higher mutation rate and the algorithm will never approach maximum potential fitness, apparently.<p>The code is wildly unoptimized and it&#x27;s my first draft. I could have used memory pointers to manipulate image data faster but this gets the job done so far. Processing color  data takes a lot more time and this program wasn&#x27;t written for that.<p>Runs on Windows. The source code needs to be cleaned up, so I didn&#x27;t include or upload it. As far as i know, this may be sadly the only Genetic Algorithm program so far from the island of Mauritius.  Download it here: https:&#x2F;&#x2F;sites.google.com&#x2F;site&#x2F;bryanbottebell&#x2F;bryan-bottebell-s-projects&#x2F;Imolver.zip
======
opcvx
Let me remind everyone that downloading and running unknown executables is
borderline insane.

@OP Where is the source?, if you want to share, distribute the source not the
exe.

~~~
dragonbonheur
Dude, if you saw the source, you'd faint.

About it being unknown, may I remind you that much of Apple OS X or Microsoft
Office are just as "unknown"? Have you read the source of LibreOffice
recently?

EDIT: I've included the source in the .zip now. Maybe i should have put an
EULA like the "trusted" companies but anyway, you wanted it, you got it. In
BASIC.

~~~
scriptdevil
Apple and Microsoft have much to lose if they are found distributing malware.
You on the other hand have just written your first GA program and have
admitted that the source is ugly. What is the last time you were OK about
running an executable from a shady site?

~~~
Alupis
Let's not beat up on the OP too much for not releasing source. It's a very
complex program and in an initial state is surely messy code (we've all been
there).

Good work OP.

~~~
scriptdevil
Just in case it came out the wrong way, kudos to the OP for getting the job
done. I just found his argument that the source-code isn't needed because
Microsoft doesn't release its sources way off mark.

------
frikk
One way you can use a higher mutation rate is to only mutate children, but
keep the parents without mutation (as the first two children of the next
generation). That way you can always remember the 'best of previous
generations.

Or, you can vary the _mutation_ rate with a normal curve -- so say most of the
population gets a small rate, but a small percentage gets a wildly higher rate
and wildy lower rate.

~~~
dragonbonheur
>remember the 'best of previous generations

In nature, immortality doesn't seem to lead to much evolution. remember that
immortal jellyfish some japanese scientist discovered a while ago that went
back to its polyp phase once it got mature? Besides, sometimes species devolve
too in nature. I just accept mortality and obsolescence as they are.

~~~
frikk
hehe. That's fine. It all depends on the nature of the experiment. Typically
you want to optimize a solution in a given deterministic domain. If you wish
to, instead, create an open-ended evolutionary system for novelty in a non-
deterministic solution space, go for it!

Although, to be fair, in nature you're also not dealing with a static fitness
function, a high mutation rate, and there's a wide myriad of other variables
that affect the overall dynamics of a population (like sexual vs asexual
reproduction, migration, recessive genes, sexual selection, etc)

~~~
dragonbonheur
You're absolutely right. I've been wondering what results i would get if I
seeded all of the population with the reference image data, slightly mutated
but let the GA look for variations with a 10 or 20% variation tolerance.

------
spiritplumber
Thanks! I wanted to start learning GAs and this looks like a great intro.

