# plot moving avg def moving_average(interval, window_size): window = np.ones (int (window_size)) / float (window_size) return np.convolve (interval, window, 'same') no_of_slices = 3 no_of_users_list = (10, 10, 10) # region : Read simulation results c_algo = 'mcqi' parent_dir = 'baseline comparison data/variable_distance_02_req/'+c_algo subfolders = [ f.path for f in os.scandir(parent_dir) if f.is_dir() ] results_list = [] for tmp_dir in subfolders: results_list.append(read_sim_data(tmp_dir, no_of_slices=3, no_of_users_list=no_of_users_list)) # endregion # region : Plot rb distributions rb_dist = pd.DataFrame() for tmp_result in results_list: rb_dist = pd.concat([rb_dist,tmp_result.controller.apply(pd.Series.value_counts)],axis=1) rb_dist = rb_dist/25 * 100 # (/no of rb * 100) c = np.nan_to_num(rb_dist.to_numpy()) c1=c.reshape (3, 10, 1000) c2 = np.mean(c1,axis=2) pyplot.plot(c2[0],'r--',label="x vs y1") #CONTAINS YOUR 3RD ROW pyplot.plot(c2[1],'g--',label="x vs y2") #CONTAINS YOUR 4TH ROW pyplot.plot(c2[2],'b--',label="x vs y3") #CONTAINS YOUR 5TH ROW filename = parent_dir + "/rb_dist.png"
window = np.ones(int(window_size)) / float(window_size) return np.convolve(interval, window, 'same') no_of_slices = 3 no_of_users_list = (10, 10, 10) # region : Read simulation results parent_dir = "baseline comparison data/final_results/variable_requirement/req_inc" subfolders = [f.path for f in os.scandir(parent_dir) if f.is_dir()] results_list = [] for i in range(len(subfolders)): tmp_dir = subfolders[i] results_list.append( read_sim_data(tmp_dir, no_of_slices=3, no_of_users_list=no_of_users_list)) # endregion # region : reward,slice and score data # # get data # data_rewards = [] # data_slice_scores_rr = [] # data_slice_scores_mcqi = [] # data_slice_scores_pf = [] # for tmp_result in results_list: # data_rewards.append(tmp_result.reward_arr) # data_slice_scores_rr.append(tmp_result.slice_scores[0] ) # data_slice_scores_mcqi.append(tmp_result.slice_scores[1] ) # data_slice_scores_pf.append (tmp_result.slice_scores[2]) # # plot moving average: rewards
from matplotlib import pyplot import pandas as pd from matplotlib.patches import Polygon from readsimdata import read_sim_data no_of_slices = 3 no_of_users_per_slice = 10 # Read slice results for plotting comparison parent_dir = "baseline comparison data/New folder (3)" dir_MCQI = parent_dir + "/MCQI" dir_PF = parent_dir + "/PF" dir_RR = parent_dir + "/RR" dir_RL = parent_dir + "/RL" result_MCQI = read_sim_data(dir_MCQI, no_of_slices=3, no_of_users_per_slice=10) result_PF = read_sim_data(dir_PF, no_of_slices=3, no_of_users_per_slice=10) result_RR = read_sim_data(dir_RR, no_of_slices=3, no_of_users_per_slice=10) result_RL = read_sim_data(dir_RL, no_of_slices=3, no_of_users_per_slice=10) parent_dir = "baseline comparison data/New folder (3)" subfolders = [f.path for f in os.scandir(parent_dir) if f.is_dir()] results_list = [] for tmp_dir in subfolders: results_list.append( read_sim_data(tmp_dir, no_of_slices=3, no_of_users_per_slice=10)) result_MCQI = results_list[0] result_PF = results_list[1] result_RR = results_list[2] result_RL = results_list[3]