Live data from Hacker News

Genetic Algorithms in CoffeeScript

janmonschke.com

11–20 of 48 posts

Re: Genetic Algorithms in CoffeeScript

#11

Earlier quoted context omitted.

It's my main language for almost two years now ;)

I'm not saying that it being your main language is bad, it's just the syntax is absolutely terrible to read and understand for those of us on C-style languages. If the point was to teach others, the vast majority of your audience is not going to be reading coffeescript and learning much.

In all code examples you can press the down arrow to view the horrible (c-style) Javascript source.

The javascript seems to be mainly horrible because of the coffeescript code being object oriented and its lack of a more powerful looping construct.

Re: Genetic Algorithms in CoffeeScript

#12
post #4

Suggestion: TSP is a combinatorial optimization problem and isn't well suited to GAs. You would be much better off using a method meant for combinatorial optimization: notably ant colony optimization.

If you don't mind expanding a little, I'd be interested to know why they're not suited to combinatorial optimization, and what they are in fact more suited to?

I have searched for a problem that they're more suited to, and I've come to the conclusion that GAs are in fact not known to work on any problem. They do "work" in the sense that sometimes they find an answer, but there are other algorithms that are much simpler and consistently outperform them (notably randomized hill climbing). Here is a paper that despite trying to prove the opposite, clearly shows that GAs are NOT a good way to solve any problem: http://web.cecs.pdx.edu/~mm/nips93.pdf

Re: Genetic Algorithms in CoffeeScript

#13

Earlier quoted context omitted.

It's my main language for almost two years now ;)

I'm not saying that it being your main language is bad, it's just the syntax is absolutely terrible to read and understand for those of us on C-style languages. If the point was to teach others, the vast majority of your audience is not going to be reading coffeescript and learning much.

IMHO, I don't think it is fair to suggest this.

- There are GA tutorials available in several other languages, if this doesn't work for you. Btw, if a tutorial was offered in Lisp/Haskell, would we see the same suggestion?

- For Ruby/Python programmers, this isn't hard at all to read. Familiarity with non C-style languages might be something to pick up.

- Having moved to Coffee from C-style languages, I prefer coffee. But that is just my opinion.

I think HNers should be more tolerant of language choices. That argument can't really be won.

Re: Genetic Algorithms in CoffeeScript

#14

Can't help this example could have been illustrated much more clearly in something other then CoffeeScript.

The coffeescript rocks/sucks crowd does not belong here. This person wrote a blog post explaining something using a language he is familiar with.

If articles are boiled down to a shouting match because the java-haters or the coffeescript-haters or the ruby-haters found the article first we all may as well go back to /.

Re: Genetic Algorithms in CoffeeScript

#15
post #12

Earlier quoted context omitted.

If you don't mind expanding a little, I'd be interested to know why they're not suited to combinatorial optimization, and what they are in fact more suited to?

I have searched for a problem that they're more suited to, and I've come to the conclusion that GAs are in fact not known to work on any problem. They do "work" in the sense that sometimes they find an answer, but there are other algorithms that are much simpler and consistently outperform them (notably randomized hill climbing). Here is a paper that despite trying to prove the opposite, clearly shows that GAs are NO…

That's not quite my understanding of the paper's results: "As can be seen, the time to reach level one is comparable for the two algorithms, but the GA is much faster at reaching levels 2 and 3. Further, the GA discovers level 3 approximately twice as often as RMHC [randomized hill climbing]"

I don't dispute that there are generally better optimization algorithms than GAs, but this paper does present an artificial case in a GA outperforms hill climbing.

Re: Genetic Algorithms in CoffeeScript

#16
post #4

Suggestion: TSP is a combinatorial optimization problem and isn't well suited to GAs. You would be much better off using a method meant for combinatorial optimization: notably ant colony optimization.

If you don't mind expanding a little, I'd be interested to know why they're not suited to combinatorial optimization, and what they are in fact more suited to?

I would reserve GAs (at least in their naive form) as a last-resort option. They are extremely inefficient solutions because it doesn't exploit any structure in the problem.

Essentially, a GA solution consists of:

1. Select a random point(s) in the search space, hoping that you have arrived at a sufficiently good solution.

2. If none of the solutions are not good enough, generate a new set of points by combining the best available points and adding a bit of random error.

3. Repeat the above until time has run out/u've hit a good enough solution.

However having said that, GAs can be a good option if 1)not much is known about the function you are trying to optimize, or 2)the crossover/mutation functions are designed to reflect some problem structure, or 3)the search space is small enough.

Re: Genetic Algorithms in CoffeeScript

#18
post #12

Earlier quoted context omitted.

If you don't mind expanding a little, I'd be interested to know why they're not suited to combinatorial optimization, and what they are in fact more suited to?

I have searched for a problem that they're more suited to, and I've come to the conclusion that GAs are in fact not known to work on any problem. They do "work" in the sense that sometimes they find an answer, but there are other algorithms that are much simpler and consistently outperform them (notably randomized hill climbing). Here is a paper that despite trying to prove the opposite, clearly shows that GAs are NO…

I've seen GA's work as a way to tune parameters on an SVM, with pretty good results.

Re: Genetic Algorithms in CoffeeScript

#20
post #12

Earlier quoted context omitted.

If you don't mind expanding a little, I'd be interested to know why they're not suited to combinatorial optimization, and what they are in fact more suited to?

I have searched for a problem that they're more suited to, and I've come to the conclusion that GAs are in fact not known to work on any problem. They do "work" in the sense that sometimes they find an answer, but there are other algorithms that are much simpler and consistently outperform them (notably randomized hill climbing). Here is a paper that despite trying to prove the opposite, clearly shows that GAs are NO…

Most GAs are not a very faithful adaptation of actual biological evolution, either. The real evolutionary process is a bit different. Most notably, the "agent" actually implements the algorithm in the sense that it performs its own self-replication and implements the "operators" (crossover, etc.) within its own embodiment. This has certain implications, most notably that the algorithm itself is subject to evolution.

There are other big holes too. For example, few GAs implement anything resembling ontogeny or lifetime learning, and generally have a poor genotype/phenotype divide. That also has big implications. It's a big reason most GAs are far too "greedy" and get stuck at local maxima easily.

Post reply on HN