Genetic Algorithms in CoffeeScript(janmonschke.com) |
Genetic Algorithms in CoffeeScript(janmonschke.com) |
https://github.com/janmonschke/Genetic-Algorithms/tree/gh-pa...
- It is deterministic, hence not a black box - It is a local search, easy to explain - Does not require as many parameters to tweak (GAs' performance demands on how you set these: mutation rate, population size, cross-over mechanism (dozens of possibilities), stopping procedure, selection procedure, etc...) - Considered by literature to be one of the strongest class of algorithms for the class of TSP problems, in both solution quality and computational effort
Here's an open-source implementation in Common Lisp: https://github.com/mck-/Open-VRP
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.
Here's a TSP challenge for you to prove yourselves: http://www.tsp.gatech.edu/data/usa/index.html
Deadline is July 4th, 2013 -- Price $500 & Honourable mention for finding the shortest path to the world's largest TSP problem.
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 /.
(I ask because this discussion is talking about both the genetic algorithms and Coffeescript).
Hmm... maybe some sort of GPS application that took into account current road conditions -- length of time stopped at traffic lights, performance characteristics of the current vehicle (velocity and acceleration away from lights, etc).
At one time there was talk of making the air traffic control system distributed rather than centralized. The win there is that 1) each aircraft only has to worry about the other aircraft that near enough to interfere and 2) if the control system goes out in one aircraft, the systems in the other aircraft can compensate. By contrast the centralized system has to watch all the aircraft in a large chunk of airspace, and if it goes out, well...
This is sort of what Google is doing with their self-driving cars, I think (that's just my impression -- I haven't looked into it in detail).
You may want to fix the links in the readme though.
...than u rule da web.
- 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.
The javascript seems to be mainly horrible because of the coffeescript code being object oriented and its lack of a more powerful looping construct.
Population = (function() { Population.prototype.genomes = []; })();
This throws a ReferenceError because Population is not defined.
Genome = (function() {
Genome.prototype.values = [];
function Genome(values) {
this.values = values != null ? values : this.initial();
}
Genome.prototype.inital = function(){
return [RANDOMARRAY FROM [0-14]]
}
})();After this part Genome will be undefined.
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.
In particular they tuned the GA but not he hill climber, so it's not clear that GAs win even on this artificially designed problem.
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.
"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."
"We have presented analyses of two algorithms, RMHC and the IGA, and have used the analyses to identify some general principles of when and how a genetic algorithm will out- perform hill climbing."
I'm not sure this paper says what you're claiming that it says.
Second, to get a result where a GA outperformed hill climbing they did the following:
1. They started with a problem that was DESIGNED to be very well suited to GAs and not so well suited to hill climbing. It turned out that when you do hill climbing in a non ridiculous way that GAs lose big time (by a factor of 10).
2. Through several steps they further modified the artificial problem to give a disadvantage to hill climbing and an advantage to GAs.
3. They tuned the GA's parameters and did not tune the hill climber's parameters.
4. They compared the performance by number of fitness function evaluations. This is unfair to hill climbing because GAs have bigger overheads elsewhere.
After these steps the GA outperformed hill climbing by about a factor of 2. So it is not clear that the GA would still win if you tuned the hill climber. Even if it did, this is a problem explicitly designed to give GAs an advantage. The fact that they had to go through so much effort to design such a problem doesn't instill much confidence that there exists a real world problem where GAs work.
I have tried to replicate their results and do the tuning of the hill climber, but unfortunately the paper is so vague on what the problem is that the algorithms are actually supposed to solve, so that I was not able to do this. If anybody knows a study of a problem (preferably real world) where GAs are shown to outperform reasonable forms of hill climbing I'd be very happy to hear it.
GA (specially pseudo-boolean GA) is not a "Golden Algorihtm" that solves every problem as most people think, rather it is a "idea" that was pioneered by Hollad in the sixties, now it's sole purpose is to explain the theoretical aspects of other GA-offshoot Evolutionary Optimization techniques like GP(Genetic Programming), EA (Evolutionary Algorithm), DE(Differential Evolution), ES(Evolutionary Strategy) etc, etc.
I think GP has much more impact in attacking real world problems, GECCO Humies award list has many interesting results where RMHC's may not be suitable -- http://www.genetic-programming.org/combined.html
Well, yeah, you'd want to use GAs on problems for which they were well-suited. That's not at all the same as "clearly shows that GAs are NOT a good way to solve any problem".
The financial markets are a bit like that - stochastic exogenous factors (headline risk like the Euro crisis, the FOMC meeting decisions etc.) and evolved responses based on the principle of no-arbitrage (ie other traders) determine portfolio performance and trading decisions along with transaction costs.
But GAs as they exist are unsuitable for this, from what I've gathered from conversations with those quants. The modifications required appear to be in the direction of structured intra-generation genome modification (or adaptation) rather than pure randomness and crossover to produce agents with a specific trading behaviour (much in the same way as evolution allows a sensible change in the DNA to produce a particular protein suited for a task).
Yes, that's my opinion too. GAs model natural selection, which is extremely slow. The only reason it works in nature is the huge timescales and the lack of anything better (since it has to start from essentially nothing - there is no designer).
But I agree, that they are not a silver bullet for any kind of problem and for most problems there is almost always a way smarter and more efficient algorithm. I did not hold this presentation to show that GAs were the best solution for any problem. My intention was to teach sth. that I myself liked in university. Especially I thought that the way we were taught GAs in university was too complicated and complex.