Programming Tools
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingProgramming Tools

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old January 14th, 2004, 01:49 PM
dhouston's Avatar
dhouston dhouston is offline
Contributing User
Dev Articles Beginner (1000 - 1499 posts)
 
Join Date: May 2003
Location: Tennessee
Posts: 1,355 dhouston User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
Send a message via ICQ to dhouston
Genetic Algorithms

Anybody have any thoughts on or experience with writing genetic algorithms? I tried my first one recently and am eager to hear about other people's experience. To kick things off, I'll describe mine.

It's a genetic algorithm through and through in that it emulates natural selection. I wrote an Ant class and a Couple class. The Ant class contains information about individual Ant objects, including a DNA sequence, the DNA sequence of both parents, and the gene selected for in the current run of the program. The primary method for the Ant class is a little algorithm for determining whether or not the ant is fit to procreate (about which more in a minute).

The Couple class is a wrapper around two ants chosen almost randomly. Its primary method is one I chose in a fit of elementary-school snickering to call "screw" ($couple->screw()) that disassembles the DNA of both parents and spawns a new ant in a new generation using slices of DNA from both parents.

I spawn a random population of ants to begin with, and then I loop through X generations and spawn Y ants for each generation. After the initial random generation, only ants deemed fit based on their genome may breed to produce future generations. So the gene I'm selecting for gradually begins to appear more and more frequently. The more generations, the higher the frequency. And voila, a genotype that found its way into the genome more or less randomly in the first generation becomes a common trait of the species; or, to put it another more concrete (if not ant-specific) way, the opposable thumb is born.

A strand of DNA for my purposes is composed of four two-letter pairs using the 16 possible such combinations of the letters a - d. So aa_bd_ca_bc_ would be one possible strand of DNA. I select for double letters within one pair, so if I decide to select for "a," only ants who have the sequence "aa_" in their DNA can mate.

Genetic algorithms are sometimes used in programming to find the best way of accomplishing a task. They're meta-programming, in a way. You feed a problem to a genetic algorithm, and it attempts to solve the problem in various (random) ways. Each iteration is scored, and as additional attempts are made, past attempts that scored well stand to be recombined with other attempts that do well. I'm not sure how this works in practice (how you write something that attempts random unwritten logic to solve problems), but I hear it's pretty cool. My little program is one of the simplest examples of this sort of algorithm, I imagine.

Anybody else got any experience with genetic algorithms?

Reply With Quote
  #2  
Old January 15th, 2004, 06:56 AM
stumpy's Avatar
stumpy stumpy is offline
May contain nuts.
Dev Articles Regular (2000 - 2499 posts)
 
Join Date: Aug 2002
Location: Sydney, AU
Posts: 2,058 stumpy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 8 m 57 sec
Reputation Power: 9
Send a message via ICQ to stumpy Send a message via MSN to stumpy
Sounds very kewl - my dad has a similar real world problem at the moment, trying to find the best way to structure a large law firm. i.e. Trying to put the best people in the best (re: productive) positions. He's trying to come at it from a different angle (people rather than $$), and is really struggling apparently. While he was telling me, I was thinking, this would be prefect for some kind of "AI-ish" type program...

So is there a major difference between AI and Genetic programming?

Reply With Quote
  #3  
Old January 15th, 2004, 07:48 AM
dhouston's Avatar
dhouston dhouston is offline
Contributing User
Dev Articles Beginner (1000 - 1499 posts)
 
Join Date: May 2003
Location: Tennessee
Posts: 1,355 dhouston User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
Send a message via ICQ to dhouston
I'm no expert, but I imagine AI uses genetic algorithms to arrive at some decisions. I imagine, for example, that AI keeps track of all decisions it's made in the past and weighs future decisions against those of the past and their consequences to determine what to do next.

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingProgramming Tools > Genetic Algorithms


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway
Stay green...Green IT