# Genetic Algorithms?

Discussion in 'OT Technology' started by CodeX, Dec 23, 2009.

1. ### CodeXGuest

Anyone have any experience here?

Never really got to into this in school but I have been looking into it and it's really interesting and something I'd like to learn more about, so if anyone has any good resources or code samples that would be cool

2. ### sandor3kgtNew Member

Joined:
Nov 1, 2006
Messages:
646
0
Some dubiously helpful psuedocode from one of my favorite books, Artificial Intelligence: A Modern Approach:

function GENETIC-ALGORITHM(population, FITNESS-FN) returns an individual
inputs: population, a set of individuals
FITNESS-FN, a function that measures the fitness of an individual

repeat
new_population <- empty set
loop for i from 1 to SIZE(population) do
x <- RANDOM-SELECTION(population, FITNESS-FN)
y <- RANDOM-SELECTION(population, FITNESS-FN)
child <- REPRODUCE(x, y)
if(small random probability) then child <- MUTATE(child)
population <- new_population
until some individual is fit enough, or enough time has elapsed
return the best individual in population, according to FITNESS-FN
-----
function REPRODUCE(x, y) returns an individual
inputs: x, y, parent individuals

n <- LENGTH(x)
c <- random number from 1 to n
return APPEND(SUBSTRING(x, 1, c), SUBSTRING(y, c + 1, n))

-----
That REPRODUCE method is specific to a particular formation of the n-queens problem in the book, but you essentially just need to replace it with some method that scrambles the "DNA" of your objects.

Last time I went through the bookstore at MIT, I remember seeing a lot of good books discussing them. http://mitpress.mit.edu/catalog/browse/default.asp?cid=5

I'm sure you've already searched Amazon for books on genetic algorithms, so I won't suggest it...

Good luck. Genetic algorithms are a fascinating subset of ideas from an already incredibly interesting field (AI). Do something awesome with them.

3. ### FartLighterResident Fart ExpertOT Supporter

Joined:
Jul 5, 2005
Messages:
3,028
266
Check out:
http://www.amazon.com/Introduction-...=sr_1_2?ie=UTF8&s=books&qid=1261870047&sr=8-2

I found it to be a good book.

The field guide in "related items" looks good as well.

4. ### CodeXGuest

blah books... lol thanks but I generally don't use books I was hoping for a decent online tutorial with some code samples or something... I'm a cheap bastard when it comes to buying books to do something that is basically just a hobby.

Really, thanks though, I know this is a rather obscure topic that not many people would be familiar with, but I was hoping to find someone who has first hand experience.

As soon as I get some time after the holidays I'll start experimenting with this stuff on my own, I've always learned better by doing things through trial and error rather than by reading about it. I'm mostly interested in how many different applications this type of thing might have, I know it is used to more or less brute force solutions to difficult problems but I'm sure it could be used in algorithm optimization and other applications as well.