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 = token_decoration.get_decorations( log, net, initial_marking, final_marking, parameters=parameters, measure="performance", ht_perf_method="first") 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
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 = token_decoration.get_decorations( log, net, initial_marking, final_marking, parameters=parameters, measure="performance") 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, "performance") return bpmn_graph
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 performance, 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, el_corr, 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 = token_decoration.get_decorations( log, net, initial_marking, final_marking, parameters=parameters, measure="performance") 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
def apply(log, parameters=None): """ Gets the Petri net through Inductive Miner, decorated by performance metric Parameters ------------ log Log parameters Parameters of the algorithm Returns ------------ base64 Base64 of an SVG representing the model model Text representation of the model format Format of the model """ if parameters is None: parameters = {} decreasingFactor = parameters[ "decreasingFactor"] if "decreasingFactor" in parameters else constants.DEFAULT_DEC_FACTOR activity_key = parameters[ pm4_constants. PARAMETER_CONSTANT_ACTIVITY_KEY] if pm4_constants.PARAMETER_CONSTANT_ACTIVITY_KEY in parameters else xes.DEFAULT_NAME_KEY # reduce the depth of the search done by token-based replay token_replay.MAX_REC_DEPTH = 1 token_replay.MAX_IT_FINAL1 = 1 token_replay.MAX_IT_FINAL2 = 1 token_replay.MAX_REC_DEPTH_HIDTRANSENABL = 1 log = attributes_filter.filter_log_on_max_no_activities( log, max_no_activities=constants.MAX_NO_ACTIVITIES, parameters=parameters) filtered_log = auto_filter.apply_auto_filter(log, parameters=parameters) activities_count = attributes_filter.get_attribute_values( filtered_log, activity_key) activities = list(activities_count.keys()) start_activities = list( start_activities_filter.get_start_activities( filtered_log, parameters=parameters).keys()) end_activities = list( end_activities_filter.get_end_activities(filtered_log, parameters=parameters).keys()) dfg = dfg_factory.apply(filtered_log, parameters=parameters) dfg = clean_dfg_based_on_noise_thresh( dfg, activities, decreasingFactor * constants.DEFAULT_DFG_CLEAN_MULTIPLIER, parameters=parameters) net, im, fm = inductive_miner.apply_dfg(dfg, parameters=parameters, activities=activities, start_activities=start_activities, end_activities=end_activities) #parameters["format"] = "svg" #gviz = pn_vis_factory.apply(net, im, fm, log=log, variant="performance", parameters=parameters) bpmn_graph, el_corr, inv_el_corr, el_corr_keys_map = petri_to_bpmn.apply( net, im, fm) aggregated_statistics = token_decoration.get_decorations( filtered_log, net, im, fm, parameters=parameters, measure="performance") bpmn_aggreg_statistics = convert_performance_map.convert_performance_map_to_bpmn( aggregated_statistics, inv_el_corr) #bpmn_graph = bpmn_embedding.embed_info_into_bpmn(bpmn_graph, bpmn_aggreg_statistics, "performance") bpmn_graph = bpmn_diagram_layouter.apply(bpmn_graph) bpmn_string = bpmn_exporter.get_string_from_bpmn(bpmn_graph) gviz = bpmn_vis_factory.apply_petri( net, im, fm, aggregated_statistics=aggregated_statistics, variant="performance", parameters={"format": "svg"}) gviz2 = bpmn_vis_factory.apply_petri( net, im, fm, aggregated_statistics=aggregated_statistics, variant="performance", parameters={"format": "dot"}) svg = get_base64_from_file(gviz.name) gviz_base64 = get_base64_from_file(gviz2.name) ret_graph = get_graph.get_graph_from_petri(net, im, fm) return svg, export_petri_as_string( net, im, fm ), ".pnml", "xes", activities, start_activities, end_activities, gviz_base64, ret_graph, "indbpmn", "perf", bpmn_string, ".bpmn", activity_key