Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def crossover(selected_vectors_list, potential_offspring, q):
- # Создаем mutant_vectors, равный по размеру selected_vectors
- mutant_vectors = potential_offspring
- # Заменяем случайные q векторов mutant_vectors на соответствующие векторы из selected_vectors
- # Для оставшихся векторов
- for l in range(q, len(selected_vectors_list)):
- for j in range(len(selected_vectors_list[l])):
- # Выбираем случайное число
- p = np.random.rand()
- # Вычисляем CR_{l,g}
- CR_lg = 0.9 if p > 0.1 else p
- # Для каждой координаты j в векторе
- if np.random.rand() < 1.0 - CR_lg:
- mutant_vectors[l, j] = selected_vectors_list[l, j]
- return mutant_vectors
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement