我在遗传算法中使用随机通用抽样。我找到了它的伪代码。在使用Python编码时暴露了3个问题。错误是:序列的真值是模棱两可的。使用a.empty、a.bool()、a.item()、a.any()或a.all()。有人能帮我吗?在
伪代码:
SUS(Population, N)
F := total fitness of Population
N := number of offspring to keep
P := distance between the pointers (F/N)
Start := random number between 0 and P
Pointers := [Start + i*P | i in [0..(N-1)]]
return RWS(Population,Pointers)
RWS(Population, Points)
Keep = []
for P in Points
i := 0
while fitness sum of Population[0..i] < P
i++
add Population[i] to Keep
return Keep
我的审判代码如下:
^{pr2}$
我使用python3使用了以下代码。我希望它能帮助暴露同样问题的人。在
这是我的实现,可能会有帮助!在
相关问题 更多 >
编程相关推荐