File tree Expand file tree Collapse file tree 1 file changed +7
-6
lines changed Expand file tree Collapse file tree 1 file changed +7
-6
lines changed Original file line number Diff line number Diff line change @@ -38,6 +38,13 @@ 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
+
41
48
$ this ->selection ();
42
49
43
50
echo "<br> $ this ->iteration => selection chromosome is: " . json_encode ($ this ->chromosome );
@@ -51,12 +58,6 @@ public function __construct()
51
58
echo "<br> $ this ->iteration => mutation chromosome is: " . json_encode ($ this ->chromosome );
52
59
53
60
$ 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
- }
59
- }
60
61
}
61
62
62
63
echo "<br>when finish chromosome is: " .json_encode ($ this ->chromosome );
You can’t perform that action at this time.
0 commit comments