Introduction to genetic algorithms (example in Javascript)
burakkanber.com
Introduction to genetic algorithms (example in Javascript)
1–10 of 22 posts
Re: Introduction to genetic algorithms (example in Javascript)
#2Re: Introduction to genetic algorithms (example in Javascript)
#3I had a course on design optimisation in the last year of my degree and I'm constantly surprised by just how relevant it is to a lot of different fields. It really is worth familiarising yourself with optimisation techniques if this kind of stuff interests you, because they can be applied to a very broad range of problems.
Re: Introduction to genetic algorithms (example in Javascript)
#4I would love to solicit suggestions for other ML topics and languages to cover as part of this series (please don't suggest "SVMs in brainfuck"). Let me know what you think!
One suggestion I have is to just stick with one language instead of using multiple languages in the series. I understand that you are using different languages to prove the point that ML can be implemented in any language, but when you switch the language between articles, it might get a little awkward to follow. I would suggest teaching in one language which you think can better represent the logic and then provide a link to a github repo or something which has the same code in different languages.
Again, kudos for the effort.
Re: Introduction to genetic algorithms (example in Javascript)
#5I would love to solicit suggestions for other ML topics and languages to cover as part of this series (please don't suggest "SVMs in brainfuck"). Let me know what you think!
Re: Introduction to genetic algorithms (example in Javascript)
#6I would love to solicit suggestions for other ML topics and languages to cover as part of this series (please don't suggest "SVMs in brainfuck"). Let me know what you think!
Since Go is a systems language, I have it running as a http server that sends back the results to webpage that renders the JSON on a HTML5 Canvas.
What I really wanted to do is experiment with "migrating" solutions from one population to another, to see if I can get any speedup that way. Right now, the isolated populations sort of converge at the same speed, but some do better than others, because they converge to different local minima.
Anyway, if you want to fork it, its here: https://github.com/YesSql/GolangTspGa
Re: Introduction to genetic algorithms (example in Javascript)
#7A few points of feedback though:
Typically, what you are calling "genes" are called "chromosomes". Calling them "genes" is confusing because genes typically refer to smaller hereditary units (generally an individual bit on the chromosome). It would also be helpful if you mentioned that what you call "mating" is usually called "crossover".
Also this bit is rather inaccurate in terms of theory:
>Mating alone has a little bit of a problem: in-breeding. If all you do is mate your candidates to go from generation to generation, you run the risk of getting stuck near a “local optimum”: an answer that’s pretty good but not necessarily the “global optimum” (the best you can hope for).
You're sort of looking at all of GA backwards here. Mutation is the main way that a GA arrives at new innovations, and an algorithm with no crossover will do usually pretty well, but will be prone to getting stuck in local optima. This is because it is possible to arrive at a solution where no incremental change can improve the fitness.
Crossover is somewhat helpful against local optima because it allows the algorithm to try combinations of innovations from different solutions. Depending on the fitness landscape, this can be either helpful or useless. Regardless, a GA will, on any non-trivial problem, almost certainly get stuck on a local optimum, which is a very important point for users of GAs to realize.
But what is not the case is that mutation prevents crossover from hitting a local optimum. Crossover by itself basically just won't optimize at all. It's generally best to think of a GA as being driven primarily by mutation and selection, with crossover as a tweak that can make the search more efficient.
Re: Introduction to genetic algorithms (example in Javascript)
#8I was happy to see that you actually were doing genetic algorithms (usually people incorrectly refer to simpler evolutionary algorithms as "genetic", which is a pet peeve of mine). A few points of feedback though: Typically, what you are calling "genes" are called "chromosomes". Calling them "genes" is confusing because genes typically refer to smaller hereditary units (generally an individual bit on the chromosome).…
False. There is no theoretical or comprehensive empirical study I've ever seen to suggest this is the case. At best, in some scenarios (e.g., multiplex, ordered subset selection) crossover will help speed up the search because it is effectively assuming it's separable, meaning different parts of the problem can be optimized independently. So if you're trying to get all 1s in a bit string, you could imagine separating that into two parts: maximizing the first and second halves of the bit string, then combining the best individuals you would get an optimal answer to the original problem. This is why, for instance, that crossover rarely helps in evolving neural networks; their weights' non-separable nature makes it difficult to select a meaningful subset of the network.
> Crossover is somewhat helpful against local optima because it allows the algorithm to try combinations of innovations from different solutions. Depending on the fitness landscape, this can be either helpful or useless. Regardless, a GA will, on any non-trivial problem, almost certainly get stuck on a local optimum, which is a very important point for users of GAs to realize.
Also false. I'll especially take note that this is not the case if you're using a less-than-naive EA. One great example is CMA-ES, which is particularly well suited for handling non-convex, deceptive optimization problems (and uses no crossover).
> But what is not the case is that mutation prevents crossover from hitting a local optimum. Crossover by itself basically just won't optimize at all
Again, not true. Consider multiplex. You start with a bunch of random bit strings. IF you have 1s in all indexes somewhere in the population, it's possible (though unlikely) that the algorithm will find the optimal answer. The issue that arises is when you select against the last 1 bit in a certain index in the population; it's now lost forever and thus the GA will at best reach a local optima (optima in the sense of it's the best it can now do with future populations).
Re: Introduction to genetic algorithms (example in Javascript)
#9I would love to solicit suggestions for other ML topics and languages to cover as part of this series (please don't suggest "SVMs in brainfuck"). Let me know what you think!