Пример #1
0
def compute_run_time():
    no_tree, no_event, pro, mutated_num = 10, 10, 0.9, 5
    tree1 = [pt_create.apply(random.randint(11, 15)) for _ in range(no_tree)]
    m_tree1 = [[pt_mutate.apply(tree) for _ in range(mutated_num)]
               for tree in tree1]
    log1 = [log_create.apply(tree, no_event, pro) for tree in tree1]
    tree2 = [pt_create.apply(random.randint(16, 20)) for _ in range(no_tree)]
    m_tree2 = [[pt_mutate.apply(tree) for _ in range(mutated_num)]
               for tree in tree2]
    log2 = [log_create.apply(tree, no_event, pro) for tree in tree2]
    tree3 = [pt_create.apply(random.randint(21, 25)) for _ in range(no_tree)]
    m_tree3 = [[pt_mutate.apply(tree) for _ in range(mutated_num)]
               for tree in tree3]
    log3 = [log_create.apply(tree, no_event, pro) for tree in tree3]
    tree4 = [pt_create.apply(random.randint(26, 30)) for _ in range(no_tree)]
    log4 = [log_create.apply(tree, no_event, pro) for tree in tree4]
    m_tree4 = [[pt_mutate.apply(tree) for _ in range(mutated_num)]
               for tree in tree4]
    # tree5 = [pt_create.apply(random.randint(31, 33)) for _ in range(no_tree)]
    # log5 = [log_create.apply(tree, no_event, pro) for tree in tree5]
    # m_tree5 = [[pt_mutate.apply(tree) for _ in range(mutated_num)] for tree in tree5]
    # tree6 = [pt_create.apply(random.randint(34, 35)) for _ in range(no_tree)]
    # log6 = [log_create.apply(tree, no_event, pro) for tree in tree6]
    # m_tree6 = [[pt_mutate.apply(tree) for _ in range(mutated_num)] for tree in tree6]

    l_without_lock = list(
        map(
            lambda tree_log: avg_runtime_without_lock(tree_log[0], tree_log[
                1], tree_log[2]), [(tree1, m_tree1, log1),
                                   (tree2, m_tree2, log2),
                                   (tree3, m_tree3, log3),
                                   (tree4, m_tree4, log4)]))
    # , (tree5, m_tree5, log5), (tree6, m_tree6, log6)
    l_with_lock = list(
        map(
            lambda tree_log: avg_runtime_with_lock(tree_log[0], tree_log[
                1], tree_log[2]), [(tree1, m_tree1, log1),
                                   (tree2, m_tree2, log2),
                                   (tree3, m_tree3, log3),
                                   (tree4, m_tree4, log4)]))
    # , (tree5, m_tree5, log5), (tree6, m_tree6, log6)
    plot_histogram_lock_runtime(l_without_lock, l_with_lock)
Пример #2
0
def create_logs(pts):
    logs_list = list()
    for trees in pts:
        logs = pd.DataFrame(columns=['log'])
        for i, s_tree in enumerate(trees['tree']):
            tree = pt_utils.parse(s_tree)
            logs.loc[i] = [
                parse_string_list(
                    log_create.apply(tree, trace_num, non_fit_pro))
            ]
        logs_list.append(logs)
    return logs_list
Пример #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)
def creat_non_fitting_based_on_tree2(file, name, node_num, parameters):
    num = [
        "node", "best_worst_cost", "optimal_cost", "optimal_time",
        "repaired_cost", "repaired_time", "scope_repair_cost",
        "scope_repair_time", "grade1", "grade2"
    ]
    tree_num, mutated_num, log_num, non_fit_pro = 25, 1, 1, 0.9
    tree = [
        pt_create.apply(random.randint(node_num[0], node_num[1]))
        for _ in range(tree_num)
    ]
    m_tree = [[pt_mutate.apply(tree) for _ in range(mutated_num)]
              for tree in tree]
    log = [[
        log_create.apply(m_tree, log_num, non_fit_pro) for m_tree in m_tr4
    ] for m_tr4 in m_tree]
    for i in range(len(tree)):
        for j in range(len(m_tree[0])):
            result = compute_cost_and_time(tree[i], m_tree[i][j], log[i][j],
                                           parameters)
            print_tree_align_compare(result)
def creat_non_fitting_based_on_tree1(file, name, node_num):
    num = [
        "node", "best_worst_cost", "optimal_cost", "optimal_time",
        "repaired_cost", "repaired_time", "scope_repair_cost",
        "scope_repair_time", "grade1", "grade2"
    ]
    tree_num, mutated_num, log_num, non_fit_pro = 5, 1, 5, 0.9
    tree = [
        pt_create.apply(random.randint(node_num[0], node_num[1]))
        for _ in range(tree_num)
    ]
    m_tree = [[pt_mutate.apply(tree) for _ in range(mutated_num)]
              for tree in tree]
    log = [log_create.apply(tree, log_num, non_fit_pro) for tree in tree]
    for i in range(len(tree)):
        node_num = pt_mani_utils.non_none_leaves_number(tree[i])
        for j in range(len(m_tree[0])):
            param1 = {'ret_tuple_as_trans_desc': True, 'COMPARE_OPTION': 1}
            result = compute_cost_and_time(tree[i], m_tree[i][j], log[i],
                                           param1)
            print_tree_align_compare(result)
            result["node"] = node_num