コード例 #1
0
def apply(net, initial_marking, final_marking, log=None, aggregated_statistics=None, parameters=None):
    """
    Apply method for Petri net visualization (useful for recall from factory; it calls the
    graphviz_visualization method)

    Parameters
    -----------
    net
        Petri net
    initial_marking
        Initial marking
    final_marking
        Final marking
    log
        (Optional) log
    aggregated_statistics
        Dictionary containing the frequency statistics
    parameters
        Algorithm parameters

    Returns
    -----------
    viz
        Graph object
    """
    if aggregated_statistics is None and log is not None:
        aggregated_statistics = alignments_decoration.get_alignments_decoration(net, initial_marking, final_marking,
                                                                                log=log)

    return visualize.apply(net, initial_marking, final_marking, parameters=parameters,
                           decorations=aggregated_statistics)
コード例 #2
0
def apply_petri(net,
                initial_marking,
                final_marking,
                log=None,
                aggregated_statistics=None,
                parameters=None):
    """
    Visualize a BPMN graph from a Petri net, decorated with frequency, using the given parameters

    Parameters
    -----------
    net
        Petri net
    initial_marking
        Initial marking
    final_marking
        Final marking
    log
        (Optional) log where the replay technique should be applied
    aggregated_statistics
        (Optional) element-wise statistics calculated on the Petri net
    parameters
        Possible parameters of the algorithm, including:
            format -> Format of the image to render (pdf, png, svg)
            aggregationMeasure -> Measure to use to aggregate statistics
            pmutil.constants.PARAMETER_CONSTANT_ACTIVITY_KEY -> Specification of the activity key
            (if not concept:name)
            pmutil.constants.PARAMETER_CONSTANT_TIMESTAMP_KEY -> Specification of the timestamp key
            (if not time:timestamp)

    Returns
    -----------
    file_name
        Path of the figure in which the rendered BPMN has been saved
    """

    if parameters is None:
        parameters = {}

    image_format = parameters["format"] if "format" in parameters else "png"

    bpmn_graph, elements_correspondence, inv_el_corr, el_corr_keys_map = bpmn_converter.apply(
        net, initial_marking, final_marking)

    if aggregated_statistics is None and log is not None:
        aggregated_statistics = alignments_decoration.get_alignments_decoration(
            net, initial_marking, final_marking, log=log)

    bpmn_aggreg_statistics = None
    if aggregated_statistics is not None:
        bpmn_aggreg_statistics = convert_performance_map.convert_performance_map_to_bpmn(
            aggregated_statistics, inv_el_corr)

    file_name = bpmn_diagram_to_figure(
        bpmn_graph,
        image_format,
        bpmn_aggreg_statistics=bpmn_aggreg_statistics)
    return file_name
コード例 #3
0
ファイル: get_align.py プロジェクト: zhengyuxin/pm4py-ws
def perform_alignments(log, petri_string, parameters=None):
    """
    Perform alignments

    Parameters
    ------------
    log
        Log
    net
        Petri net
    parameters
        Parameters of the algorithm

    Returns
    -------------
    petri
        SVG of the decorated Petri
    table
        SVG of the decorated table
    """
    if parameters is None:
        parameters = {}

    net, im, fm = pnml.import_petri_from_string(petri_string,
                                                parameters=parameters)

    parameters_align = copy(parameters)
    parameters_align["ret_tuple_as_trans_desc"] = True

    alignments = align_factory.apply(log,
                                     net,
                                     im,
                                     fm,
                                     parameters=parameters_align)
    decorations = alignments_decoration.get_alignments_decoration(
        net, im, fm, aligned_traces=alignments, parameters=parameters)

    gviz_on_petri = pn_vis_factory.apply(net,
                                         im,
                                         fm,
                                         aggregated_statistics=decorations,
                                         variant="alignments",
                                         parameters={"format": "svg"})
    svg_on_petri = get_base64_from_gviz(gviz_on_petri)

    parameters_table = copy(parameters)
    parameters_table["format"] = "svg"

    gviz_table = align_table_factory.apply(log,
                                           alignments,
                                           parameters=parameters_table)
    svg_table = get_base64_from_gviz(gviz_table)

    return svg_on_petri, svg_table
コード例 #4
0
def apply_through_conv(bpmn_graph,
                       log=None,
                       aggregated_statistics=None,
                       parameters=None):
    """
    Visualize a BPMN graph decorating it through conversion to a Petri net

    Parameters
    -----------
    bpmn_graph
        BPMN graph object
    log
        (Optional) log where the replay technique should be applied
    aggregated_statistics
        (Optional) element-wise statistics calculated on the Petri net
    parameters
        Possible parameters, of the algorithm, including:
            format -> Format of the image to render (pdf, png, svg)

    Returns
    -----------
    file_name
        Path of the figure in which the rendered BPMN has been saved
    """

    if parameters is None:
        parameters = {}

    image_format = parameters["format"] if "format" in parameters else "png"

    net, initial_marking, final_marking, elements_correspondence, inv_elements_correspondence, el_corr_keys_map = \
        bpmn_to_petri.apply(bpmn_graph)

    if aggregated_statistics is None and log is not None:
        aggregated_statistics = alignments_decoration.get_alignments_decoration(
            net, initial_marking, final_marking, log=log)

    bpmn_aggreg_statistics = None
    if aggregated_statistics is not None:
        bpmn_aggreg_statistics = convert_performance_map.convert_performance_map_to_bpmn(
            aggregated_statistics, inv_elements_correspondence)

    file_name = bpmn_diagram_to_figure(
        bpmn_graph,
        image_format,
        bpmn_aggreg_statistics=bpmn_aggreg_statistics)
    return file_name
コード例 #5
0
def apply_embedding(bpmn_graph,
                    log=None,
                    aggregated_statistics=None,
                    parameters=None):
    """
    Embed decoration information inside the BPMN graph

    Parameters
    -----------
    bpmn_graph
        BPMN graph object
    log
        (Optional) log where the replay technique should be applied
    aggregated_statistics
        (Optional) element-wise statistics calculated on the Petri net
    parameters
        Possible parameters, of the algorithm

    Returns
    -----------
    bpmn_graph
        Annotated BPMN graph
    """
    if parameters is None:
        parameters = {}

    net, initial_marking, final_marking, elements_correspondence, inv_elements_correspondence, el_corr_keys_map = \
        bpmn_to_petri.apply(bpmn_graph)

    if aggregated_statistics is None and log is not None:
        aggregated_statistics = alignments_decoration.get_alignments_decoration(
            net, initial_marking, final_marking, log=log)

    if aggregated_statistics is not None:
        bpmn_aggreg_statistics = convert_performance_map.convert_performance_map_to_bpmn(
            aggregated_statistics, inv_elements_correspondence)
        bpmn_graph = bpmn_embedding.embed_info_into_bpmn(
            bpmn_graph, bpmn_aggreg_statistics, "conformance")

    return bpmn_graph