コード例 #1
0
def execute_script():
    # log_path = "C:/Users/bas/Documents/tue/svn/private/logs/ilp_test_2_abcd_acbd.xes"
    log_path = os.path.join("..", "tests", "input_data", "running-example.xes")
    log = xes_importer.import_log(log_path)
    ts = ts_factory.apply(log)
    viz = ts_vis_factory.apply(ts, parameters={"format": "svg"})
    ts_vis_factory.view(viz)
コード例 #2
0
def execute_script():
    log_path = os.path.join("..", "tests", "input_data", "running-example.xes")
    log = xes_importer.apply(log_path)
    # obtain Petri net through Alpha Miner
    net, initial_marking, final_marking = alpha_miner.apply(log)
    # obtain stochastic information for transitions in the model
    s_map = stochastic_map.get_map_from_log_and_net(
        log,
        net,
        initial_marking,
        final_marking,
        force_distribution="EXPONENTIAL")
    # export the current stochastic Petri net
    petri_exporter.export_net(net,
                              initial_marking,
                              "example.pnml",
                              final_marking=final_marking,
                              stochastic_map=s_map)
    # re-import the current stochastic Petri net from file
    net, initial_marking, final_marking, s_map = petri_importer.import_net(
        "example.pnml", return_stochastic_information=True)
    # remove temporary file
    os.remove("example.pnml")
    # gets the reachability graph from the Petri net
    reachab_graph = construct_reachability_graph(net, initial_marking)
    # get the tangible reachability graph from the reachability graph and the stochastic map
    tang_reach_graph = tangible_reachability.get_tangible_reachability_from_reachability(
        reachab_graph, s_map)
    # visualize the tangible reachability graph on the screen
    viz = ts_vis_factory.apply(tang_reach_graph,
                               parameters={
                                   "format": "svg",
                                   "show_labels": True,
                                   "show_names": True
                               })
    ts_vis_factory.view(viz)
    # gets the Q matrix assuming exponential distributions
    q_matrix = ctmc.get_q_matrix_from_tangible_exponential(
        tang_reach_graph, s_map)
    # pick a state to start from
    states = sorted(list(tang_reach_graph.states), key=lambda x: x.name)
    state = states[0]
    print("\n\nstarting from state = ", state.name)
    # do transient analysis after 1 day
    transient_result = ctmc.transient_analysis_from_tangible_q_matrix_and_single_state(
        tang_reach_graph, q_matrix, state, 86400)
    print("\nprobability for each state after 1 day = ", transient_result)
    # do transient analysis after 10 days
    transient_result = ctmc.transient_analysis_from_tangible_q_matrix_and_single_state(
        tang_reach_graph, q_matrix, state, 864000)
    print("\nprobability for each state after 10 days = ", transient_result)
    # do transient analysis after 100 days
    transient_result = ctmc.transient_analysis_from_tangible_q_matrix_and_single_state(
        tang_reach_graph, q_matrix, state, 8640000)
    print("\nprobability for each state after 100 days = ", transient_result)
    steady_state = ctmc.steadystate_analysis_from_tangible_q_matrix(
        tang_reach_graph, q_matrix)
    print("\nsteady state = ", steady_state)
コード例 #3
0
def execute_script():
    log_path = os.path.join("..", "tests", "input_data", "running-example.csv")
    dataframe = pandas_df_imp.import_dataframe_from_path(log_path)
    activities_count = dict(dataframe.groupby("concept:name").size())
    [dfg_frequency, dfg_performance] = df_statistics.get_dfg_graph(dataframe, measure="both",
                                                                   perf_aggregation_key="mean")
    net, initial_marking, final_marking = alpha_miner.apply_dfg(dfg_frequency)
    spaths = get_shortest_paths(net)
    aggregated_statistics = get_decorations_from_dfg_spaths_acticount(net, dfg_performance,
                                                                      spaths,
                                                                      activities_count,
                                                                      variant="performance")
    # obtain stochastic information for transitions in the model
    s_map = stochastic_map.get_map_exponential_from_aggstatistics(aggregated_statistics)
    # gets the reachability graph from the Petri net
    reachab_graph = construct_reachability_graph(net, initial_marking)
    # get the tangible reachability graph from the reachability graph and the stochastic map
    tang_reach_graph = tangible_reachability.get_tangible_reachability_from_reachability(reachab_graph, s_map)
    # visualize the tangible reachability graph on the screen
    viz = ts_vis_factory.apply(tang_reach_graph, parameters={"format": "svg", "show_labels": True, "show_names": True})
    ts_vis_factory.view(viz)
    # gets the Q matrix assuming exponential distributions
    q_matrix = ctmc.get_q_matrix_from_tangible_exponential(tang_reach_graph, s_map)
    # pick a state to start from
    states = sorted(list(tang_reach_graph.states), key=lambda x: x.name)
    state = states[0]
    print("\n\nstarting from state = ", state.name)
    # do transient analysis after 1 day
    transient_result = ctmc.transient_analysis_from_tangible_q_matrix_and_single_state(tang_reach_graph, q_matrix,
                                                                                       state, 86400)
    print("\nprobability for each state after 1 day = ", transient_result)
    # do transient analysis after 10 days
    transient_result = ctmc.transient_analysis_from_tangible_q_matrix_and_single_state(tang_reach_graph, q_matrix,
                                                                                       state, 864000)
    print("\nprobability for each state after 10 days = ", transient_result)
    # do transient analysis after 100 days
    transient_result = ctmc.transient_analysis_from_tangible_q_matrix_and_single_state(tang_reach_graph, q_matrix,
                                                                                       state, 8640000)
    print("\nprobability for each state after 100 days = ", transient_result)
    steady_state = ctmc.steadystate_analysis_from_tangible_q_matrix(tang_reach_graph, q_matrix)
    print("\nsteady state = ", steady_state)
コード例 #4
0
from translucent_event_log.objects.tel.importer.xes.iterparse_tel import import_tel
import os
from translucent_event_log.objects.tel.importer.xes.utils import log_to_tel
from translucent_event_log.objects.tel.utils import tel_set_enabled
from pm4py.algo.discovery.alpha import factory as alpha_miner
from pm4py.visualization.petrinet import factory as vis_factory
from pm4py.visualization.transition_system import factory as trans_vis_factory
from pm4py.algo.discovery.transition_system import factory as trans_factory
from translucent_event_log.objects.tel import utils
from translucent_event_log.algo.discover_petrinet import state_based_region as sb

input_file_path = os.path.join("input_data", "test_logs", "running_10_tel.xes")
log = import_tel(input_file_path)
tel = tel_set_enabled(log)

auto = utils.discover_annotated_automaton(tel)
gviz = trans_vis_factory.apply(auto)
trans_vis_factory.view(gviz)  #show automaton

auto_2 = trans_factory.apply(log)

nett, im, fm = sb.petri_net_synthesis(auto)
net, i, f = sb.petri_net_synthesis(auto_2)
#
gviz = vis_factory.apply(nett, im, fm)
vis_factory.view(gviz)

# gviz = vis_factory.apply(net, i, f)
# vis_factory.view(gviz)
コード例 #5
0
import os
from tests.translucent_event_log_new.objects.tel.importer.xes.utils import log_to_tel
from pm4py.algo.discovery.alpha import factory as alpha_miner
from tests.translucent_event_log_new.objects.tel.utils import tel_set_enabled
from pm4py.visualization.transition_system import factory as vis_factory
from pm4py.visualization.petrinet import factory as petri_factory
from tests.translucent_event_log_new.algo.discover_automaton import utils
from datetime import timedelta
from tests.translucent_event_log_new.algo.discover_petrinet import state_based_region as sb

input_file_path = os.path.join("input_data", "running-example_tel.xes")
log = import_tel(input_file_path)
tel = tel_set_enabled(log)

auto = utils.discover_annotated_automaton(tel)
gviz = vis_factory.apply(auto)
vis_factory.view(gviz)  #show automaton

auto = utils.discover_annotated_automaton(tel,
                                          parameters={
                                              'sfreq_thresh': 2,
                                              'afreq_thresh': 3
                                          })

gviz = vis_factory.apply(auto)
vis_factory.view(gviz)  #show automaton

nett, im, fm = sb.petri_net_synthesis(auto)
#
gviz = petri_factory.apply(nett, im, fm)
petri_factory.view(gviz)
コード例 #6
0
from tests.translucent_event_log.algo.discovery.state_based_region_theory import state_based_region_theory as state_region
from tests.translucent_event_log.objects.tel.importer.xes.iterparse_tel import import_tel
import os
from tests.translucent_event_log.objects.tel.importer.xes.utils import log_to_tel
from pm4py.algo.discovery.alpha import factory as alpha_miner
from tests.translucent_event_log.objects.tel import utils
from pm4py.visualization.transition_system import factory as vis_factory
from itertools import combinations

input_file_path = os.path.join("input_data", "running-example.xes")
log = import_tel(input_file_path)
nett, initial_marking, final_marking = alpha_miner.apply(log)

tel = log_to_tel(nett, initial_marking, final_marking, log)
auto = utils.discover_annotated_automaton(tel)

gviz = vis_factory.apply(auto)
vis_factory.view(gviz)