def plot_error_var(): input = "../../src/results/" export = "../../export/testfile" configs = ["ErrorDependentExponent", "RegularExponent", "InverseExponent"] markers = {"ErrorDependentExponent": 's', "RegularExponent": '^', "InverseExponent": 'o'} colors = {"ErrorDependentExponent": 'r', "RegularExponent": 'b', "InverseExponent": 'g'} metric = "errVar" plt.figure() ax = plt.gca() for i, config in enumerate(configs): # see all the result files files = [f for f in listdir(input) if (isfile(join(input, f)) and (config in f) and ('.sca' in f))] print(files) files.sort(key=lambda x: int(re.findall('-(.+?).sca', x)[0])) print(files) # --- number of subsystems --- # n_min = 10 n_max = 42 step = 4 n_s = [n_min + step * x for x in range(1, int((n_max - n_min) / step + 1))] df = pd.DataFrame() for f in files: df = df.append(parse_sca(filename=input+f)) print(df) means = df.groupby('num_subsystems').mean() print(means) cis = df.groupby('num_subsystems').apply(lambda x: getCI(x, confidence=0.95)) print(cis) # means.plot(kind="line", yerr=cis.value, ax=ax, label=config, color=colors[config], marker=markers[config]) means.plot(kind="line", ax=ax, label=config, color=colors[config], marker=markers[config]) plt.grid(True) legend = plt.legend(loc=0) for i, config in enumerate(configs): legend.get_texts()[i].set_text(config) # plt.yscale('log') plt.show() return
for i_s in n_s: # every number of subsystems thr = [] acc = [] col = [] for i_rep in range(n_rep): # every replication thr.append(float(lines[i])) acc.append(float(lines1[i])) col.append(float(lines2[i])) i += 1 throughput_box.append(list(thr)) throughput.append(np.mean(thr)) throughput_ci.append(ci.getCI(thr)) access.append(np.mean(acc)) access_box.append(list(acc)) access_ci.append(ci.getCI(acc)) collisions.append(np.mean(col)) collisions_box.append(list(col)) collisions_ci.append(ci.getCI(col)) # --- cleanup --- # f.close() f1.close() f2.close() # remove_simdata()
for lmb_v in lmb: # every lambda value var = [] for i_rep in range(n_rep): # every replication var_temp = [] for s in range(i_s): # every subsystem in the replication var_temp.append(float(lines[i])) i += 1 var.append(np.mean(var_temp)) results[n_s.index(i_s)].append(np.mean(var)) results_box[n_s.index(i_s)].append(list(var)) results_ci[n_s.index(i_s)].append(ci.getCI(var)) f.close() # remove_simdata() # --- plotting --- # fig, ax = plt.subplots(figsize=(8.5, 5)) p = [] market_style = ['^', 'o', 's', 'x'] for i_s in n_s: if i_s == 20: p.append(ax.plot(lmb[13:], results[n_s.index(i_s)][13:], market_style[n_s.index(i_s)]+'-'))
var_nab_temp = [] for s in range(i_s): # every subsystem in the replication var_temp.append(float(lines[i])) var_na_temp.append(float(lines1[i])) var_nab_temp.append(float(lines2[i])) i += 1 var.append(np.mean(var_temp)) var_na.append(np.mean(var_na_temp)) var_nab.append(np.mean(var_nab_temp)) # if i_s==60: # p1 = ax.plot([x for x in range(20)], var, 'bs-') variance_box.append(list(var)) variance_mean.append(np.mean(var)) variance_ci.append(ci.getCI(var)) variance_na_box.append(list(var_na)) variance_na_mean.append(np.mean(var_na)) variance_na_ci.append(ci.getCI(var_na)) variance_nab_box.append(list(var_nab)) variance_nab_mean.append(np.mean(var_nab)) variance_nab_ci.append(ci.getCI(var_nab)) # --- cleanup --- # f.close() f1.close() f2.close() remove_simdata()