| Ratings |  | Unique User Downloads |  | Download Rankings | 
|    53% |  | Total: 253 |  | All time:  7,888 This week: 560  | 
|  | 
| Description |  | Author | 
| This class implements a genetic algorithm to optimize a population of chromosomes.
 It provides a base class that implements several steps of a genetic algorithm like initializing the population, selection, fitness function, cross-over, mutation and get the best sequence.
 
 The class can be extended by specialized sub-classes that override the population initialization or other steps to customize the genetic algorithm to solve specific optimization problems.
 |  | 
|  |  | Innovation award 
  Nominee: 1x
 | 
 
 | 
Example
| 
<?php
 /*
 this example show how we use SimpleGeneticAlgorithm
 */
 
 require __DIR__ . '/../vendor/autoload.php'; // composer autoload
 
 $ga = new \SimpleGeneticAlgorithm\SimpleGeneticAlgorithm(array(
 
 //'population' => 20,
 //'selection' => 90, // 90%
 'mutation' => 25, // 25%
 
 //'seed' => 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ 1234567890\'.,',
 'goal' => 'Astari Ghaniarti',
 
 //'max_iteration' => 50000,
 'delay' => 50, // ms, if debug is false, then delay forced to 0
 'debug' => true,
 //'fitness_in_percent' => false, // usefull if chromosome more than 10 chars
 ));
 
 
 //var_dump($ga->run());
 $ga->run(); // just run because debug is true
 
 | 
Details
SimpleGeneticAlgorithm
simple genetic algorithm in php,
this package i create just for example how we can implement Genetic Algorithm in PHP
if you inteserted just email me at [email protected] :-)
see interface/GeneticAlgorithm.php
Installation
you can download this with composer (packagist)
<pre><code>composer require ryanhs/simple-genetic-algorithm</code></pre>
Example
in example dir you can see:
- 
example1.php
- 
example2.php
- 
example3.php
example 1
<pre><code>
require '/vendor/autoload.php'; // composer autoload
$ga = new \SimpleGeneticAlgorithm\SimpleGeneticAlgorithm(array(
'mutation' => 25, // 25%
'goal' => 'Astari Ghaniarti',
'delay' => 50, // ms, if debug is false, then delay forced to 0
'debug' => true,
));
$ga->run(); // just run because debug is true
</code></pre>
License
MIT License
		
|  | Applications that use this package |  | 
No pages of applications that use this class were specified.
 If you know an application of this package, send a message to the author to add a link here.
 If you know an application of this package, send a message to the author to add a link here.