def main_generation():
    ut.init_log()
    log.info("Generating datasets for SMP and SMTI")
    # generate_smti_set(sizes_smti, samples_per_size_smti)
    # generate_smp_set(sizes_smp, samples_per_size_smp)
    log.info("DONE! Plotting the distributions of sizes and preferencelists")
    plot_equidistribution_smti(sizes_smti, samples_per_size_smti)
示例#2
0
def main_accuracy(max_qubo_size=8):
    """
    Measurements regarding the accuracy for MAX-SMTI:
    Qbsolv against APX-Algorithms.
    Next compare the energy of the found QUBO solution to the energy found by LP
    :param max_qubo_size:
    :return:
    """
    ut.init_log()
    # log.info("Starting Accurcay Measurement for SMTI")
    # log.info("Evaluating against other algorithms..")
    # df_acc = pd.DataFrame()
    # for size in sizes_smti:
    #     for index_f in range(samples_per_size_smti):
    #         log.info(f"At: {size}, {index_f}")
    #         out = compute_accuracy_measurement(size, index_f, use_qa=(size < max_qubo_size))
    #         df_acc = df_acc.append(out, ignore_index=True)
    #
    # store_computation_result(df_acc, "accuracy_results")
    # log.info("DONE!")
    # log.info("Checking Energy")

    df_acc = pd.DataFrame()
    for size in sizes_smti:
        for index_f in range(samples_per_size_smti):
            log.info(f"At: {size}, {index_f}")
            out = compute_qubo_en(size, index_f, use_qa=(size < max_qubo_size))
            if out is not None:
                df_acc = df_acc.append(out, ignore_index=True)
    log.info("Done!")
    store_computation_result(df_acc, "qbsolv_en_results")
示例#3
0
def smp_acc_runtime_main():
    ut.init_log()
    df_smp = pd.DataFrame()
    for size in range(3, smp_solve_max):
        for index_f in range(samples_per_size_smp):
            log.info(f"At: {size}, {index_f}")
            out = compare_runtime(size, index_f)
            df_smp = df_smp.append(out, ignore_index=True)
            store_computation_result(df_smp, "smp_bt_time_qa_qbsolv")
    store_computation_result(df_smp, "smp_bt_time_qa_qbsolv")
示例#4
0
def main_smp_measurements(generate_solutions=True):
    """
    Main Method to measure the QUBO Formulation against the SMP results:
    #1
    :param generate_solutions:
    :return:
    """
    ut.init_log()
    log.info("Sarting SMP Evaluation")
    if generate_solutions:
        generate_and_save_all_solutions()
    log.info("Starting SMP Evaluation")

    ###########################################################
    # compare the count of found matches
    # by qbsolv vs the quantum annealer
    ###########################################################
    df_smp = pd.DataFrame()
    for size in sizes_smp:
        if size >= smp_solve_max:
            continue
        for index_f in range(samples_per_size_smp):
            log.info(f"At: {size}, {index_f}")
            tmp = compare_solution_count_qbsolv_smp(size, index_f)
            df_smp = df_smp.append(tmp, ignore_index=True)
    store_computation_result(df_smp, "smp_qbsolv_count_result")
    log.info("DONE")

    ###########################################################
    # check how many stable pairs have found by qbsolv in the range
    # of the QA
    ###########################################################
    df_smp = pd.DataFrame()
    for size in sizes_smp_qa:
        for index_f in range(samples_per_size_smp):
            log.info(f"At: {size}, {index_f}")
            out = compute_smp_results(size, index_f)
            df_smp = df_smp.append(out, ignore_index=True)
    store_computation_result(df_smp, "smp_result")
    log.info("DONE")

    ###########################################################
    # compare the counts of the Qbsolv on a large scale by (previously)
    # finding all stable matchings by backtracking
    ###########################################################
    df_smp = pd.DataFrame()
    for size in sizes_smp:
        for index_f in range(samples_per_size_smp):
            log.info(f"At: {size}, {index_f}")
            out = compute_smp_results_qbsolv(size, index_f)
            df_smp = df_smp.append(out, ignore_index=True)
    store_computation_result(df_smp, "smp_result_qbsolvpure")
    log.info("DONE ALL")
示例#5
0
def main_time_measure():
    """
    Simple Measurement of the Runtime of Qbsolv vs. the APX-Algorithms

    Next_ measure QUBO vs. LP-Preprocess

    At last: QUBO vs. Backtracking on #P-SMP
    :return:
    """
    ut.init_log()
    log.info(f"Starting Time Measurement")
    # df_time = pd.DataFrame()
    # for size in sizes_smti:
    #     for index_f in range(samples_per_size_smti):
    #         log.info(f"At: {size}, {index_f}")
    #         out = measure_time_instance(size, index_f, times_repeat=10)
    #         df_time = df_time.append(out, ignore_index=True)
    # log.info("Done!")
    # store_computation_result(df_time, "time_result")

    # df_time = pd.DataFrame()
    #     # log.info(f"staring LP vs. QUBO Preprocessing")
    #     # for size in sizes_smti:
    #     #     for index_f in range(samples_per_size_smti):
    #     #         log.info(f"At: {size}, {index_f}")
    #     #         out = measure_lp_qubo_preprocessing(size, index_f, times_repeat=10)
    #     #         df_time = df_time.append(out, ignore_index=True)
    #     # log.info("Done!")
    df_time = pd.DataFrame()
    log.info(f"Backtracking vs. QUBO")
    for size in [i for i in range(3, 18)]:
        for index_f in range(samples_per_size_smp):
            log.info(f"At: {size}, {index_f}")
            out = measure_qubo_vs_backtracking(size, index_f)
            df_time = df_time.append(out, ignore_index=True)
    log.info("Done!")
    store_computation_result(df_time, "qubo_vs_backtrack_smp")