示例#1
0
    for i in range(replications):
        cipde1[i].solve()
        pp.saveExpObject(cipde1[i],
                         save_path + "cipde1_rep_" + str(i) + ".json")
        print(save_path + "cipde1_rep_" + str(i) + ".json" + " -> saved")

    ##########################
    #   testbed problem 2    #
    ##########################
    cipde2 = []
    for i in range(replications):
        initialPop = np.random.randn(8, 4)
        mpJadea = oaMempJadeadaptive.OptAlgoMemeticpJADEadaptive(
            initialPop, max_fe, min_err)
        cipde2.append(pde2.CiPde2(mpJadea, gakernel, nb1, nc1))

    for i in range(replications):
        cipde2[i].solve()
        pp.saveExpObject(cipde2[i],
                         save_path + "cipde2_rep_" + str(i) + ".json")
        print(save_path + "cipde2_rep_" + str(i) + ".json" + " -> saved")

    ##########################
    #   testbed problem 3    #
    ##########################
    cipde3 = []
    for i in range(replications):
        initialPop = np.random.randn(8, 4)
        mpJadea = oaMempJadeadaptive.OptAlgoMemeticpJADEadaptive(
            initialPop, max_fe, min_err)
示例#2
0
        cipde1.append(pde1.CiPde1(mpJADE, gskernel, nb1, nc1))

    for i in range(replications):
        cipde1[i].solve()
        pp.saveExpObject(cipde1[i],
                         "../../cipde1_mpjgsk_rep_" + str(i) + ".json")
        print("../../cipde1_mpjgsk_rep_" + str(i) + ".json" + " -> saved")

    ####################################
    #   testbed problem 2 for mpJADEa  #
    ####################################
    cipde2 = []
    for i in range(replications):
        initialPop = np.random.randn(60, 30)
        mpJADE = oapMJ.OptAlgoMemeticpJADE(initialPop, max_fe, min_err)
        cipde2.append(pde2.CiPde2(mpJADE, gskernel, nb1, nc1))

    for i in range(replications):
        cipde2[i].solve()
        pp.saveExpObject(cipde2[i],
                         "../../cipde2_mpjgsk_rep_" + str(i) + ".json")
        print("../../cipde2_mpjgsk_rep_" + str(i) + ".json" + " -> saved")

    ####################################
    #   testbed problem 3 for mpJADEa  #
    ####################################
    cipde3 = []
    for i in range(replications):
        initialPop = np.random.randn(60, 30)
        mpJADE = oapMJ.OptAlgoMemeticpJADE(initialPop, max_fe, min_err)
        cipde3.append(pde3.CiPde3(mpJADE, gskernel, nb1, nc1))
    for i in range(replications):
        obj = parallelResults[i].get()
        pp.saveExpObject(obj, "../../cipde1_mj_rep_" + str(i) + ".json")
        print("../../cipde1_mj_rep_" + str(i) + ".json" + " -> saved")

    pool.close()
    pool.join()

    ####################################
    #    testbed problem 2 for mJADE   #
    ####################################
    cipde2 = []
    for i in range(replications):
        initialPop = np.random.randn(40, 20)
        mJADE = oaMJ.OptAlgoMemeticJADE(initialPop, max_fe, min_err)
        cipde2.append(pde2.CiPde2(mJADE, gakernel, nb1, nc1))

    pool = Pool(processes=20)
    parallelResults = []
    for i in range(replications):
        parallelResults.append(pool.apply_async(solveObj, args=(cipde2, i)))

    for i in range(replications):
        obj = parallelResults[i].get()
        pp.saveExpObject(obj, "../../cipde2_mj_rep_" + str(i) + ".json")
        print("../../cipde2_mj_rep_" + str(i) + ".json" + " -> saved")

    pool.close()
    pool.join()

    ####################################
        for x1 in omega:
            nc.append((x0, x1))

    # boundary points
    nb = []
    nby = np.hstack(
        (np.zeros(10), np.arange(0.0, 1.0,
                                 0.1), np.ones(10), np.arange(1.0, 0.0, -0.1)))
    nbx = np.hstack(
        (np.arange(0.0, 1.0, 0.1), np.ones(10), np.arange(1.0, 0.0,
                                                          -0.1), np.zeros(10)))
    for i in range(40):
        nb.append((nbx[i], nby[i]))

    # creating object
    cipde2 = pde2.CiPde2(mJade, gkernel, nb, nc)
    cipde2.solve()

    saveExpObject(cipde2, "./save_test_large.json")

    load_dict = loadExpObject("./save_test_large.json")

    assert cipde2.kernel.kernel_type == load_dict["kernel_type"]
    assert cipde2.exec_time == load_dict["exec_time"]
    assert cipde2.mem_consumption == load_dict["mem_consumption"]
    assert cipde2.normL2() == load_dict["normL2"]
    assert np.allclose(cipde2.sol_kernel, load_dict["sol_kernel"])
    assert np.allclose(cipde2.pop_history, load_dict["pop_history"])
    assert np.allclose(cipde2.fit_history, load_dict["fit_history"])
    assert np.allclose(cipde2.f_history, load_dict["f_history"])
    assert np.allclose(cipde2.cr_history, load_dict["cr_history"])
    for i in range(replications):
        cipde1[i].solve()
        pp.saveExpObject(
            cipde1[i],
            "D:/Nicolai/MA_Data/experiment0/cipde1_rep_" + str(i) + ".json")
        print("D:/Nicolai/MA_Data/experiment0/cipde1_rep_" + str(i) + ".json" +
              " -> saved")

    ##########################
    #   testbed problem 2    #
    ##########################
    cipde2 = []
    for i in range(replications):
        initialPop = np.random.randn(40, 20)
        mJade = oaMemJade.OptAlgoMemeticJADE(initialPop, max_fe, min_err)
        cipde2.append(pde2.CiPde2(mJade, gkernel, nb1, nc1))

    for i in range(replications):
        cipde2[i].solve()
        pp.saveExpObject(
            cipde2[i],
            "D:/Nicolai/MA_Data/experiment0/cipde2_rep_" + str(i) + ".json")
        print("D:/Nicolai/MA_Data/experiment0/cipde2_rep_" + str(i) + ".json" +
              " -> saved")

    ##########################
    #   testbed problem 3    #
    ##########################
    cipde3 = []
    for i in range(replications):
        initialPop = np.random.randn(40, 20)