File tree 1 file changed +14
-1
lines changed
1 file changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -81,11 +81,24 @@ def updatePosition2(self, population):
81
81
populationSize = self ._populationSize
82
82
for i in range (populationSize ):
83
83
d1 , d2 = np .random .randint (0 , 5 , 2 )
84
+ changed = False
84
85
for j in range (self ._chromlen ):
85
86
r = np .random .rand ()
86
87
if r < self ._pa :
88
+ changed = True
87
89
self ._current_position [i , j ] += random .random () * (current_position [d1 , j ] - current_position [d2 , j ])
88
- self ._current_position [i ] = self .optimum (self ._current_position [i ], population [i ])
90
+
91
+ if changed :
92
+ self ._current_position [i ] = self .optimum (self ._current_position [i ], population [i ])
93
+
94
+
95
+ def reform (self ):
96
+ random .seed (round (time () * 1000 ))
97
+ np .random .seed (int (time ()))
98
+ if self ._crossoverProbability < 95 :
99
+ self ._crossoverProbability += 1.0
100
+ elif self ._pa < .5 :
101
+ self ._pa += .01
89
102
90
103
91
104
def replacement (self , population ):
You can’t perform that action at this time.
0 commit comments