def test_simple_execution_receipt(self): self.dummy = "dummy" log = xes_importer.apply(os.path.join(INPUT_DATA_DIR, "receipt.xes")) output_dictionary = simple_model_factory.apply(log) net, initial_marking, final_marking = simple_model_factory.apply( log, classic_output=True) del output_dictionary del net del initial_marking del final_marking
def transient_analysis_from_dataframe(df, delay, parameters=None): """ Gets the transient analysis from a dataframe and a delay Parameters ------------- df Pandas dataframe delay Time delay parameters Parameters of the algorithm Returns ------------- transient_result Transient analysis result """ if parameters is None: parameters = {} activity_key = parameters[ constants. PARAMETER_CONSTANT_ACTIVITY_KEY] if constants.PARAMETER_CONSTANT_ACTIVITY_KEY in parameters else xes.DEFAULT_NAME_KEY case_id_glue = parameters[ constants. PARAMETER_CONSTANT_CASEID_KEY] if constants.PARAMETER_CONSTANT_CASEID_KEY in parameters else CASE_CONCEPT_NAME timestamp_key = parameters[ constants. PARAMETER_CONSTANT_TIMESTAMP_KEY] if constants.PARAMETER_CONSTANT_TIMESTAMP_KEY in parameters else xes.DEFAULT_TIMESTAMP_KEY log = log_conv_factory.apply(df, variant=log_conv_factory.DF_TO_EVENT_LOG_1V, parameters=parameters) # gets the simple Petri net through simple miner net, im, fm = simple_factory.apply(log, parameters=parameters, classic_output=True) activities_count = dict(df.groupby(activity_key).size()) dfg_performance = df_statistics.get_dfg_graph(df, measure="performance", perf_aggregation_key="mean", case_id_glue=case_id_glue, activity_key=activity_key, timestamp_key=timestamp_key) spaths = get_shortest_paths(net) aggregated_statistics = get_decorations_from_dfg_spaths_acticount( net, dfg_performance, spaths, activities_count, variant="performance") # gets the stochastic map out of the dataframe and the Petri net s_map = smap_builder.get_map_exponential_from_aggstatistics( aggregated_statistics, parameters=parameters) return transient_analysis_from_petri_net_and_smap(net, im, s_map, delay, parameters=parameters)
def execute_script(): log_name = os.path.join("..", "tests", "input_data", "running-example.xes") log = xes_importer.apply(log_name, variant="nonstandard") print("imported log") # obtain a simple, sound workflow net, containing only visibile unique transitions, # applying the Alpha Miner to some of the top variants (methods by Ale) activity_key = "concept:name" parameters = {PARAMETER_CONSTANT_ACTIVITY_KEY: activity_key, PARAMETER_CONSTANT_ATTRIBUTE_KEY: activity_key} net, initial_marking, final_marking = simple_extraction_factory.apply(log, classic_output=True, parameters=parameters) print("obtained model") # visualize the output Petri net gviz = pn_vis_factory.apply(net, initial_marking, final_marking) del gviz # pn_vis_factory.view(gviz) # gets the average time between cases starts avg_time_starts = get_case_arrival_avg(log) print("avg_time_starts real=", avg_time_starts) # gets the stochastic distribution associated to the Petri net and the log smap = stochastic_map.get_map_from_log_and_net(log, net, initial_marking, final_marking, force_distribution="EXPONENTIAL") print("smap=", smap) perf_bound_obj = LpPerfBounds(net, initial_marking, final_marking, smap, avg_time_starts) net1, imarking1, fmarking1 = perf_bound_obj.get_net() gviz = pn_vis_factory.apply(net1, imarking1, fmarking1) for var in perf_bound_obj.var_corr: corr = perf_bound_obj.var_corr[var] minimum = perf_bound_obj.solve_problem(var, maximize=False) maximum = perf_bound_obj.solve_problem(var, maximize=True) print(var, minimum[corr], maximum[corr])
def transient_analysis_from_log(log, delay, parameters=None): """ Gets the transient analysis from a log and a delay Parameters ------------- log Event log delay Time delay parameters Parameters of the algorithm Returns ------------- transient_result Transient analysis result """ if parameters is None: parameters = {} # gets the simple Petri net through simple miner net, im, fm = simple_factory.apply(log, parameters=parameters, classic_output=True) # gets the stochastic map out of the log and the Petri net s_map = smap_builder.get_map_from_log_and_net(log, net, im, fm, parameters=parameters, force_distribution="EXPONENTIAL") return transient_analysis_from_petri_net_and_smap(net, im, s_map, delay, parameters=parameters)
def execute_script(): # loads the log log = xes_importer.apply( os.path.join("..", "tests", "input_data", "receipt.xes")) # apply the simple miner net, im, fm = simple_miner.apply(log, classic_output=True) # checks if the Petri net is a sound workflow net is_sound_wfnet = check_petri_wfnet_and_soundness(net) print("is_sound_wfnet = ", is_sound_wfnet)
def generate_simple_net(xes_log): try: simple_net, initial_marking, final_marking = simple_algorithm.apply( xes_log, classic_output=True, parameters={"max_no_variants": 20}) return { 'simple_net': simple_net, 'initial_marking': initial_marking, 'final_marking': final_marking } except AttributeError: print("Please check your input values")
def run_simple_miner(log,classic_output=True,parameters={"max_no_variants": 20}): net, initial_marking, final_marking = simple_algorithm.apply(log, classic_output=classic_output, parameters=parameters) #gviz = vis_petri.apply(net, initial_marking, final_marking) #vis_petri.view(gviz) return net, initial_marking, final_marking
from pm4py.algo.discovery.simple.model.log import factory as simple_model_factory logFolder = os.path.join("..", "compressed_input_data") pnmlFolder = "simple_pnml" pngFolder = "simple_png" for logName in os.listdir(logFolder): if "." in logName: logNamePrefix = logName.split(".")[0] print("\nelaborating " + logName) logPath = os.path.join(logFolder, logName) log = xes_factory.import_log(logPath, variant="iterparse") net, initial_marking, final_marking = simple_model_factory.apply( log, classic_output=True) pnml_exporter.export_net(net, initial_marking, os.path.join(pnmlFolder, logNamePrefix) + ".pnml", final_marking=final_marking) gviz = petri_vis_factory.apply(net, initial_marking, final_marking, log=log, variant="frequency") petri_vis_factory.save( gviz,