Source code for pm4py.statistics.passed_time.log.variants.pre

    This file is part of PM4Py (More Info:

    PM4Py is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    PM4Py is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with PM4Py.  If not, see <>.
from pm4py.algo.discovery.dfg.variants import native, performance
from typing import Optional, Dict, Any, Union, Tuple, List, Set
from pm4py.objects.log.obj import EventLog
from pm4py.objects.conversion.log import converter as log_converter

[docs]def apply(log: EventLog, activity: str, parameters: Optional[Dict[Any, Any]] = None) -> Dict[str, Any]: """ Gets the time passed from each preceding activity Parameters ------------- log Log activity Activity that we are considering parameters Possible parameters of the algorithm Returns ------------- dictio Dictionary containing a 'pre' key with the list of aggregates times from each preceding activity to the given activity """ if parameters is None: parameters = {} log = log_converter.apply(log, variant=log_converter.Variants.TO_EVENT_LOG, parameters=parameters) dfg_frequency = native.native(log, parameters=parameters) dfg_performance = performance.performance(log, parameters=parameters) pre = [] sum_perf_pre = 0.0 sum_acti_pre = 0.0 for entry in dfg_performance.keys(): if entry[1] == activity: pre.append([entry[0], float(dfg_performance[entry]), int(dfg_frequency[entry])]) sum_perf_pre = sum_perf_pre + float(dfg_performance[entry]) * float(dfg_frequency[entry]) sum_acti_pre = sum_acti_pre + float(dfg_frequency[entry]) perf_acti_pre = 0.0 if sum_acti_pre > 0: perf_acti_pre = sum_perf_pre / sum_acti_pre return {"pre": pre, "pre_avg_perf": perf_acti_pre}