Exemplo n.º 1
0
            #total은 룰렛 선택을 적용하기 위한 전체 범주.
        total += temp
        #print("result = %d" %total)
        #tuple로 구성
        fitness.append((temp, i))
    fitness.sort(reverse=True)
    #print(total)
    return total, fitness


if __name__ == "__main__":
    #chromos = Gene List

    chromos = []
    List, Count, TOTAL = ReadData.LoadSchedule()
    #랜덤한 유전자 생성
    while (True):
        temp = GA(List, Count)
        for j in range(0, len(EstimatePower)):
            #조건을 만족하지 못할 경우, 유전자 재생성
            if (TOTAL - temp.GenerationCapa[j]) < EstimatePower[j]:
                temp = None
                break
        if temp == None:
            continue
        else:
            #print(i, temp.Gene)
            chromos.append(temp)
            if len(chromos) == GENS:
                break