Пример #1
0
def run3_1(problem):
    ga = GA.GA_Faster_Both(problem)
    start = time.process_time()
    ga.run()
    end = time.process_time()
    run_time = end - start
    print("*********  GA_Both runtime:   *********")
    print(run_time)
    y1 = ga.memo_opt[0:-1]
    x1 = np.arange(1, len(y1) + 1)
    l1 = plt.plot(x1, y1, 'r--', label='GA_Both')
    plt.plot(x1, y1, 'r-')
    plt.title('The Convergence Curve of GA_Both')
    plt.xlabel('Iteration')
    plt.ylabel('Best Objective')
    plt.legend()
    plt.show()
    print("**************** GA_Both ****************")
    print([a for a in ga.opt_chromo])
    print("********* GA_Both Block lasts:   *********")
    for i in ga.memo_FV[tuple(ga.opt_chromo)].block_lasts:
        print(i)
    print("*********  GA_Both end times:   *********")
    for i in ga.memo_FV[tuple(ga.opt_chromo)].end_times:
        print(i)
    print("*********  GA_Both eti_penalty:   *********")
    print("overall penalty of GA_BASIC:",
          ga.memo_FV[tuple(ga.opt_chromo)].eti_penalty)
Пример #2
0
def run8(p):
    ga_basic = GA.GA_Faster_Both(p)
    start = time.process_time()
    ga_basic.run()
    end = time.process_time()
    run_time = end - start
    b_ratio = ga_basic.memo_FV[tuple(ga_basic.opt_chromo)].b_ratio
    f = open('GA with Both results.txt', 'a')
    f.write(
        str(p.n) + "\t" + str(p.b) + "\t" + str(p.rho) + "\t" + str(run_time) +
        "\t" + str(b_ratio) + "\n")
    f.close()
Пример #3
0
def run8(p):
    ga = GA.GA_Faster_Both(p)
    start = time.process_time()
    ga.run()
    end = time.process_time()
    run_time = end - start
    f = open('GA_bound_1&2_0717.txt', 'a')
    f.write(
        str(p.n) + "\t" + str(p.b) + "\t" + str(p.rho) + "\t" + str(run_time) +
        "\t" + str(ga.memo_opt[ga.max_iter]) + "\t" +
        str(ga.memo_opt[ga.max_iter - 5]) + "\t" +
        str(ga.memo_opt[ga.max_iter - 10]) + "\n")
    f.close()