Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # seleção por torneio gera aleatoriamente dois
- # pais e retorna o melhor deles
- def tournament_selection(acuracias, cromossomos):
- melhor = []
- aux = []
- for i in range(0,2):
- rand = randint(0,20)
- if acuracias[rand] == 0:
- rand = randint(0,20)
- elif acuracias[rand] != 0:
- aux.append(rand)
- if acuracias[aux[0]] > acuracias[aux[1]]:
- melhor.append(cromossomos[aux[0]])
- cromossomos[aux[0]] = 0
- elif acuracias[aux[1]] > acuracias[aux[0]]:
- melhor.append(cromossomos[aux[1]])
- cromossomos[aux[0]] = 0
- return melhor, cromossomos
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement