# Test2: fix esp = 1, sin_const = 3, beta = 0.95, i_ub = 0.5, N_loop = 1. # change N_sample # N_sample_test = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] N_sample_test = [3, 4, 5, 6, 7, 8, 9, 10] for N_sample_temp in N_sample_test: result_x = [] result_u = [] N_sample = N_sample_temp for i in range(N_loop): sim = Simulation(model, Q, Qf, R, mu, x_init, beta=beta, N_sample=N_sample, i_th_state=i_th_state, i_state_ub=i_state_ub, epsilon=epsilon, sin_const=sin_const, N_sim=N_sim, mode="gene") result_x += [sim.x_sim] result_u += [sim.u_sim] print("#" + str(i) + " sim of " + str(N_sample) + " is done") N_sample_str = str(N_sample) write_path = "/Users/zhengangzhong/Dropbox/PhD/documents/paper_writing/CDC2021/result/" + file_name + "/" + N_sample_str + "_" + "x_tra" + ".txt" with open(write_path, 'w') as f: for listitem in result_x:
N_sim = 60 # Generate date, mu and sigma are given # sim = Simulation(model, Q, Qf, R, x_init, beta = beta, N_sample = N_sample, i_th_state = i_th_state, i_state_ub = i_state_ub, epsilon = epsilon, # sin_const = sin_const, N_sim=N_sim, mode = "gene", mu = mu, sigma = sigma, est = False) # print(sim.x_sim) # Generate date, mu and sigma are estimated from data sim = Simulation(model, Q, Qf, R, x_init, beta=beta, N_sample=N_sample, i_th_state=i_th_state, i_state_ub=i_state_ub, epsilon=epsilon, sin_const=sin_const, N_sim=N_sim, mode="gene", mu=mu, sigma=sigma, est=True) print(sim.x_sim) # Collect date, mu and sigma are given # data_set = gene_sample(N, d, N_sample, sin_const) # print(data_set) # N_sample_max = 10 # sim = Simulation(model, Q, Qf, R, x_init, beta = beta, N_sample = N_sample, i_th_state = i_th_state, i_state_ub = i_state_ub, epsilon = epsilon, # sin_const = sin_const, N_sim=N_sim, mode = "collect", data_set = data_set, N_sample_max = N_sample_max, mu = mu, sigma = sigma, est = False)
N_loop = 50 # 50 N_sample_max = 10 data_set_init = gene_sample(N, d, N_sample, sin_const) # Test3: fix N_sample = 1, sin_const = 3, beta = 0.95, i_ub = 0.4, N_loop = 10, eps = 1 # sample 100 trajectories with collected data result_x = [] result_u = [] for i in range(N_loop): data_set = data_set_init sim = Simulation(model, Q, Qf, R, mu, x_init, beta=beta, N_sample=N_sample, i_th_state=i_th_state, i_state_ub=i_state_ub, epsilon=epsilon, sin_const=sin_const, N_sim=N_sim, mode="collect", data_set=data_set, N_sample_max=N_sample_max) result_x += [sim.x_sim] result_u += [sim.u_sim] print("#" +str(i) + " sim " + "is done") write_path = "/Users/zhengangzhong/Dropbox/PhD/documents/paper_writing/CDC2021/result/" + file_name + "_" + "x_tra" + "_N_sample=" + str(N_sample) + ".txt" with open(write_path, 'w') as f: for listitem in result_x: f.write('%s\n' % listitem) f.close() write_path = "/Users/zhengangzhong/Dropbox/PhD/documents/paper_writing/CDC2021/result/" + file_name + "_" + "u_tra" + "_N_sample=" + str(N_sample) + ".txt" with open(write_path, 'w') as f: for listitem in result_u: f.write('%s\n' % listitem) f.close()