Exemplo n.º 1
0
def execute_script():
    # read an event log
    log = pm4py.read_xes("../tests/compressed_input_data/02_teleclaims.xes.gz")
    # log = pm4py.read_xes("../tests/input_data/receipt.xes")
    print("number of variants of the original log ->", len(pm4py.get_variants(log)))
    # discover a process model
    tree = pm4py.discover_tree_inductive(log)
    # simulate a log out of the model (to have another log that is similar to the original)
    aa = time.time()
    min_trace_length = bottomup_discovery.get_min_trace_length(tree)
    simulated_log = tree_playout.apply(tree, variant=tree_playout.Variants.EXTENSIVE,
                                       parameters={"max_trace_length": min_trace_length + 2})
    print("number of variants of the simulated log -> ", len(simulated_log))
    # apply the alignments between this log and the model
    bb = time.time()
    aligned_traces = logs_alignment.apply(log, simulated_log)
    cc = time.time()
    print(aligned_traces[0])
    print("playout time", bb - aa)
    print("alignments time", cc - bb)
    print("TOTAL", cc - aa)
    print(alignment_based.evaluate(aligned_traces))
    # apply the anti alignments between this log and the model
    dd = time.time()
    anti_aligned_traces = logs_alignment.apply(log, simulated_log,
                                               parameters={
                                                   logs_alignment.Variants.EDIT_DISTANCE.value.Parameters.PERFORM_ANTI_ALIGNMENT: True})
    ee = time.time()
    print(anti_aligned_traces[0])
    print("anti alignments time", ee - dd)
    print(alignment_based.evaluate(anti_aligned_traces))
Exemplo n.º 2
0
def apply(tree, parameters=None):
    """
    Footprints detection on process tree

    Parameters
    -----------------
    tree
        Process tree
    parameters
        Parameters of the algorithm

    Returns
    -----------------
    footprints
        Footprints
    """
    if parameters is None:
        parameters = {}

    all_footprints = get_all_footprints(tree, parameters=parameters)
    root_node_footprints = all_footprints[tree]

    min_trace_length = bottomup_disc.get_min_trace_length(tree, parameters=parameters)
    root_node_footprints[Outputs.MIN_TRACE_LENGTH.value] = min_trace_length

    return root_node_footprints
Exemplo n.º 3
0
def apply(tree, parameters=None):
    """
    Performs an extensive playout of the process tree

    Parameters
    -------------
    tree
        Process tree
    parameters
        Possible parameters, including:
        - Parameters.MAX_TRACE_LENGTH => maximum length of a trace (default: min_allowed_trace_length)
        - Parameters.MAX_LOOP_OCC => maximum number of occurrences for a loop (default: MAX_TRACE_LENGTH)
        - Parameters.ACTIVITY_KEY => activity key
        - Parameters.MAX_LIMIT_NUM_TRACES => maximum number to the limit of traces; the playout shall stop when the number is reached (default: sys.maxsize)
    Returns
    -------------
    log_skeleton
        Event log_skeleton
    """
    if parameters is None:
        parameters = {}

    activity_key = exec_utils.get_param_value(Parameters.ACTIVITY_KEY, parameters, xes_constants.DEFAULT_NAME_KEY)
    # to save memory in the returned log_skeleton, allocate each activity once. to know the list of activities of the
    # process tree, use the footprints module
    fp_tree = fp_discovery.apply(tree, parameters=parameters)
    activities = fp_tree["activities"]
    activities = {act: Event({activity_key: act}) for act in activities}

    min_allowed_trace_length = bottomup_discovery.get_min_trace_length(tree, parameters=parameters)
    max_trace_length = exec_utils.get_param_value(Parameters.MAX_TRACE_LENGTH, parameters, min_allowed_trace_length)
    max_loop_occ = exec_utils.get_param_value(Parameters.MAX_LOOP_OCC, parameters, int(max_trace_length/2))
    max_limit_num_traces = exec_utils.get_param_value(Parameters.MAX_LIMIT_NUM_TRACES, parameters, 100000)
    return_set_strings = exec_utils.get_param_value(Parameters.RETURN_SET_STRINGS, parameters, False)

    bottomup = bottomup_discovery.get_bottomup_nodes(tree, parameters=parameters)
    min_rem_dict = bottomup_discovery.get_min_rem_dict(tree, parameters=parameters)

    playout_dictio = {}
    for i in range(len(bottomup)):
        get_playout(bottomup[i], playout_dictio, max_trace_length, max_loop_occ, min_rem_dict, max_limit_num_traces)
    tree_playout_traces = playout_dictio[tree][TRACES]

    if return_set_strings:
        return tree_playout_traces

    log = EventLog()
    for tr0 in tree_playout_traces:
        trace = Trace()
        for act in tr0:
            trace.append(activities[act])
        log.append(trace)

    return log