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
when DNA_SIZE > 1, index out of boundary at
good_idx = idx[fitness.argsort()][-POP_SIZE:]
so, suggestion is :
def kill_bad(pop, kids):
# put pop and kids together
for key in ['DNA', 'mut_strength']:
pop[key] = np.vstack((pop[key], kids[key]))
fitness = get_fitness(F(pop['DNA'])) # calculate global fitness
w,h = pop['DNA'].shape
idx = np.arange(w*h)
good_idx = idx[fitness.argsort()][-POP_SIZE*DNA_SIZE:] # selected by fitness ranking (not value)
for key in ['DNA', 'mut_strength']:
pop[key] = pop[key].flatten()
pop[key] = pop[key][good_idx]
pop[key] = pop[key].reshape((POP_SIZE,DNA_SIZE))
return pop
The text was updated successfully, but these errors were encountered:
when DNA_SIZE > 1, index out of boundary at
good_idx = idx[fitness.argsort()][-POP_SIZE:]
so, suggestion is :
def kill_bad(pop, kids):
# put pop and kids together
for key in ['DNA', 'mut_strength']:
pop[key] = np.vstack((pop[key], kids[key]))
The text was updated successfully, but these errors were encountered: