variable_name = 'Hm0' # name of uncertain variable dictionary_type = 'w' # dictionary where uncertain variable lives costlist = [] dellist = [] # set output txt file ts = time.time() st = datetime.datetime.fromtimestamp(ts).strftime('%Y-%m-%d %H:%M:%S') filename = "mc_xbeach_" + st + ".txt" logfile = open(filename, "w+") logfile.close() t0 = time.time() logfile = open(filename, "a+")#, 0) mlmc.write(logfile, str(no_parallel_processes)) # run monte carlo algorithm cost, del1 = mlmc.mlmc_test(no_parallel_processes, path_stem, _parallel_mc, multilevel, 'jonstable', dictionary_type, M, L, N0, Lmin, Lmax, logfile, build_output, variable_name, sample, interp_fn = interp_fn, angles_fn = angle_dict) costlist.append(cost) dellist.append(del1) # record cost and expectation from this one run logfile = open(filename, "a+")#, 0) print('total time: ' + str(t1 - t0)) mlmc.write(logfile, "total time: %f" % (t1-t0)) mlmc.write(logfile, "\n")
ts = time.time() st = datetime.datetime.fromtimestamp(ts).strftime('%Y-%m-%d %H:%M:%S') # set up a unique file to store outputs filename = "mlmc_xbeach_" + st + ".txt" logfile = open(filename, "w+") logfile.close() # run MLMC algorithm for i in range(no_runs): t0 = time.time() logfile = open(filename, "a+")#, 0) mlmc.write(logfile, str(no_parallel_processes)) if init_test == True: alpha_mod, beta, gamma, cost, var1, var2, del1 = mlmc.mlmc_test(no_parallel_processes, path_stem, _parallel_mc, multilevel, wavetype, dictionary_type, M, L, N0, Lmin, Lmax, logfile, build_output, variable_name, sample, interp_fn = interp_fn, normalisation_factor = init_vol) vardifflist.append(var1) varsing.append(var2) costlist.append(cost) dellist.append(del1) expectedlist.append(sum(del1)) if eps_test == True: # these values come from the results of init_test and thus must be replaced if a new init_test run is performed alpha_mod = 0.921053 beta = 1.970078 gamma = 2.400694 var1 = [5.9081e-07, 6.3646e-08, 1.9078e-08, 1.0362e-08, 1.5862e-09] del1 = [1.0026e-03, 1.2740e-04, 1.0285e-4, 9.3601e-05, 4.8057e-05] Ns, varlevel, Plist, P_seq_list, cost_per_epsilon = mlmc.eps_only(alpha_mod, beta, gamma, var1, del1, no_parallel_processes, path_stem, _parallel_mc, multilevel, wavetype, dictionary_type, M, L, 2, epsilon, Lmin, Lmax, logfile, build_output, variable_name, sample, interp_fn = interp_fn, angles_fn = 0, normalisation_factor = init_vol) Nslist.append(Ns) varlist.append(varlevel)
varlist = [] # set up unique file to store outputs ts = time.time() st = datetime.datetime.fromtimestamp(ts).strftime('%Y-%m-%d %H:%M:%S') filename = "mlmc_xbeach_" + st + ".txt" logfile = open(filename, "w+") logfile.close() for i in range(no_runs): t0 = time.time() logfile = open(filename, "a+")#, 0) mlmc.write(logfile, str(no_parallel_processes)) if init_test == True: alpha, beta, gamma, cost, var1, var2, del1 = mlmc.mlmc_test(no_parallel_processes, path_stem, _parallel_mc, multilevel, 'jons', 'w', M, L, N0, Lmin, Lmax, logfile, build_output, variable_name, sample, interp_fn = interp_orig_fn) vardifflist.append(var1) varsing.append(var2) costlist.append(cost) dellist.append(del1) expectedlist.append(sum(del1)) if eps_test == True: # these values come from the results of init_test and thus must be replaced if a new init_test run is performed alpha = 1.276595 beta = 1.770709 gamma = 1.432590 var1 = [0.003881187499999994, 0.000679, 0.00028910546875, 9.037011718750001e-05, 2.10205078125e-05, 7.315612792968751e-06] del1 = [0.63725, 0.014, 0.0114375, 0.00684375, 0.00421875, 0.0029609375] Ns, varlevel, Plist, P_seq_list, cost_per_epsilon = mlmc.eps_only(alpha, beta, gamma, var1, del1, no_parallel_processes, path_stem, _parallel_mc, multilevel, 'jons', 'w', M, L, 2, epsilon, Lmin, Lmax, logfile, build_output, variable_name, sample, interp_fn = interp_orig_fn, angles_fn = 0) Nslist.append(Ns) varlist.append(varlevel)