You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
def choose_fromlast(dis_adp,answer_source):
mid_adp=[]
mid_adp_each=0
for i in range(num_total):
mid_adp_each=dis_adp[i]+mid_adp_each
mid_adp.append(mid_adp_each)
# print(mid_adp)
#产生0-mid_adp[num_total-1]之间的随机数
#选择n-1<随机数<n的那个n的解,保留
copy_ans=[]
for p in range(copy_num):
rand=random.uniform(0,mid_adp[num_total-1])#产生随机数
# print(rand)
# print(p)
for j in range(num_total):
if (rand<mid_adp[j]):#查找位置
copy_ans.append(answer_source[j])
break
else:
continue
return copy_ans
The text was updated successfully, but these errors were encountered:
具体算法是这段:
这里应该是从n个原始解集中随机(不同概率)选择k个不重复的copy,但是这里的写法会导致parent会被重复选取。还请修改!
The text was updated successfully, but these errors were encountered: