Genetic Algorithms?

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

  1. CodeX

    CodeX Guest

    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 :x:
  2. sandor3kgt

    sandor3kgt New Member

    Nov 1, 2006
    Likes Received:
    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

    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)
    add child to new_population
    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.

    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. FartLighter

    FartLighter Resident Fart Expert OT Supporter

    Jul 5, 2005
    Likes Received:
    Check out:

    I found it to be a good book.

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

    CodeX Guest

    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.

Share This Page