Monthly Archives: September 2012

TDD: Links, News And Resources (5)

Previous Post

You know: production code without TDD is condemned by Geneva Convention ;-). More resources about one of my favorites topics:

mfncooper / sidedoor
https://github.com/mfncooper/sidedoor
Exposing a secondary API for your Node.js modules

Kata – the Only Way to Learn TDD
http://www.peterprovost.org/blog/2012/05/02/kata-the-only-way-to-learn-tdd/
Test Driven Development in PHP
http://stackoverflow.com/questions/46276/test-driven-development-in-php

Unit testing in node.js
http://caolanmcmahon.com/posts/unit_testing_in_node_js

Unit testing node.js apps
http://cjohansen.no/en/node_js/unit_testing_node_js_apps

Test Driven Development in Python
http://powertwenty.com/kpd/downloads/TestDrivenDevelopmentInPython.pdf

Ruby, Setting $stdout per-thread
http://blog.segment7.net/2006/08/16/setting-stdout-per-thread

TATFT — I feel a revolution coming on
http://smartic.us/2008/08/15/tatft-i-feel-a-revolution-coming-on/

Just enough testing
http://smartic.us/2012/04/12/just-enough-testing/

Testing like the TSA
http://37signals.com/svn/posts/3159-testing-like-the-tsa

ELisp Testing
http://nic.ferrier.me.uk/blog/2011_09/elisp_testing

Jasmine
http://pivotal.github.com/jasmine/
Jasmine is a behavior-driven development framework for testing your JavaScript code.

Why I hate Test Driven Development
http://www.altdevblogaday.com/2012/03/30/why-i-hate-tdd/

How to not solve a Sudoku
http://devgrind.com/2007/04/25/how-to-not-solve-a-sudoku/

Sudoku 4: Disaster Narrowly Averted
http://xprogramming.com/xpmag/Sudoku4
Sudoku: Learning, Thinking and Doing Something About It
http://xprogramming.com/xpmag/SudokuMusings

Moving On With Sudoku
http://xprogramming.com/xpmag/Sudoku2

OK, Sudoku
http://xprogramming.com/xpmag/OkSudoku

ASP.NET Web Forms 4.5, MVVM and Testability
http://blogs.microsoft.co.il/blogs/oric/archive/2012/02/22/asp-net-web-forms-and-mvvm.aspx
MS Test, el framework de test de Visual Studio 2010
http://www.genbetadev.com/herramientas/ms-test-el-framework-de-test-de-visual-studio-2010

Erlang EUnit – introduction
http://erlcode.wordpress.com/2010/08/30/erlang-eunit-introduction/

My Links
http://delicious.com/ajlopez/tdd

Keep tuned!

Angel “Java” Lopez
http://www.ajlopez.com
http://twitter.com/ajlopez

SimpleGA (1) Genetic Algorithms in Javascript/Node.js

Two week ago, I was writing:

https://github.com/ajlopez/SimpleGA

a Simple Genetic Algorithm base framework, that supports population, evaluation and mutator operators (I should add crossover operators). The base algorithm is based on

A Genetic Algorithm Tutorial (pdf)

You can create a population of genotypes, each one with an evaluation function. The library evaluates each genotypes and prepares another population, based on the value of each genotype, copying the best ones, and mutating some of the initial specimen based on fitness. The fitness value is v = fi / fa, where fi is the individual fitness evaluation, and fa is the fitness average. The integer part of v determines the count of copies of an individual that survives to the next generation. The fraction part is the probability of having a mutated copy in the next generation set of genotypes:

var newpopulation = [];

for (var k = 0; k < l; k++) {
	if (values[k] < 0)
		continue;
		
	var fitness = values[k] / total;
	
	if (fitness < 0)
		continue;
		
	var ntimes = Math.floor(fitness);
	var fraction = fitness - ntimes;
	
	for (var j = 0; j < ntimes; j++)
		newpopulation.push(population[k]);
		
	if (fraction > 0 && Math.random() <= fraction)
		newpopulation.push(population[k]);
}

if (mutators && mutators.length > 0) {
	l = newpopulation.length;
	var lm = mutators.length;
	
	for (k = 0; k < l; k++) {
		var mutator = mutators[Math.floor(Math.random() * lm)];
		newpopulation[k] = mutator.mutate(newpopulation[k]);
	}
}

(I should add crossover operator support). There is a sample implementing the Travelling Saleman Problem

https://github.com/ajlopez/SimpleGA/blob/master/samples/tsp/tsp.js

running in console using https://github.com/ajlopez/SimpleGA/blob/master/samples/tsp/program.js

It can run from the console, or you can launch a local web page:

https://github.com/ajlopez/SimpleGA/blob/master/samples/tsphtml/index.html

I wrote client/server version (web page at browser, Node.js server program) and a distributed version (the evaluation of many population running in many server nodes, coordinated by a Node.js server, showing results in a browser).

Next steps: add crossover operators, sample short descriptions, more samples.

Keep tuned!

Angel “Java” Lopez

http://www.ajlopez.com

http://twitter.com/ajlopez

Genetic Algorithms: Links and resources (1)

These days, I wrote a simple genetic algorithm in Javascript, runing at browser, and at server (Node.js), even with distributed load (see https://github.com/ajlopez/SimpleGA) I should write a post about that code (my previous posts with experiments in C#), but first, I want to share some of my genetic algorithm links:

http://en.wikipedia.org/wiki/Genetic_algorithm

In the computer science field of artificial intelligence, a genetic algorithm (GA) is a search heuristic that mimics the process of natural evolution. This heuristic is routinely used to generate useful solutions to optimization and search problems. Genetic algorithms belong to the larger class of evolutionary algorithms (EA), which generate solutions to optimization problems using techniques inspired by natural evolution, such as inheritance, mutation, selection, and crossover.

Robocode with JGAP
http://jgap.sourceforge.net/doc/robocode/robocode.html

Andy’s Genetic Programming- GPQuick and Doodle Garde
https://www.assembla.com/wiki/show/bhmk_e1jWr3zqkab7jnrAJ/bhmk_e1jWr3zqkab7jnrAJ

Genetic Algorithms: Cool Name & Damn Simple
http://dev.lethain.com/genetic-algorithms-cool-name-damn-simple/

Local Optimization Software
http://www.mat.univie.ac.at/~neum/glopt/software_l.html

E-Book "Global Optimization Algorithms — Theory and Application"
http://www.it-weise.de/projects/
This book elaborates on many of the basic principles in global optimization, Evolutionary Algorithms, and Genetic Programming.

Evolvable Hardware
http://pages.cpsc.ucalgary.ca/~jacob/Courses/Winter2003/CPSC601-73/Slides/10-EvolvableHardware.pdf

Genetic A/B Testing with JavaScript
http://ejohn.org/blog/genetic-ab-testing-with-javascript/

Introduction to Genetic Algorithms
http://www.rennard.org/alife/english/gavintrgb.html
Genetic Programming: Evolution of Mona Lisa
http://rogeralsing.com/2008/12/07/genetic-programming-evolution-of-mona-lisa/

Time for Genetic Programming?
http://blog.assembla.com/assemblablog/tabid/12618/bid/5680/Time-for-Genetic-Programming.aspx

Help! My Product Development is Going TOO FAST
http://blog.assembla.com/assemblablog/tabid/12618/bid/2448/Help-My-Product-Development-is-Going-TOO-FAST.aspx
Use evolution: We can build a machine that evolves the product by user-testing variations.

Discipulus 5 Genetic Programming Predictive Modelling
http://www.rmltech.com/
Genetic Algorithm Library
http://www.codeproject.com/Articles/26203/Genetic-Algorithm-Library

A FIELD GUIDE TO GENETIC PROGRAMMING
http://www.gp-field-guide.org.uk/

Genetic Algorithms
http://www.aiai.ed.ac.uk/technology/geneticalgorithms.html

An Introduction to Genetic Algorithms In Java
http://java.sys-con.com/node/36224

Survival of the Fittest: Natural Selection with Windows Forms
http://msdn.microsoft.com/en-us/magazine/cc163934.aspx
What is Genetic Programming?
http://www.genetic-programming.com/gpanimatedtutorial.html

Genetic Algorithms
http://www.doc.ic.ac.uk/~nd/surprise_96/journal/vol4/tcw2/report.html

Global Optimization Toolbox
http://www.mathworks.com/products/global-optimization/index.html

Travelling salesman problem
http://en.wikipedia.org/wiki/Traveling_Salesman_Problem
GAlib
A C++ Library of Genetic Algorithm Components
http://lancet.mit.edu/ga/

My Links
http://delicious.com/ajlopez/geneticalgorithms

Keep tuned!

Angel “Java” Lopez
http://www.ajlopez.com
http://twitter.com/ajlopez

New Month’s Resolutions: September 2012

Time to write the new month’s resolutions. First, the past month review:

– Start to prepare talk Python Argentina [complete]
– Work on PythonSharp [pending]
– Write a new post about TDD [complete] see post
– Continue to prepare a talk about code generation in Ruby [complete]
– Start to prepare talk about distributed applications (examples in NodeJs) [complete]

I was busy in my non-technical resolution (see Spanish post).

Resolutions for September:

– Give a talk about distributed applications
– Give a talk about TDD for .NET
– Continue working on PythonSharp
– Continue preparing the talk about code generation in Ruby
– Continue preparing my talk for Python Argentina
– More work on AjConsorSite
– Work on AjContab (PHP version)
– Work on AjTalk for Java

Keep tuned!

Angel “Java” Lopez
http://www.ajlopez.com
http://twitter.com/ajlopez