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 0146050 commit 892fe1aCopy full SHA for 892fe1a
GeneticAlgorithm.php
@@ -33,7 +33,24 @@ public function __construct()
33
$this->calcFitness();
34
$this->calcProbability();
35
36
- var_dump($this->cumulative_probability);
+ $new_chromosome = array();
37
+
38
+ for ($i=0;$i<5;$i++) {
39
+ $r[$i] = mt_rand() / mt_getrandmax();
40
41
+ for ($j=0;$j<5;$j++){
42
+ if ($j == 0) {
43
+ if ($r[$i] < $this->cumulative_probability[0])
44
+ $new_chromosome[$i] = $this->chromosome[0];
45
+ }else {
46
+ if ($r[$i] > $this->cumulative_probability[$j - 1] && $r[$i] < $this->cumulative_probability[$j])
47
+ $new_chromosome[$i] = $this->chromosome[$j];
48
+ }
49
50
51
52
53
+ var_dump($new_chromosome);
54
}
55
56
public function calcFx(){
0 commit comments