<jupyter_start><jupyter_text>GIRG<jupyter_code>betas = np.concatenate(
    (np.linspace(args["--gamma"], 1.3*args["--gamma"], 12),
     np.linspace(1.3*args["--gamma"], 2.0*args["--gamma"], 15)[1:])
)
betas
args["procnum"] = 30
args["simnum"] = 10
random_seed_num = 5

inf_city = 30
%time

log_folder = "girgs_final"
if(not os.path.exists(log_folder)):
    os.makedirs(log_folder)

for seed in range(0, random_seed_num):
    print(f"\rRandom seed: {seed}/{random_seed_num}")
    for config in [True, False]:
        for GIRG_args in [GIRG_args1 ,GIRG_args2, GIRG_args3, GIRG_args4]:
            GIRG_args["config_model"]=config
            GIRG_args["random_seed"]=seed
            graph = init_graph(GIRG_args)
            hun = C_Country(graph)

            pm = get_moving(graph, procent = 0.001)
            args["--p_moving"]=pm

            centrum = get_centrum(graph, "k-core", inf_city)
            agg1 = hun.run_for_betas_simple_raw(args, centrum, betas, inf_city, "uniform_random")
            periphery = [n for n in graph.nodes() if n not in centrum] 
            agg2 = hun.run_for_betas_simple_raw(args, periphery, betas, inf_city, "uniform_random")

            graph_name = "Config" if config else "GIRG"
            tau = GIRG_args["tau"]
            alpha = GIRG_args["alpha"]
            filename = "{}/{}_tau:{}_alpha:{}_seed:{}.csv".format(
                log_folder, graph_name, tau, alpha,seed)
            
            save_to_file(betas, agg1, agg2, seed, filename)
def save_file(df, file):
    df_cen = df[df["cen"]==True].drop(['beta', 'cen'], axis=1).mean(1)
    df_per = df[df["cen"]==False].drop(['beta', 'cen'], axis=1).mean(1)
    betas = df[df["cen"]==True]["beta"]

    df_agg = pd.DataFrame()
    df_agg["betas"]=df[df["cen"]==True]["beta"]
    df_agg["mean1"]=df_cen
    df_agg["std1"]=df[df["cen"]==True].drop(['beta', 'cen'], axis=1).std(1)
    df_agg["mean2"]=np.array(df_per)
    df_agg["std2"]=np.array(df[df["cen"]==False].drop(['beta', 'cen'], axis=1).std(1))
    df_agg["ratio"]=df_agg["mean1"]/df_agg["mean2"]
    A = 1.645/np.sqrt(df.drop(['beta', 'cen'], axis=1).shape[1])
    df_agg["conf1_lower"] = df_agg["mean1"]-df_agg["std1"]*A
    df_agg["conf1_upper"] = df_agg["mean1"]+df_agg["std1"]*A
    df_agg["conf2_lower"] = df_agg["mean2"]-df_agg["std2"]*A
    df_agg["conf2_upper"] = df_agg["mean2"]+df_agg["std2"]*A
    df_agg["lower"] = df_agg["conf1_lower"]/df_agg["conf2_upper"]
    df_agg["upper"] = df_agg["conf1_upper"]/df_agg["conf2_lower"]

    df_agg.to_csv("girgs_final/aggregation/"+file+"_agg.csv")
    
    return df_agg

os.mkdir("girgs_final/aggregation")
for files in [["GIRG_tau:2.5_alpha:2.3","GIRG_tau:3_alpha:1.3",
                 "GIRG_tau:3.5_alpha:1.3","GIRG_tau:3.5_alpha:2.3"],
              ["Config_tau:2.5_alpha:2.3","Config_tau:3_alpha:1.3",
                  "Config_tau:3.5_alpha:1.3","Config_tau:3.5_alpha:2.3"]]:
    plt.figure(figsize=(10,8))
    for file in files:
        df = pd.read_csv("girgs_final/{}_seed:{}.csv".format(file, 0))
        for seed in range(0,random_seed_num):
            df_temp = pd.read_csv("girgs_final/{}_seed:{}.csv".format(file, seed))
            df = pd.merge(df,df_temp, how='inner', left_on=['beta','cen'], right_on=['beta','cen'])

        df["mean"] = df.drop(['beta', 'cen'], axis=1).mean(1)
        df["std"] = df.drop(['beta', 'cen'], axis=1).std(1)

        df.to_csv("girgs_final/aggregation/"+file+"_all.csv")
        df_agg = save_file(df, file)

        plt.plot(betas/args["--gamma"], df_agg["ratio"].values, label=file)
        plt.fill_between(betas/args["--gamma"], df_agg["lower"].values, df_agg["upper"].values,
                         alpha=0.2)
    plt.xlabel("R_0")
    plt.legend()
    plt.show()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.20228298380674276, 'fraction_numerical': 0.02893549243429785, 'mean_word_length': 3.4381625441696113, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '51437', 'license': 'MIT', 'n_tokens_mistral': 1534, 'n_tokens_neox': 1494, 'n_words': 196, 'path': 'paper/results_GIRG-Config.ipynb', 'repo_name': 'dczifra/epidemic_seeding', 'size': '3767'}