File tree Expand file tree Collapse file tree 1 file changed +8
-7
lines changed Expand file tree Collapse file tree 1 file changed +8
-7
lines changed Original file line number Diff line number Diff line change @@ -38,13 +38,6 @@ public function __construct()
38
38
echo "init chromosome is: " .json_encode ($ this ->chromosome );
39
39
40
40
while (is_null ($ finish_point ) && $ this ->iteration < $ this ->population ) {
41
-
42
- for ($ i = 0 ; $ i < 5 ; $ i ++){
43
- if ($ this ->chromosome [$ i ][0 ] + 2 * $ this ->chromosome [$ i ][1 ] + 3 * $ this ->chromosome [$ i ][2 ] == 10 ) {
44
- $ finish_point = $ i ;
45
- }
46
- }
47
-
48
41
$ this ->selection ();
49
42
50
43
echo "<br> $ this ->iteration => selection chromosome is: " . json_encode ($ this ->chromosome );
@@ -58,6 +51,14 @@ public function __construct()
58
51
echo "<br> $ this ->iteration => mutation chromosome is: " . json_encode ($ this ->chromosome );
59
52
60
53
$ this ->iteration ++;
54
+
55
+ for ($ i = 0 ; $ i < 5 ; $ i ++){
56
+ if ($ this ->chromosome [$ i ][0 ] + 2 * $ this ->chromosome [$ i ][1 ] + 3 * $ this ->chromosome [$ i ][2 ] == 10 ) {
57
+ $ finish_point = $ i ;
58
+ $ this ->calcFx ();
59
+ $ this ->calcFitness ();
60
+ }
61
+ }
61
62
}
62
63
63
64
echo "<br>when finish chromosome is: " .json_encode ($ this ->chromosome );
You can’t perform that action at this time.
0 commit comments