コード例 #1
0
def repair_align_compare(tree, m_tree, log):
    alignment_on_pt(tree, log)
    alignments = alignment_on_pt(m_tree, log)
    optimal_cost = sum([align['cost'] for align in alignments])
    print('optimal cost', optimal_cost)

    best_worst_cost = get_best_cost_on_pt(m_tree, log)

    alignments = alignment_on_pt(tree, log)

    parameters = {'ret_tuple_as_trans_desc': True}
    alignments, repair_alignments = repair.apply_with_alignments(
        tree, m_tree, log, alignments, Version.IAR_LINEAR, parameters, 1)
    print(repair_alignments)
    alignments2, repair_alignments2 = repair.apply_with_alignments(
        tree, m_tree, log, alignments, Version.IAR_TOP_DOWN, parameters, 1)
    print(repair_alignments2)

    ra_cost = sum([align['cost'] for align in repair_alignments])
    grade = 1 - (ra_cost - optimal_cost) / (best_worst_cost - optimal_cost) \
        if best_worst_cost != optimal_cost else 1
    print('repair1 cost', ra_cost)

    ra_cost2 = sum([align['cost'] for align in repair_alignments2])
    grade2 = 1 - (ra_cost2 - optimal_cost) / (best_worst_cost - optimal_cost) \
        if best_worst_cost != optimal_cost else 1
    print('repair2 cost', ra_cost2)

    if grade != grade2:
        print(grade, grade2)
        print(tree)
        print(m_tree)
        print_event_log(log)
        print("Oh my God")
        exit(-1)
コード例 #2
0
def avg_runtime_without_lock(trees, logs):
    start = time.time()
    for i, tree in enumerate(trees):
        alignment_on_pt(tree, logs[i])
    end = time.time()
    print((end - start) / len(trees))
    return (end - start) / len(trees)
コード例 #3
0
def align_info(tree, m_tree, log, version, option):
    print(tree)
    print(m_tree)
    print_event_log(log)

    start = time.time()
    alignment_on_pt(tree, log)
    alignments = alignment_on_pt(m_tree, log)
    end = time.time()
    print(alignments)
    optimal_time = end - start
    print('optimal time:', end - start)
    optimal_cost = sum([align['cost'] for align in alignments])
    print('optimal cost', optimal_cost)

    best_worst_cost = get_best_cost_on_pt(m_tree, log)
    print('best worst:', best_worst_cost)
    start = time.time()
    parameters = {'ret_tuple_as_trans_desc': True}
    alignments, repair_alignments = repair.apply(tree, m_tree, log, version,
                                                 parameters, option)
    end = time.time()
    print(alignments)
    print(repair_alignments)
    ra_time = end - start
    print('optimal time:', end - start)
    ra_cost = sum([align['cost'] for align in repair_alignments])
    grade = 1 - (ra_cost - optimal_cost) / (best_worst_cost - optimal_cost) \
        if best_worst_cost != optimal_cost else 1
    print('optimal cost', ra_cost)
    print('grade:', grade)
    # print('---------------------------------')
    # optimal_time, optimal_cost, best_worse_cost, ra_time, ra_cost, grade
    return optimal_time, optimal_cost, best_worst_cost, ra_time, ra_cost, grade
コード例 #4
0
def avg_runtime_without_lock(trees, m_trees, logs):
    start = time.time()
    for i in range(len(trees)):
        for j in range(len(m_trees[0])):
            print('round', i, j)
            alignment_on_pt(trees[i], logs[i])
            alignment_on_pt(m_trees[i][j], logs[i])
    end = time.time()
    print((end - start) / (len(trees) * len(m_trees[0])))
    return (end - start) / (len(trees) * len(m_trees[0]))
コード例 #5
0
def compute_align_grade1(num):
    trees = pd.read_excel(tree_file, sheet_name=SHEET_NAME)
    mp_trees = pd.read_excel(m_tree_file, sheet_name=SHEET_NAME)
    # logs = pd.read_excel(log_file, sheet_name=SHEET_NAME)

    align_result = list()
    align_result2 = list()
    align_result3 = list()
    # align_result4 = list()
    for i in trees:
        itree_list = trees[i]['tree'].tolist()
        log_list = pd.read_csv(PATH + 'log' + i + ".csv")['log'].tolist()
        # log_list = logs[i]['log'].tolist()
        tree_list = mp_trees[i]['tree'].tolist()
        mpt_list = mp_trees[i]['m_tree'].tolist()

        align_info = pd.DataFrame(columns=[
            "optimal time", "optimal cost", "repair align time",
            "repair align cost", "grade"
        ])
        align_info2 = pd.DataFrame(columns=[
            "optimal time", "optimal cost", "repair align time",
            "repair align cost", "grade"
        ])
        align_info3 = pd.DataFrame(columns=[
            "optimal time", "optimal cost", "repair align time",
            "repair align cost", "grade"
        ])
        # align_info4 = pd.DataFrame(columns=["optimal time", "optimal cost", "best worst cost",
        #                                     "repair align time", "repair align cost", "grade"])
        for k, tree in enumerate(tree_list):
            log = create_event_log(log_list[k])
            alignments = alignment_on_pt(tree, log)
            for j in range(num):
                m_tree = pt_utils.parse(mpt_list[k * num + j])
                info = apply_align_on_one_pt2(tree, m_tree, log, alignments)
                align_info.loc[len(align_info.index)] = info[0]
                align_info2.loc[len(align_info.index)] = info[1]
                align_info3.loc[len(align_info.index)] = info[2]
            # align_info4.loc[len(align_info.index)] = info[3]
        align_result.append(align_info)
        align_result2.append(align_info2)
        align_result3.append(align_info3)
        # align_result4.append(align_info4)

    with pd.ExcelWriter(PATH + 'ar.xlsx') as writer:
        for i, align in enumerate(align_result):
            align.to_excel(writer, sheet_name=SHEET_NAME[i], index=False)

    with pd.ExcelWriter(PATH + 'iar.xlsx') as writer:
        for i, align in enumerate(align_result2):
            align.to_excel(writer, sheet_name=SHEET_NAME[i], index=False)

    with pd.ExcelWriter(PATH + 'iar_ud.xlsx') as writer:
        for i, align in enumerate(align_result3):
            align.to_excel(writer, sheet_name=SHEET_NAME[i], index=False)
コード例 #6
0
ファイル: __init__.py プロジェクト: lvzheqi/pm4py-source
def compute_align_grade(log, tree, m_trees):
    alignments = alignment_on_pt(tree, log)
    align_info = pd.DataFrame(columns=[
        "optimal time", "optimal cost", "ar time", "ar cost", "ar grade",
        "iar align time", "iar cost", "iar grade"
    ])
    for m_tree in m_trees:
        align_info.loc[len(align_info.index)] = apply_repair_align_on_one_pt(
            tree, m_tree, log, alignments, 1)
    return align_info
コード例 #7
0
def align_info(tree, log, parameters):
    start = time.time()
    alignment_on_pt(tree, log)
    end = time.time()
    optimal_time = end - start

    start = time.time()
    if parameters['ret_tuple_as_trans_desc']:
        alignments_lock = alignment_on_lock_pt(tree, log)
    else:
        alignments_lock = alignment_on_loop_lock_pt(tree, log)
    end = time.time()
    align_list = list(map(str, alignments_lock))
    optimal_time_lock = end - start
    optimal_cost = sum([align['cost'] for align in alignments_lock])
    best_worst_cost = sum([
        get_best_cost_on_pt(tree) + len(trace) * STD_MODEL_LOG_MOVE_COST
        for trace in log
    ])

    return align_list + [
        optimal_time, optimal_time_lock, optimal_cost, best_worst_cost
    ]
コード例 #8
0
ファイル: __init__.py プロジェクト: lvzheqi/pm4py-source
def apply_repair_align_on_one_pt(tree, m_tree, log, alignments, option):
    print('-------------------------------------------------')
    best_worst_cost = get_best_cost_on_pt(m_tree, log)

    start = time.time()
    opt_alignments = alignment_on_pt(m_tree, log)
    end = time.time()
    optimal_time = end - start
    print('optimal time:', end - start)
    optimal_cost = sum([align['cost'] for align in opt_alignments])
    print('optimal cost', optimal_cost)

    start = time.time()
    parameters = {'ret_tuple_as_trans_desc': True}
    alignments1, repair_alignments1 = repair.apply_with_alignments(
        tree, m_tree, log, alignments, Version.AR_LINEAR, parameters, option)
    end = time.time()
    ra_time1 = end - start

    ra_cost1 = sum([align['cost'] for align in repair_alignments1])
    grade1 = 1 - (ra_cost1 - optimal_cost) / (best_worst_cost - optimal_cost) \
        if best_worst_cost != optimal_cost else 1

    start = time.time()
    parameters = {'ret_tuple_as_trans_desc': True}
    alignments2, repair_alignments2 = repair.apply_with_alignments(
        tree, m_tree, log, alignments, Version.IAR_TOP_DOWN, parameters,
        option)
    end = time.time()
    ra_time2 = end - start

    ra_cost2 = sum([align['cost'] for align in repair_alignments2])
    grade2 = 1 - (ra_cost2 - optimal_cost) / (best_worst_cost - optimal_cost) \
        if best_worst_cost != optimal_cost else 1
    print('repair time:', ra_time1, ra_time2)
    print('repair cost', ra_cost1, ra_cost2)
    print('grade', grade1, grade2)
    return [
        optimal_time, optimal_cost, ra_time1, ra_cost1, grade1, ra_time2,
        ra_cost2, grade2
    ]
コード例 #9
0
ファイル: __init__.py プロジェクト: lvzheqi/pm4py-source
def apply_align_on_one_pt2(tree, m_tree, log, alignments):
    best_worst_cost = get_best_cost_on_pt(m_tree, log)

    start = time.time()
    opt_alignments = alignment_on_pt(m_tree, log)
    end = time.time()
    optimal_time = end - start
    print('optimal time:', optimal_time)
    optimal_cost = sum([align['cost'] for align in opt_alignments])
    print('optimal cost', optimal_cost)

    parameters = {'ret_tuple_as_trans_desc': True}

    start = time.time()
    alignments1, repair_alignments1 = repair.apply_with_alignments(
        tree, m_tree, log, alignments, Version.AR_LINEAR, parameters, 1)
    end = time.time()
    ra_time1 = end - start

    start = time.time()
    alignments2, repair_alignments2 = repair.apply_with_alignments(
        tree, m_tree, log, alignments, Version.IAR_LINEAR, parameters, 1)
    end = time.time()
    ira_time2 = end - start

    start = time.time()
    alignments3, repair_alignments3 = repair.apply_with_alignments(
        tree, m_tree, log, alignments, Version.IAR_TOP_DOWN, parameters, 1)
    end = time.time()
    ira_time3 = end - start

    # start = time.time()
    # alignments4, repair_alignments4 = repair.apply_with_alignments(tree, m_tree, log, alignments, Version.IAR_TOP_DOWN,
    #                                                                parameters, 2)
    # end = time.time()
    # ira_time4 = end - start

    print('repair time:', ra_time1, ira_time2, ira_time3)
    # print('repair time:', ra_time1, ira_time2, ira_time3, ira_time4)

    ra_cost1 = sum([align['cost'] for align in repair_alignments1])
    grade1 = 1 - (ra_cost1 - optimal_cost) / (best_worst_cost - optimal_cost) \
        if best_worst_cost != optimal_cost else 1

    ira_cost2 = sum([align['cost'] for align in repair_alignments2])
    grade2 = 1 - (ira_cost2 - optimal_cost) / (best_worst_cost - optimal_cost) \
        if best_worst_cost != optimal_cost else 1

    ira_cost3 = sum([align['cost'] for align in repair_alignments3])
    grade3 = 1 - (ira_cost3 - optimal_cost) / (best_worst_cost - optimal_cost) \
        if best_worst_cost != optimal_cost else 1

    # ira_cost4 = sum([align['cost'] for align in repair_alignments4])
    # grade4 = 1 - (ira_cost4 - optimal_cost) / (best_worst_cost - optimal_cost) \
    #     if best_worst_cost != optimal_cost else 1

    print('repair cost', ra_cost1, ira_cost2, ira_cost3)
    print('grade', grade1, grade2, grade3)

    # print('repair cost', ra_cost1, ira_cost2, ira_cost3, ira_cost4)
    # print('grade', grade1, grade2, grade3, grade4)
    return [[
        optimal_time * 40, optimal_cost * 40, ra_time1 * 40, ra_cost1 * 40,
        grade1
    ],
            [
                optimal_time * 40, optimal_cost * 40, ira_time2 * 40,
                ira_cost2 * 40, grade2
            ],
            [
                optimal_time * 40, optimal_cost * 40, ira_time3 * 40,
                ira_cost3 * 40, grade3
            ]]