We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 6e1a430 commit d2db23bCopy full SHA for d2db23b
GeneticAlgorithm.php
@@ -21,6 +21,7 @@ class GeneticAlgorithm
21
public $probability = array();
22
public $cumulative_probability = array();
23
public $crossover_rate = 0.25;
24
+ public $mutation_rate = 0.1;
25
public $population = 200;
26
27
public $total_fitness = 0;
@@ -83,4 +84,12 @@ public function crossOver() {
83
84
$iteration = 0;
85
var_export($this->chromosome(1));
86
}
87
+
88
+ public function mutation(){
89
+ $mutation_count = round((3 * 5) * $this->mutation_rate, 0, PHP_ROUND_HALF_DOWN);
90
+ for ($i=0;$i<$mutation_count;$i++){
91
+ $position = rand(1,(3 * 5));
92
+ $chossed_chrom = round($position / 3 , 0 , PHP_ROUND_HALF_UP) - 1;
93
+ }
94
95
0 commit comments