'list' объект не вызывается ошибка в Python - PullRequest
0 голосов
/ 31 января 2020

Я работаю над проблемой общего алгоритма c. Я выбрал несколько компетентных лиц на основе их пригодности. Теперь я пытаюсь развести среди людей, чтобы произвести следующее поколение.

def crossover(parent1,parent2):
    parent1=np.random.randint(0,100,20)
    parent2=np.random.randint(0,100,20)
    child1=[]
    child2=[]
    crossover_point=int(np.random.random()*len(parent1))
    for i in range(crossover_point+1):
        child1.append(parent1[i])
        child2.append(parent2[i])
        temp=i
    for i in range(temp+1,len(parent1)):
        child1.append(parent2[i])
        child2.append(parent1[i])
    return child1,child2
def breed_population(selection_result):
    k=len(selection_result)//2
    children=[]
    for i in range(k):
        child=crossover(selection_result[i],selection_result(k-i-1))
        children.append(child)

    return children
selection_result=[10, 8, 19, 10, 5, 1, 11, 14, 17, 8, 16, 16, 11, 8, 17, 13, 11, 10, 8, 11]
p=breed_population(selection_result)

Теперь я получаю следующую ошибку.

TypeError                                 Traceback (most recent call last)
<ipython-input-2-d2718835d6df> in <module>
     24     return children
     25 selection_result=[10, 8, 19, 10, 5, 1, 11, 14, 17, 8, 16, 16, 11, 8, 17, 13, 11, 10, 8, 11]
---> 26 p=breed_population(selection_result)

<ipython-input-2-d2718835d6df> in breed_population(selection_result)
     19     children=[]
     20     for i in range(k):
---> 21         child=crossover(selection_result[i],selection_result(k-i-1))
     22         children.append(child)
     23 

TypeError: 'list' object is not callable
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...