View Full Version : Genetic algorithms
Strike
06-12-2002, 08:37 PM
I was discussing AI with kmj and he mentioned that he wanted to take a course on Genetic Algorithms. I figured I would link people to a primer on it to see who all was interested in it: http://www.gameai.com/buckland/ga_tutorial.html
And one thing I noted was that the guy is obviously not too big on math:
Given the digits 0 through 9 and the operators +, -, * and /, find a sequence that will represent a given number. The operators will be applied sequentially from left to right as we read.
So given the number 23, the sequence 6+5*4/2+1 would be a possible solution.
If we chose 75.5 then 5/2+9*7-5 would be one possible solution.
By my calculations (in my head), those two equations come out to 17 and 60.5, respecitvely.
Python confirms it for me:
>>> 6.0+5.0*4.0/2.0+1.0
17.0
>>> 5.0/2.0+9.0*7.0-5
60.5
:D
Strike
06-12-2002, 08:39 PM
/me is dumb (illiterate):
The operators will be applied sequentially from left to right as we read.
I even quoted that part.
Genetic Algorithms is one of the coolest fields in Computer Science, as far as I can tell. Gonna have to check out this tutorial.
sans-hubris
06-13-2002, 12:41 PM
Neural networks + genetic algorithms = coolest things in CS.
Anyway, genetic algorithms are incredibly simple. I had to work with them over the past year, so feel free to ask questions.
Strike
06-13-2002, 02:37 PM
Another interesting article/tutorial:
http://www.generation5.org/gaexample.shtml
neural networks info
http://www.mathworks.com/access/helpdesk/help/toolbox/nnet/nnet.shtml
also thanks to strike
stuka
06-13-2002, 10:28 PM
CUJ http://www.cuj.com had a good article on genetic algorithms (and a comparison to annealing algorithms) a while back...really cool stuff.
Strike
06-14-2002, 11:16 AM
I am this close (/me gestures by making a tiny space between thumb and forefinger) to having that generation5.org problem coded into Python. I actually built a nice Gene class for it which will make it easier to do some other GA stuff as well. I will post the code here and in the Python forum when I get it completely done, though I'm having a bit of a problem right now - any of the breeding I do seems to actually take the genes farther away from the goal value :(
Strike
06-16-2002, 10:52 PM
I'm attaching the stuff I have so far for those who want to look at it (it's heavily commented, so it shouldn't be too far over people's heads). It's not quite working as I had hoped. Right now it tries to solve the diophantine equation in the generation5.org example above, but it always seems to produce the wrong solution. Actually, just how wrong the solution is is directly proportional to the population pool size. For example, if I have a pool of size 100, I eventually get fitness values of 0.01 for all of the genes. For a pool of size 2, it's 0.5 for both after a few runs.
Note: I'm zipping it because there are two files: diophantine.py (which contains the actual problem/solution), and Gene.py (which is the aforementioned Gene class). To run it simply run "python diophantine.py".
Strike
06-16-2002, 10:54 PM
Note: I'll actually post the code in the Python forum as well.
inkedmn
06-19-2002, 01:05 PM
moving to Programming Blarg...
recluse
06-24-2002, 04:19 PM
Good idea inkedmn :)
I think I like the idea of this forum.
Strike, how goes the GA codz0ring? I haven't heard any updates recently. I would also like to take a look into this stuff but I just haven't had the time. Wait let me rephrase, I undoubtly have the time I just have find it by managing my current time better. I'm actually kinda busy (for me). Though your typical goal oriented HS junior probably has more on their plate.
Yah so, give me the 10-14 man!
Strike
06-24-2002, 05:08 PM
Well, it's pretty much at the same state as what I have uploaded there - haven't looked at it much since. Thankfully Python makes it nice and easy to return to projects like that without having messed with them for a while, and they will still make sense. So, whenever someone gets intrigued by it, or if I do, then I will look at it again. For now, I'm busy with other stuff.
vBulletin® v3.7.0, Copyright ©2000-2009, Jelsoft Enterprises Ltd.