Пример #1
0
def compute_alignment(sheet_index, file):
    """
    Create specified number of event logs of each tree, not including Empty Trace.

    The event log in the same column belong to the same process tree.

    Records Format (Column)
    ---------------
    Alignments, time without lock, time with lock, optimal cost, best_worst_cost
    """
    trees = object_read.read_trees_from_file(PT_FILE_NAME, sheet_index)
    logs = object_read.read_logs_from_file(LOG_FILE_NAME)
    base = excel_utils.create_workbook()
    align_e_table = None
    for row, tree in enumerate(trees):
        print("align:", row)
        log = logs[row] if sheet_index == 0 else logs[row // MPT_NUM]
        if sheet_index == 0:
            if row % PT_NUM[0] == 0:
                align_e_table = ExcelTable(
                    base.add_sheet(ALIGN_SHEET_NAME[row // PT_NUM[0]]))
        else:
            if row % (PT_NUM[0] * MPT_NUM) == 0:
                align_e_table = ExcelTable(
                    base.add_sheet(ALIGN_SHEET_NAME[row //
                                                    (PT_NUM[0] * MPT_NUM)]))
        parameters = None
        excel_utils.write_column_to_table(align_e_table.table,
                                          align_e_table.column,
                                          align_info(tree, log, parameters))
    excel_utils.save(base, file)
Пример #2
0
def compute_repair_result(mpt_index, align_mpt, expand_repair_file,
                          result_file):
    """
    Record repair alignment

    Records Format (repair)
    ---------------
    Alignments, time , cost

    Records Format (result)
    ---------------
    Alignment time without lock, time with lock, optimal cost, best_worst_cost, repair_alignments,
    time, cost, expand_repair_alignments, time, cost
    """
    trees = object_read.read_trees_from_file(PT_FILE_NAME, 0)
    m_trees = object_read.read_trees_from_file(PT_FILE_NAME, mpt_index)
    logs = object_read.read_logs_from_file(LOG_FILE_NAME)
    alignments_t1 = object_read.read_align_from_file(ALIGN_FILE_NAME)
    alignments_t2 = object_read.read_align_from_file(align_mpt)

    base = excel_utils.create_workbook()
    expand_repair_repair = excel_utils.create_workbook()
    result_e_table, expand_e_table = None, None
    parameters = {'ret_tuple_as_trans_desc': True}
    for row, m_tree in enumerate(m_trees):
        if row % (PT_NUM[0] * MPT_NUM) == 0:
            result_e_table = ExcelTable(
                base.add_sheet(REPAIR_SHEET_NAME[row //
                                                 (PT_NUM[0] * MPT_NUM)]))
            expand_e_table = ExcelTable(
                expand_repair_repair.add_sheet(
                    ALIGN_SHEET_NAME[row // (PT_NUM[0] * MPT_NUM)]))
        pt_number.apply(trees[row // MPT_NUM], 'D', 1)
        pt_number.apply(m_tree, 'D', 1)
        repair_info = repair_align_info(trees[row // MPT_NUM], m_tree,
                                        logs[row // MPT_NUM],
                                        alignments_t1[row // MPT_NUM].aligns,
                                        alignments_t2[row].best_worst_cost,
                                        alignments_t2[row].cost_opt,
                                        parameters)
        expand_repair_info = expand_repair_align_info(
            trees[row // MPT_NUM], m_tree, logs[row // MPT_NUM],
            alignments_t1[row // MPT_NUM].aligns,
            alignments_t2[row].best_worst_cost, alignments_t2[row].cost_opt,
            parameters)

        excel_utils.write_column_to_table(expand_e_table.table,
                                          expand_e_table.column,
                                          expand_repair_info[0])
        excel_utils.write_row_to_table(
            result_e_table.table, result_e_table.row,
            alignments_t2[row].get_opt_info() + repair_info[1] +
            expand_repair_info[1])

    excel_utils.save(base, result_file)
    excel_utils.save(expand_repair_repair, expand_repair_file)
Пример #3
0
def create_log():
    """
    Create specified number of event logs of each tree, not including Empty Trace.

    The event log in the same column belong to the same process tree.
    """
    base = excel_utils.create_workbook()
    trees = object_read.read_trees_from_file(PT_FILE_NAME)
    log_e_table = None
    for row, tree in enumerate(trees):
        if row % PT_NUM[0] == 0:
            log_e_table = ExcelTable(
                base.add_sheet(LOG_SHEET_NAME[row // PT_NUM[0]]))
        log = log_create.apply(tree, TRACE_NUM, 0.8)
        trace_list = [[event[DEFAULT_NAME_KEY] for event in trace]
                      for trace in log]
        excel_utils.write_column_to_table(log_e_table.table,
                                          log_e_table.column, trace_list)
    excel_utils.save(base, LOG_FILE_NAME)
Пример #4
0
def create_tree():
    """
    Create totally 80 process trees, in which
        10 trees with 11-15 nodes
        10 trees with 16-18 nodes
        10 trees with 19-21 nodes
        10 trees with 22-24 nodes
        10 trees with 25-27 nodes
        10 trees with 28-30 nodes
        10 trees with 31-33 nodes
        10 trees with 34-45 nodes

    Worksheet
    -----------
    Base worksheet:
        Store Information of based Process Tree

    Other Worksheet:
        Store Information of mutated process tree with based process tree
        The worksheet differs based on the size of mutated sub process tree.
        e.g. For "MPT4", only the depth of Sub PT less or equal than 4 can mutate.

    Records Format For base Worksheet
    ---------
    Number of nodes, Process Tree, Number of leaves, Depth of PT, Operator of root


    Records Format For other Worksheet
    ---------
    Row number in base worksheet, (content in that row), Number of nodes of MPT, Mutated Process Tree (MPT)
     Number of leaves of MPT, Depth of MPT, Operator of the root of MPT,

    """
    base = excel_utils.create_workbook()
    original_e_tab = ExcelTable(base.add_sheet("PT"))
    mutate_e_tabs = []
    for level in MPT_LEVEL:
        mutate_e_tab = ExcelTable(base.add_sheet("MPT" + str(level)))
        mutate_e_tabs.append(mutate_e_tab)
    for i in range(len(PT_NUM)):
        pt_write_to_table(original_e_tab, mutate_e_tabs, PT_NUM[i],
                          PT_RANGE[i][0], PT_RANGE[i][0], MPT_NUM, MPT_LEVEL)
    excel_utils.save(base, PT_FILE_NAME)
Пример #5
0
def compute_repair_result_option2(repair_file_result, mpt_index, align_mpt,
                                  result_file):
    """

    Records
    ----------

    """
    input_list = object_read.read_expand_repair_grade_not_equal_to_one(
        repair_file_result, mpt_index, align_mpt)
    base = excel_utils.create_workbook()
    expand_e_table = ExcelTable(base.add_sheet("COMPARE"))
    parameters = {'ret_tuple_as_trans_desc': True, 'COMPARE_OPTION': 2}
    for (o_info, tree, m_tree, log, alignment_t1, alignment_t2) in input_list:
        pt_number.apply(tree, 'D', 1)
        pt_number.apply(m_tree, 'D', 1)
        expand_repair_info = expand_repair_align_info(
            tree, m_tree, log, alignment_t1.aligns,
            alignment_t2.best_worst_cost, alignment_t2.cost_opt, parameters)
        excel_utils.write_column_to_table(expand_e_table.table,
                                          expand_e_table.column,
                                          o_info + expand_repair_info[1])

    excel_utils.save(base, result_file)