Example #1
0
def rodarTesteAlfa(alfa):
    # print("Iniciando Thread alfa =",alfa)
    beneficios = []

    for i in range(4):

        print("Teste %s GRASP_VND com alfa = %s" % (i + 1, alfa))
        solucao = GRASP_VND(25, instancia, alfa)
        print("Terminou teste %s GRASP_VND alfa = %s" % (i + 1, alfa))

        beneficios.append(solucao.beneficio())

    print("Beneficio: %s Alfa: %s" % (np.mean(beneficios), alfa))
Example #2
0
def GRASP_VND_test():
    instancia = Instancia()

    melhorSolucao = (construcao(instancia, 1), -1, -1)

    # for alfa in [.0, .25, .50, .75, 1.0]:
    for alfa in [.50]:
        print("Teste GRASP_VND com alfa = %s" % (alfa))

        solucao = GRASP_VND(200, instancia, alfa)

        if beneficio(solucao) > beneficio(melhorSolucao[0]):
            melhorSolucao = (copy.deepcopy(solucao),alfa)

        print("\nBeneficio da solucao:",beneficio(solucao))
        print("Solucao valida" if solucao.valida() else "Solucao invalida")

        print('\n------------------------------------------------------------------------------------\n')

    melhorSolucao[0].printSolucao()
    print("Alfa: " + str(melhorSolucao[1]))
Example #3
0
    for i in range(4):

        print("Teste %s GRASP_VND com alfa = %s" % (i + 1, alfa))
        solucao = GRASP_VND(25, instancia, alfa)
        print("Terminou teste %s GRASP_VND alfa = %s" % (i + 1, alfa))

        beneficios.append(solucao.beneficio())

    print("Beneficio: %s Alfa: %s" % (np.mean(beneficios), alfa))


if __name__ == "__main__":
    instancia = Instancia()

    solucao = GRASP_VND(10, instancia, 0.25)
    solucao.printSolucao()

    # solucao = VNS_VND(10,instancia,construcao(instancia, .25))
    # solucao.printSolucao()

    # threads = []
    # # for alfa in [.0, .25, .50, .75]:
    # for alfa in [.1, .2, .3]:
    # # for alfa in [.3]:
    #     threads.append(th.Thread(target=rodarTesteAlfa, args=(alfa,)))
    # for t in threads:
    #     t.start()

    # for t in threads:
    #     t.join()