# Analysis the data generated from on policy simulations of QL, QLP and GQL.

from BD.sim.sims import sims_analysis, merge_sim_files, extract_run_rew
from BD.util.paths import Paths


def sims_analysis_BD():
    input_folder = Paths.rest_path + 'archive/beh/qlp-ml-opt/qlp-ml/'
    sims_analysis(input_folder,
                  Paths.local_path + 'BD/to_graph_data/qlp_ml_onpolicy__stats.csv',
                  lambda conf: True
                  )

    input_folder = Paths.rest_path + 'archive/beh/ql-ml-opt/ql-ml/'
    sims_analysis(input_folder,
                  Paths.local_path + 'BD/to_graph_data/ql_ml_onpolicy_stats.csv',
                  lambda conf: True
                  )


def sims_analysis_GQL_BD():
    input_folder = Paths.rest_path + 'archive/beh/gql-ml-opt/gql-ml/'

    sims_analysis(input_folder,
                  Paths.local_path + 'BD/to_graph_data/gql_ml_onpolicy_stats.csv',
                  lambda conf: True
                  )

    input_folder = Paths.rest_path + 'archive/beh/gql10d-ml-opt/gql10d-ml/'

    sims_analysis(input_folder,
                  Paths.local_path + 'BD/to_graph_data/gql10d_ml_onpolicy_stats.csv',
                  lambda conf: True
                  )


if __name__ == '__main__':
    sims_analysis_BD()
    sims_analysis_GQL_BD()

    data = merge_sim_files(lambda x: True, Paths.rest_path + 'archive/beh/gql10d-ml-opt/gql10d-ml/')
    all_trials = extract_run_rew(data)

    output_file = Paths.local_path + 'BD/to_graph_data/gql10d_all_data_ml.csv'
    all_trials.to_csv(output_file, header=True)

    data = merge_sim_files(lambda x: True, Paths.rest_path + 'archive/beh/gql-ml-opt/gql-ml/')
    all_trials = extract_run_rew(data)

    output_file = Paths.local_path + 'BD/to_graph_data/gql_all_data_ml.csv'
    all_trials.to_csv(output_file, header=True)

[((9, 4, 12, 19), 'BD.sim.sims.sims_analysis', 'sims_analysis', ({(9, 18, 9, 30): 'input_folder', (10, 18, 10, 82): "(Paths.local_path + 'BD/to_graph_data/qlp_ml_onpolicy__stats.csv')", (11, 18, 11, 35): '(lambda conf: True)'}, {}), "(input_folder, Paths.local_path +\n    'BD/to_graph_data/qlp_ml_onpolicy__stats.csv', lambda conf: True)", False, 'from BD.sim.sims import sims_analysis, merge_sim_files, extract_run_rew\n'), ((15, 4, 18, 19), 'BD.sim.sims.sims_analysis', 'sims_analysis', ({(15, 18, 15, 30): 'input_folder', (16, 18, 16, 80): "(Paths.local_path + 'BD/to_graph_data/ql_ml_onpolicy_stats.csv')", (17, 18, 17, 35): '(lambda conf: True)'}, {}), "(input_folder, Paths.local_path +\n    'BD/to_graph_data/ql_ml_onpolicy_stats.csv', lambda conf: True)", False, 'from BD.sim.sims import sims_analysis, merge_sim_files, extract_run_rew\n'), ((24, 4, 27, 19), 'BD.sim.sims.sims_analysis', 'sims_analysis', ({(24, 18, 24, 30): 'input_folder', (25, 18, 25, 81): "(Paths.local_path + 'BD/to_graph_data/gql_ml_onpolicy_stats.csv')", (26, 18, 26, 35): '(lambda conf: True)'}, {}), "(input_folder, Paths.local_path +\n    'BD/to_graph_data/gql_ml_onpolicy_stats.csv', lambda conf: True)", False, 'from BD.sim.sims import sims_analysis, merge_sim_files, extract_run_rew\n'), ((31, 4, 34, 19), 'BD.sim.sims.sims_analysis', 'sims_analysis', ({(31, 18, 31, 30): 'input_folder', (32, 18, 32, 84): "(Paths.local_path + 'BD/to_graph_data/gql10d_ml_onpolicy_stats.csv')", (33, 18, 33, 35): '(lambda conf: True)'}, {}), "(input_folder, Paths.local_path +\n    'BD/to_graph_data/gql10d_ml_onpolicy_stats.csv', lambda conf: True)", False, 'from BD.sim.sims import sims_analysis, merge_sim_files, extract_run_rew\n'), ((41, 11, 41, 100), 'BD.sim.sims.merge_sim_files', 'merge_sim_files', ({(41, 27, 41, 41): 'lambda x: True', (41, 43, 41, 99): "Paths.rest_path + 'archive/beh/gql10d-ml-opt/gql10d-ml/'"}, {}), "(lambda x: True, Paths.rest_path +\n    'archive/beh/gql10d-ml-opt/gql10d-ml/')", False, 'from BD.sim.sims import sims_analysis, merge_sim_files, extract_run_rew\n'), ((42, 17, 42, 38), 'BD.sim.sims.extract_run_rew', 'extract_run_rew', ({(42, 33, 42, 37): 'data'}, {}), '(data)', False, 'from BD.sim.sims import sims_analysis, merge_sim_files, extract_run_rew\n'), ((47, 11, 47, 94), 'BD.sim.sims.merge_sim_files', 'merge_sim_files', ({(47, 27, 47, 41): 'lambda x: True', (47, 43, 47, 93): "Paths.rest_path + 'archive/beh/gql-ml-opt/gql-ml/'"}, {}), "(lambda x: True, Paths.rest_path +\n    'archive/beh/gql-ml-opt/gql-ml/')", False, 'from BD.sim.sims import sims_analysis, merge_sim_files, extract_run_rew\n'), ((48, 17, 48, 38), 'BD.sim.sims.extract_run_rew', 'extract_run_rew', ({(48, 33, 48, 37): 'data'}, {}), '(data)', False, 'from BD.sim.sims import sims_analysis, merge_sim_files, extract_run_rew\n')]