Genetics is a genetic algorithm implementation for node;
Genetics is written in CoffeeScript (it can be used in JavaScript as well).

Installation

npm install Genetics

Usage

See test/test.coffee for a quick start.

Class Genetic(solType, totalPop = 100, keepPop = 0)

solType must be an implementation of class Solution()
totalPop is the total number of solutions
keepPop is the number of solutions kept after selection (by default : totalPop / 2)
This class must implement the folowing method :
after implementation, Genetic.init() and Genetic.run() must be called

Genetic.end()

return true if end Conditions is reached
else return false

Genetic.select() (optional)

Select Solutions to be kept from @pop
After the Selection, @pop.length must equal @totalPop

Class Solution()

This class must implement the following methods :

Solution.random()

Generate a random solution.

Solution.crossOver(sol1, sol2)

Generate a solution from sol1 and sol2

Solution.mutate()

Return a mutated solution

Solution.eval()

Set Solution.fit to a number representing the solution's fitness