Genetically
A Genetic Algorithm library designed for typescript
Live example and informations about genetically can be founds in the demonstration
Install
Using npm :
$ npm install -S genetically
Examples
Take a look at the examples on simple functions made for optimization problems:
- Linear function
f(x) = -x²
- Cube function
f(x) = x³
- Booth function
f(x, y) = (x + 2y - 7) ** 2 + (2x + y - 5) ** 2
- Baele function
f(x, y) = (1.5 - x - x*y) ** 2 + (2.25 - x + (x*y) ** 2) ** 2 + (2.625 - x + (x*y) ** 3) ** 2
Usage
Simple use case
; ; genetic.run;
More complex usage with the LinearGeneticAlgorithm example.
; // Create a GeneticAlgorithm Object from a test function;gaLinear.run;gaLinear.display; // Or create you own genetic algorithm /** * Random starting value */; /** * Transform x * start is [-32, 32] * end is [000000, 111111] */;; /** * Transform x * start is [000000, 111111] * end is [-32, 32] */; /** * Function to optimize * f(x) = x² */; // Make the genetic algorithm object; // Compute the fitness of the population and display itga.runPopulation;ga.display; // Evolve the populationga.run; // After the evolution is complete, display it console.log'End evolution';ga.display;
Documentation
Please take a look at the documentation for references on how to use the library.