For a school project, I have to implement Simulated Annealing meta heuristic.
Thanks to many open source web tools, I've been able to quickly do the project and have a pretty display. CoffeeScript, Raphael, Highcharts, Three.js, Twitter Bootstrap, jQuery and Web Workers.
2D Demo
You have a shuffled grid and you have to find the original grid. The only operation available is to swap 2 random elements. The cost function is the distance of the point with their original neighbors.
3D Demo
On this one, we are given many functions and we have to find the global minimum. The challenge was to be able to display the evolution of the algorithm, as it traverses 200k points per second.
CoffeeScript Sexyness
I've written the project in CoffeeScript and I don't regret it. I find myself writing code a lot faster because I have a lot less to type. Most of the Javascript syntax is either shortened (function
to ->
) or optional (parenthesis, curly brackets ...) in CoffeeScript. There are also handy features such as splats, generators ...
Destructuring Assignment
worker.onmessage = (data: [id, rest...]) -> switch id when 'update' [cost, temperature, accepted, tried, data, force] = rest |
Trimmed JSON
chart = new Highcharts.Chart chart: renderTo: 'container' yAxis: [ title: text: 'Cost' ] tooltip: formatter: -> this.series.name + ': ' + this.y |
Report
Felix Abecassis wrote a report that explains everything 🙂 It's in French, sorry!