Пример #1
0
g_list_sus = np.load(direction + 'sus_waarts_N' + repr(N_sus[0]) +
                     '_Nsim100_cs_g_list.npy')

g_list_mp1 = np.load(direction + 'mp_waarts_N' + repr(N_mp[0]) +
                     '_Nsim100_b5_cs_sss2_g_list.npy')
g_list_mp2 = np.load(direction + 'mp_waarts_N' + repr(N_mp[1]) +
                     '_Nsim100_b10_cs_sss2_g_list.npy')
g_list_mp3 = np.load(direction + 'mp_waarts_N' + repr(N_mp[2]) +
                     '_Nsim100_b20_cs_sss2_g_list.npy')

# ---------------------------------------------------------------------------
# POST-PROCESSING
# ---------------------------------------------------------------------------

print('Ncall,SUS =', uutil.get_mean_ncall_from_SUS(g_list_sus, N_sus[0], 0.1))
print('Ncall,MP1 =', uutil.get_mean_ncall_from_MP(g_list_mp1, N_mp[0], 5))
print('Ncall,MP2 =', uutil.get_mean_ncall_from_MP(g_list_mp2, N_mp[1], 10))
print('Ncall,MP3 =', uutil.get_mean_ncall_from_MP(g_list_mp3, N_mp[2], 20))

pf_mean_sus, pf_cov_sus = uutil.get_mean_and_cov_pf_from_SUS(
    g_list_sus, N_sus[0], 0.1)
pf_mean_mp1, pf_cov_mp1 = uutil.get_mean_and_cov_pf_from_MP(
    g_list_mp1, N_mp[0])
pf_mean_mp2, pf_cov_mp2 = uutil.get_mean_and_cov_pf_from_MP(
    g_list_mp2, N_mp[1])
pf_mean_mp3, pf_cov_mp3 = uutil.get_mean_and_cov_pf_from_MP(
    g_list_mp3, N_mp[2])

print('SUS: pf =', pf_mean_sus, '| cov =', pf_cov_sus)
print('MP1: pf =', pf_mean_mp1, '| cov =', pf_cov_mp1)
print('MP2: pf =', pf_mean_mp2, '| cov =', pf_cov_mp2)
Пример #2
0
    g_list_mp1, N_mp[0])
pf_mean_mp2, pf_cov_mp2 = uutil.get_mean_and_cov_pf_from_MP(
    g_list_mp2, N_mp[1])
pf_mean_mp3, pf_cov_mp3 = uutil.get_mean_and_cov_pf_from_MP(
    g_list_mp3, N_mp[2])
print('-----------------------------------------------------')
print('cov = 0.1 | SUS cov =', round(pf_cov_sus1, 3), '| MP cov =',
      round(pf_cov_mp1, 3))
print('cov = 0.2 | SUS cov =', round(pf_cov_sus2, 3), '| MP cov =',
      round(pf_cov_mp2, 3))
print('cov = 0.3 | SUS cov =', round(pf_cov_sus3, 3), '| MP cov =',
      round(pf_cov_mp3, 3))
print('-----------------------------------------------------')

# number of LSF calls
ncall_sus1 = uutil.get_mean_ncall_from_SUS(g_list_sus1, N_sus[0], p0)
ncall_sus2 = uutil.get_mean_ncall_from_SUS(g_list_sus2, N_sus[1], p0)
ncall_sus3 = uutil.get_mean_ncall_from_SUS(g_list_sus3, N_sus[2], p0)

ncall_mp1 = uutil.get_mean_ncall_from_MP(g_list_mp1, N_mp[0], Nb)
ncall_mp2 = uutil.get_mean_ncall_from_MP(g_list_mp2, N_mp[1], Nb)
ncall_mp3 = uutil.get_mean_ncall_from_MP(g_list_mp3, N_mp[2], Nb)

print('cov = 0.1 | SUS ncall =', round(ncall_sus1, 0), '| MP ncall =',
      round(ncall_mp1, 0))
print('cov = 0.2 | SUS ncall =', round(ncall_sus2, 0), '| MP ncall =',
      round(ncall_mp2, 0))
print('cov = 0.3 | SUS ncall =', round(ncall_sus3, 0), '| MP ncall =',
      round(ncall_mp3, 0))
print('-----------------------------------------------------')
print('Thank you for the music!')
    # ---------------------------------------------------------------------------
    # POST-PROCESSING
    # ---------------------------------------------------------------------------

    # initialization
    cov_at_pf_array = np.zeros(len(burn_in_list), float)
    pf_mean_array = np.zeros(len(burn_in_list), float)
    ncall_array = np.zeros(len(burn_in_list), float)
    cov_ref = np.zeros(len(burn_in_list), float)

    for i in range(0, len(burn_in_list)):
        pf_mean_array[i], cov_at_pf_array[
            i] = uutil.get_mean_and_cov_pf_from_MP(g_list_list[i],
                                                   nsamples_list[i])
        ncall_array[i] = uutil.get_mean_ncall_from_MP(g_list_list[i],
                                                      nsamples_list[i],
                                                      burn_in_list[i])

        cov_ref[i] = np.sqrt(pf_ref**(-1 / nsamples_list[i]) - 1)

    cov_ref_list.append(cov_ref)
    cov_mean_list.append(cov_at_pf_array)
    pf_mean_list.append(pf_mean_array)
    ncall_mean_list.append(ncall_array)

# ---------------------------------------------------------------------------
# PLOTS
# ---------------------------------------------------------------------------
# plot cov over b
plt.figure()
for i in range(0, len(ncall_number_list)):
Пример #4
0
g_list_sus = np.load(direction + 'sus_breitung_N5000_Nsim100_cs_g_list.npy')

g_list_mp1 = np.load(direction +
                     'mp_breitung_N478_Nsim100_b5_cs_sss2_g_list.npy')
g_list_mp2 = np.load(direction +
                     'mp_breitung_N241_Nsim100_b10_cs_sss2_g_list.npy')
g_list_mp3 = np.load(direction +
                     'mp_breitung_N121_Nsim100_b20_cs_sss2_g_list.npy')

# ---------------------------------------------------------------------------
# POST-PROCESSING
# ---------------------------------------------------------------------------

print('Ncall,SUS =', uutil.get_mean_ncall_from_SUS(g_list_sus, 5000, 0.1))
print('Ncall,MP1 =', uutil.get_mean_ncall_from_MP(g_list_mp1, 478, 5))
print('Ncall,MP2 =', uutil.get_mean_ncall_from_MP(g_list_mp2, 241, 10))
print('Ncall,MP3 =', uutil.get_mean_ncall_from_MP(g_list_mp3, 121, 20))

pf_mean_sus, pf_cov_sus = uutil.get_mean_and_cov_pf_from_SUS(
    g_list_sus, 5000, 0.1)
pf_mean_mp1, pf_cov_mp1 = uutil.get_mean_and_cov_pf_from_MP(g_list_mp1, 478)
pf_mean_mp2, pf_cov_mp2 = uutil.get_mean_and_cov_pf_from_MP(g_list_mp2, 241)
pf_mean_mp3, pf_cov_mp3 = uutil.get_mean_and_cov_pf_from_MP(g_list_mp3, 121)

print('SUS: pf =', pf_mean_sus, '| cov =', pf_cov_sus)
print('MP1: pf =', pf_mean_mp1, '| cov =', pf_cov_mp1)
print('MP2: pf =', pf_mean_mp2, '| cov =', pf_cov_mp2)
print('MP3: pf =', pf_mean_mp3, '| cov =', pf_cov_mp3)

b_line_mcs, pf_line_mcs = uutil.get_pf_line_and_b_line_from_MCS(g_list_mcs)
        np.load(direction + 'mp_' + example_name_list[i] + '_N' + repr(N) + '_Nsim100_b' + repr(Nb_list[i]) + '_cs_sss2_g_list.npy')

    pf_temp, cov_temp = \
        uutil.get_mean_and_cov_pf_from_MP(g_list_list_mp, N)

    pf_array = \
        uutil.get_pf_array_from_MP(g_list_list_mp, N)

    pf_rel_line_mp[i] = np.mean(pf_array) / pf_ref_list[i]
    pf_rel_lb_line_mp[i] = np.percentile(pf_array, 10) / pf_ref_list[i]
    pf_rel_ub_line_mp[i] = np.percentile(pf_array, 90) / pf_ref_list[i]

    cov_line_mp[i] = np.std(pf_array) / np.mean(pf_array)
    cov_ref_line[i] = np.sqrt(np.mean(pf_array)**(-1 / N) - 1)

    ncall_array_mp[i] = uutil.get_mean_ncall_from_MP(g_list_list_mp,
                                                     N_mp_list[i], Nb_list[i])

# analytical reference
ref_lines = np.ones(len(example_list))

# ---------------------------------------------------------------------------
# PLOTS
# ---------------------------------------------------------------------------

# ---------------------------------------------------------------------
plt.figure()
plt.plot(example_list, ref_lines, '-', color='C0')

plt.plot(example_list, pf_rel_line_sus, 's', color='C2', label='SuS')
plt.plot(example_list, pf_rel_lb_line_sus, '_', color='C2')
plt.plot(example_list, pf_rel_ub_line_sus, '_', color='C2')
direction = 'python/data/example' + repr(example) + '/nsamples_study_mp/'
nsamples_list_mp = [10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, \
                30, 40, 50, 60, 70, 80, 90, 100]
if example == 4:
    nsamples_list_mp = [100, 200, 300, 400, 500]

ncall_points_mp = np.zeros(len(nsamples_list_mp))
cov_points_mp = np.zeros(len(nsamples_list_mp))

for i in range(0, len(nsamples_list_mp)):
    N = nsamples_list_mp[i]
    g_list_list_mp = \
        np.load(direction + 'mp_' + example_name + '_N' + repr(N) + '_Nsim100_b5_cs_sss2_g_list.npy')

    ncall_points_mp[i] = \
        uutil.get_mean_ncall_from_MP(g_list_list_mp, N, Nb)

    pf_temp, cov_points_mp[i] = \
        uutil.get_mean_and_cov_pf_from_MP(g_list_list_mp, N)

# -- load mp data ----------------------------------------------------------
max_cov = max([max(cov_points_mp), max(cov_points_sus)])
delta_line = np.linspace(0.05, max_cov, 100)

ncall_line_mcs = monte_carlo(pf_ref, delta_line)
ncall_line_sus = subset(pf_ref, delta_line, 1.5)
ncall_line_mp = moving_particles(pf_ref, delta_line, Nb)
# ---------------------------------------------------------------------------
# PLOTS
# ---------------------------------------------------------------------------
Пример #7
0
g_list_sus = np.load(direction +
                     'sus_example_1_d10_N1000_Nsim100_cs_g_list.npy')

g_list_mp1 = np.load(direction +
                     'mp_example_1_d10_N104_Nsim100_b5_cs_sss2_g_list.npy')
g_list_mp2 = np.load(direction +
                     'mp_example_1_d10_N53_Nsim100_b10_cs_sss2_g_list.npy')
g_list_mp3 = np.load(direction +
                     'mp_example_1_d10_N27_Nsim100_b20_cs_sss2_g_list.npy')

# ---------------------------------------------------------------------------
# POST-PROCESSING
# ---------------------------------------------------------------------------

print('Ncall,SUS =', uutil.get_mean_ncall_from_SUS(g_list_sus, 1000, 0.1))
print('Ncall,MP1 =', uutil.get_mean_ncall_from_MP(g_list_mp1, 104, 5))
print('Ncall,MP2 =', uutil.get_mean_ncall_from_MP(g_list_mp2, 53, 10))
print('Ncall,MP3 =', uutil.get_mean_ncall_from_MP(g_list_mp3, 27, 20))

pf_mean_sus, pf_cov_sus = uutil.get_mean_and_cov_pf_from_SUS(
    g_list_sus, 1000, 0.1)
pf_mean_mp1, pf_cov_mp1 = uutil.get_mean_and_cov_pf_from_MP(g_list_mp1, 104)
pf_mean_mp2, pf_cov_mp2 = uutil.get_mean_and_cov_pf_from_MP(g_list_mp2, 52)
pf_mean_mp3, pf_cov_mp3 = uutil.get_mean_and_cov_pf_from_MP(g_list_mp3, 27)

print('SUS: pf =', pf_mean_sus, '| cov =', pf_cov_sus)
print('MP1: pf =', pf_mean_mp1, '| cov =', pf_cov_mp1)
print('MP2: pf =', pf_mean_mp2, '| cov =', pf_cov_mp2)
print('MP3: pf =', pf_mean_mp3, '| cov =', pf_cov_mp3)

b_line_analytical = np.linspace(0, 5, 100)