Generated by Cython 3.1.2
Yellow lines hint at Python interaction.
Click on a line that starts with a "+" to see the C code that Cython generated for it.
Raw output: mdl_score.cpp
+001: '''
__pyx_t_3 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); if (PyDict_SetItem(__pyx_mstate_global->__pyx_d, __pyx_mstate_global->__pyx_n_u_test, __pyx_t_3) < 0) __PYX_ERR(0, 1, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
002: This file is part of Prolothar-Process-Discovery (More Info: https://github.com/shs-it/prolothar-process-discovery).
003:
004: Prolothar-Process-Discovery is free software: you can redistribute it and/or modify
005: it under the terms of the GNU General Public License as published by
006: the Free Software Foundation, either version 3 of the License, or
007: (at your option) any later version.
008:
009: Prolothar-Process-Discovery is distributed in the hope that it will be useful,
010: but WITHOUT ANY WARRANTY; without even the implied warranty of
011: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
012: GNU General Public License for more details.
013:
014: You should have received a copy of the GNU General Public License
015: along with Prolothar-Process-Discovery. If not, see <https://www.gnu.org/licenses/>.
016: '''
017:
018: from prolothar_common.models.dfg.node cimport Node
+019: from prolothar_common.models.eventlog.eventlog import EventLog
__pyx_t_2 = __Pyx_PyList_Pack(1, __pyx_mstate_global->__pyx_n_u_EventLog); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 19, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = __Pyx_Import(__pyx_mstate_global->__pyx_n_u_prolothar_common_models_eventlog, __pyx_t_2, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 19, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_EventLog); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 19, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_mstate_global->__pyx_d, __pyx_mstate_global->__pyx_n_u_EventLog, __pyx_t_2) < 0) __PYX_ERR(0, 19, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
020:
021: from prolothar_common cimport mdl_utils
022:
023: from prolothar_process_discovery.discovery.proseqo.pattern.pattern cimport Pattern
+024: from prolothar_process_discovery.discovery.proseqo.pattern_dfg import NR_OF_PATTERN_TYPES_WITH_SINGLETON
__pyx_t_3 = __Pyx_PyList_Pack(1, __pyx_mstate_global->__pyx_n_u_NR_OF_PATTERN_TYPES_WITH_SINGLET); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 24, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_2 = __Pyx_Import(__pyx_mstate_global->__pyx_n_u_prolothar_process_discovery_disc, __pyx_t_3, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 24, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_ImportFrom(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_NR_OF_PATTERN_TYPES_WITH_SINGLET); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 24, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); if (PyDict_SetItem(__pyx_mstate_global->__pyx_d, __pyx_mstate_global->__pyx_n_u_NR_OF_PATTERN_TYPES_WITH_SINGLET, __pyx_t_3) < 0) __PYX_ERR(0, 24, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
025: from prolothar_process_discovery.discovery.proseqo.greedy_cover cimport compute_cover
026: from prolothar_process_discovery.discovery.proseqo.cover cimport Cover
+027: from prolothar_process_discovery.discovery.proseqo.dfg_abstraction.candidates.candidates import Candidate
__pyx_t_2 = __Pyx_PyList_Pack(1, __pyx_mstate_global->__pyx_n_u_Candidate); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 27, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = __Pyx_Import(__pyx_mstate_global->__pyx_n_u_prolothar_process_discovery_disc_2, __pyx_t_2, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 27, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_Candidate); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 27, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_mstate_global->__pyx_d, __pyx_mstate_global->__pyx_n_u_Candidate, __pyx_t_2) < 0) __PYX_ERR(0, 27, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
028:
029: from libcpp.cmath cimport log2
030:
+031: cpdef float compute_mdl_score(object log, PatternDfg dfg, set activity_set=None, bint verbose=False):
static PyObject *__pyx_pw_27prolothar_process_discovery_9discovery_7proseqo_9mdl_score_1compute_mdl_score(PyObject *__pyx_self,
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
); /*proto*/
static float __pyx_f_27prolothar_process_discovery_9discovery_7proseqo_9mdl_score_compute_mdl_score(PyObject *__pyx_v_log, struct __pyx_obj_27prolothar_process_discovery_9discovery_7proseqo_11pattern_dfg_PatternDfg *__pyx_v_dfg, CYTHON_UNUSED int __pyx_skip_dispatch, struct __pyx_opt_args_27prolothar_process_discovery_9discovery_7proseqo_9mdl_score_compute_mdl_score *__pyx_optional_args) {
PyObject *__pyx_v_activity_set = ((PyObject*)Py_None);
int __pyx_v_verbose = ((int)0);
struct __pyx_obj_27prolothar_process_discovery_9discovery_7proseqo_5cover_Cover *__pyx_v_cover = 0;
float __pyx_r;
if (__pyx_optional_args) {
if (__pyx_optional_args->__pyx_n > 0) {
__pyx_v_activity_set = __pyx_optional_args->activity_set;
if (__pyx_optional_args->__pyx_n > 1) {
__pyx_v_verbose = __pyx_optional_args->verbose;
}
}
}
/* … */
/* function exit code */
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_1);
__Pyx_XDECREF(__pyx_t_2);
__Pyx_AddTraceback("prolothar_process_discovery.discovery.proseqo.mdl_score.compute_mdl_score", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = -1;
__pyx_L0:;
__Pyx_XDECREF((PyObject *)__pyx_v_cover);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* Python wrapper */
static PyObject *__pyx_pw_27prolothar_process_discovery_9discovery_7proseqo_9mdl_score_1compute_mdl_score(PyObject *__pyx_self,
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
); /*proto*/
PyDoc_STRVAR(__pyx_doc_27prolothar_process_discovery_9discovery_7proseqo_9mdl_score_compute_mdl_score, "computes the minimum description length of the log and a model (dfg).\n this is MDL(PatternDfg) + MDL(Log|PatternDfg) = MDL(PatternDfg) + MDL(Cover).\n this means a cover is computed for computing the MDL.\n ");
static PyMethodDef __pyx_mdef_27prolothar_process_discovery_9discovery_7proseqo_9mdl_score_1compute_mdl_score = {"compute_mdl_score", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_27prolothar_process_discovery_9discovery_7proseqo_9mdl_score_1compute_mdl_score, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_27prolothar_process_discovery_9discovery_7proseqo_9mdl_score_compute_mdl_score};
static PyObject *__pyx_pw_27prolothar_process_discovery_9discovery_7proseqo_9mdl_score_1compute_mdl_score(PyObject *__pyx_self,
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
) {
PyObject *__pyx_v_log = 0;
struct __pyx_obj_27prolothar_process_discovery_9discovery_7proseqo_11pattern_dfg_PatternDfg *__pyx_v_dfg = 0;
PyObject *__pyx_v_activity_set = 0;
int __pyx_v_verbose;
#if !CYTHON_METH_FASTCALL
CYTHON_UNUSED Py_ssize_t __pyx_nargs;
#endif
CYTHON_UNUSED PyObject *const *__pyx_kwvalues;
PyObject *__pyx_r = 0;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("compute_mdl_score (wrapper)", 0);
#if !CYTHON_METH_FASTCALL
#if CYTHON_ASSUME_SAFE_SIZE
__pyx_nargs = PyTuple_GET_SIZE(__pyx_args);
#else
__pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL;
#endif
#endif
__pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs);
{
PyObject ** const __pyx_pyargnames[] = {&__pyx_mstate_global->__pyx_n_u_log,&__pyx_mstate_global->__pyx_n_u_dfg,&__pyx_mstate_global->__pyx_n_u_activity_set,&__pyx_mstate_global->__pyx_n_u_verbose,0};
PyObject* values[4] = {0,0,0,0};
const Py_ssize_t __pyx_kwds_len = (__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0;
if (unlikely(__pyx_kwds_len) < 0) __PYX_ERR(0, 31, __pyx_L3_error)
if (__pyx_kwds_len > 0) {
switch (__pyx_nargs) {
case 4:
values[3] = __Pyx_ArgRef_FASTCALL(__pyx_args, 3);
if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[3])) __PYX_ERR(0, 31, __pyx_L3_error)
CYTHON_FALLTHROUGH;
case 3:
values[2] = __Pyx_ArgRef_FASTCALL(__pyx_args, 2);
if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[2])) __PYX_ERR(0, 31, __pyx_L3_error)
CYTHON_FALLTHROUGH;
case 2:
values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1);
if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 31, __pyx_L3_error)
CYTHON_FALLTHROUGH;
case 1:
values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 31, __pyx_L3_error)
CYTHON_FALLTHROUGH;
case 0: break;
default: goto __pyx_L5_argtuple_error;
}
const Py_ssize_t kwd_pos_args = __pyx_nargs;
if (__Pyx_ParseKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values, kwd_pos_args, __pyx_kwds_len, "compute_mdl_score", 0) < 0) __PYX_ERR(0, 31, __pyx_L3_error)
if (!values[2]) values[2] = __Pyx_NewRef(((PyObject*)Py_None));
for (Py_ssize_t i = __pyx_nargs; i < 2; i++) {
if (unlikely(!values[i])) { __Pyx_RaiseArgtupleInvalid("compute_mdl_score", 0, 2, 4, i); __PYX_ERR(0, 31, __pyx_L3_error) }
}
} else {
switch (__pyx_nargs) {
case 4:
values[3] = __Pyx_ArgRef_FASTCALL(__pyx_args, 3);
if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[3])) __PYX_ERR(0, 31, __pyx_L3_error)
CYTHON_FALLTHROUGH;
case 3:
values[2] = __Pyx_ArgRef_FASTCALL(__pyx_args, 2);
if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[2])) __PYX_ERR(0, 31, __pyx_L3_error)
CYTHON_FALLTHROUGH;
case 2:
values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1);
if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 31, __pyx_L3_error)
values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 31, __pyx_L3_error)
break;
default: goto __pyx_L5_argtuple_error;
}
if (!values[2]) values[2] = __Pyx_NewRef(((PyObject*)Py_None));
}
__pyx_v_log = values[0];
__pyx_v_dfg = ((struct __pyx_obj_27prolothar_process_discovery_9discovery_7proseqo_11pattern_dfg_PatternDfg *)values[1]);
__pyx_v_activity_set = ((PyObject*)values[2]);
if (values[3]) {
__pyx_v_verbose = __Pyx_PyObject_IsTrue(values[3]); if (unlikely((__pyx_v_verbose == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 31, __pyx_L3_error)
} else {
__pyx_v_verbose = ((int)0);
}
}
goto __pyx_L6_skip;
__pyx_L5_argtuple_error:;
__Pyx_RaiseArgtupleInvalid("compute_mdl_score", 0, 2, 4, __pyx_nargs); __PYX_ERR(0, 31, __pyx_L3_error)
__pyx_L6_skip:;
goto __pyx_L4_argument_unpacking_done;
__pyx_L3_error:;
for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
Py_XDECREF(values[__pyx_temp]);
}
__Pyx_AddTraceback("prolothar_process_discovery.discovery.proseqo.mdl_score.compute_mdl_score", __pyx_clineno, __pyx_lineno, __pyx_filename);
__Pyx_RefNannyFinishContext();
return NULL;
__pyx_L4_argument_unpacking_done:;
if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_dfg), __pyx_mstate_global->__pyx_ptype_27prolothar_process_discovery_9discovery_7proseqo_11pattern_dfg_PatternDfg, 1, "dfg", 0))) __PYX_ERR(0, 31, __pyx_L1_error)
if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_activity_set), (&PySet_Type), 1, "activity_set", 1))) __PYX_ERR(0, 31, __pyx_L1_error)
__pyx_r = __pyx_pf_27prolothar_process_discovery_9discovery_7proseqo_9mdl_score_compute_mdl_score(__pyx_self, __pyx_v_log, __pyx_v_dfg, __pyx_v_activity_set, __pyx_v_verbose);
/* function exit code */
goto __pyx_L0;
__pyx_L1_error:;
__pyx_r = NULL;
for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
Py_XDECREF(values[__pyx_temp]);
}
goto __pyx_L7_cleaned_up;
__pyx_L0:;
for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
Py_XDECREF(values[__pyx_temp]);
}
__pyx_L7_cleaned_up:;
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
static PyObject *__pyx_pf_27prolothar_process_discovery_9discovery_7proseqo_9mdl_score_compute_mdl_score(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_log, struct __pyx_obj_27prolothar_process_discovery_9discovery_7proseqo_11pattern_dfg_PatternDfg *__pyx_v_dfg, PyObject *__pyx_v_activity_set, int __pyx_v_verbose) {
PyObject *__pyx_r = NULL;
__Pyx_XDECREF(__pyx_r);
__pyx_t_2.__pyx_n = 2;
__pyx_t_2.activity_set = __pyx_v_activity_set;
__pyx_t_2.verbose = __pyx_v_verbose;
__pyx_t_1 = __pyx_f_27prolothar_process_discovery_9discovery_7proseqo_9mdl_score_compute_mdl_score(__pyx_v_log, __pyx_v_dfg, 1, &__pyx_t_2); if (unlikely(__pyx_t_1 == ((float)-1) && PyErr_Occurred())) __PYX_ERR(0, 31, __pyx_L1_error)
__pyx_t_3 = PyFloat_FromDouble(__pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 31, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_3);
__pyx_r = __pyx_t_3;
__pyx_t_3 = 0;
goto __pyx_L0;
/* function exit code */
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_3);
__Pyx_AddTraceback("prolothar_process_discovery.discovery.proseqo.mdl_score.compute_mdl_score", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = NULL;
__pyx_L0:;
__Pyx_XGIVEREF(__pyx_r);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* … */
__pyx_t_3 = __Pyx_CyFunction_New(&__pyx_mdef_27prolothar_process_discovery_9discovery_7proseqo_9mdl_score_1compute_mdl_score, 0, __pyx_mstate_global->__pyx_n_u_compute_mdl_score, NULL, __pyx_mstate_global->__pyx_n_u_prolothar_process_discovery_disc_3, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[0])); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 31, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_3);
__Pyx_CyFunction_SetDefaultsTuple(__pyx_t_3, __pyx_mstate_global->__pyx_tuple[0]);
if (PyDict_SetItem(__pyx_mstate_global->__pyx_d, __pyx_mstate_global->__pyx_n_u_compute_mdl_score, __pyx_t_3) < 0) __PYX_ERR(0, 31, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
/* … */
__pyx_mstate_global->__pyx_tuple[0] = PyTuple_Pack(2, Py_None, Py_False); if (unlikely(!__pyx_mstate_global->__pyx_tuple[0])) __PYX_ERR(0, 31, __pyx_L1_error)
__Pyx_GOTREF(__pyx_mstate_global->__pyx_tuple[0]);
__Pyx_GIVEREF(__pyx_mstate_global->__pyx_tuple[0]);
032: """computes the minimum description length of the log and a model (dfg).
033: this is MDL(PatternDfg) + MDL(Log|PatternDfg) = MDL(PatternDfg) + MDL(Cover).
034: this means a cover is computed for computing the MDL.
035: """
+036: cdef Cover cover = compute_cover(log.traces, dfg, store_patterns_in_pattern_stream=False, activity_set=activity_set)
__pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_log, __pyx_mstate_global->__pyx_n_u_traces); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 36, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (!(likely(PyList_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None) || __Pyx_RaiseUnexpectedTypeError("list", __pyx_t_1))) __PYX_ERR(0, 36, __pyx_L1_error) __pyx_t_3.__pyx_n = 2; __pyx_t_3.store_patterns_in_pattern_stream = 0; __pyx_t_3.activity_set = __pyx_v_activity_set; __pyx_t_2 = ((PyObject *)__pyx_f_27prolothar_process_discovery_9discovery_7proseqo_12greedy_cover_compute_cover(((PyObject*)__pyx_t_1), __pyx_v_dfg, 0, &__pyx_t_3)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 36, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_cover = ((struct __pyx_obj_27prolothar_process_discovery_9discovery_7proseqo_5cover_Cover *)__pyx_t_2); __pyx_t_2 = 0;
+037: return compute_mdl_score_given_cover(cover, log, dfg, verbose=verbose)
__pyx_t_5.__pyx_n = 1; __pyx_t_5.verbose = __pyx_v_verbose; __pyx_t_4 = __pyx_f_27prolothar_process_discovery_9discovery_7proseqo_9mdl_score_compute_mdl_score_given_cover(__pyx_v_cover, __pyx_v_log, __pyx_v_dfg, 0, &__pyx_t_5); if (unlikely(__pyx_t_4 == ((float)-1) && PyErr_Occurred())) __PYX_ERR(0, 37, __pyx_L1_error) __pyx_r = __pyx_t_4; goto __pyx_L0;
038:
+039: cpdef float compute_mdl_score_given_cover(Cover cover, object log, PatternDfg dfg, bint verbose = False):
static PyObject *__pyx_pw_27prolothar_process_discovery_9discovery_7proseqo_9mdl_score_3compute_mdl_score_given_cover(PyObject *__pyx_self,
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
); /*proto*/
static float __pyx_f_27prolothar_process_discovery_9discovery_7proseqo_9mdl_score_compute_mdl_score_given_cover(struct __pyx_obj_27prolothar_process_discovery_9discovery_7proseqo_5cover_Cover *__pyx_v_cover, PyObject *__pyx_v_log, struct __pyx_obj_27prolothar_process_discovery_9discovery_7proseqo_11pattern_dfg_PatternDfg *__pyx_v_dfg, CYTHON_UNUSED int __pyx_skip_dispatch, struct __pyx_opt_args_27prolothar_process_discovery_9discovery_7proseqo_9mdl_score_compute_mdl_score_given_cover *__pyx_optional_args) {
int __pyx_v_verbose = ((int)0);
float __pyx_v_mdl_score;
float __pyx_r;
if (__pyx_optional_args) {
if (__pyx_optional_args->__pyx_n > 0) {
__pyx_v_verbose = __pyx_optional_args->verbose;
}
}
/* … */
/* function exit code */
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_1);
__Pyx_AddTraceback("prolothar_process_discovery.discovery.proseqo.mdl_score.compute_mdl_score_given_cover", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = -1;
__pyx_L0:;
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* Python wrapper */
static PyObject *__pyx_pw_27prolothar_process_discovery_9discovery_7proseqo_9mdl_score_3compute_mdl_score_given_cover(PyObject *__pyx_self,
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
); /*proto*/
PyDoc_STRVAR(__pyx_doc_27prolothar_process_discovery_9discovery_7proseqo_9mdl_score_2compute_mdl_score_given_cover, "give same output as compute_mdl_score but with a precomputed cover");
static PyMethodDef __pyx_mdef_27prolothar_process_discovery_9discovery_7proseqo_9mdl_score_3compute_mdl_score_given_cover = {"compute_mdl_score_given_cover", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_27prolothar_process_discovery_9discovery_7proseqo_9mdl_score_3compute_mdl_score_given_cover, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_27prolothar_process_discovery_9discovery_7proseqo_9mdl_score_2compute_mdl_score_given_cover};
static PyObject *__pyx_pw_27prolothar_process_discovery_9discovery_7proseqo_9mdl_score_3compute_mdl_score_given_cover(PyObject *__pyx_self,
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
) {
struct __pyx_obj_27prolothar_process_discovery_9discovery_7proseqo_5cover_Cover *__pyx_v_cover = 0;
PyObject *__pyx_v_log = 0;
struct __pyx_obj_27prolothar_process_discovery_9discovery_7proseqo_11pattern_dfg_PatternDfg *__pyx_v_dfg = 0;
int __pyx_v_verbose;
#if !CYTHON_METH_FASTCALL
CYTHON_UNUSED Py_ssize_t __pyx_nargs;
#endif
CYTHON_UNUSED PyObject *const *__pyx_kwvalues;
PyObject *__pyx_r = 0;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("compute_mdl_score_given_cover (wrapper)", 0);
#if !CYTHON_METH_FASTCALL
#if CYTHON_ASSUME_SAFE_SIZE
__pyx_nargs = PyTuple_GET_SIZE(__pyx_args);
#else
__pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL;
#endif
#endif
__pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs);
{
PyObject ** const __pyx_pyargnames[] = {&__pyx_mstate_global->__pyx_n_u_cover,&__pyx_mstate_global->__pyx_n_u_log,&__pyx_mstate_global->__pyx_n_u_dfg,&__pyx_mstate_global->__pyx_n_u_verbose,0};
PyObject* values[4] = {0,0,0,0};
const Py_ssize_t __pyx_kwds_len = (__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0;
if (unlikely(__pyx_kwds_len) < 0) __PYX_ERR(0, 39, __pyx_L3_error)
if (__pyx_kwds_len > 0) {
switch (__pyx_nargs) {
case 4:
values[3] = __Pyx_ArgRef_FASTCALL(__pyx_args, 3);
if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[3])) __PYX_ERR(0, 39, __pyx_L3_error)
CYTHON_FALLTHROUGH;
case 3:
values[2] = __Pyx_ArgRef_FASTCALL(__pyx_args, 2);
if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[2])) __PYX_ERR(0, 39, __pyx_L3_error)
CYTHON_FALLTHROUGH;
case 2:
values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1);
if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 39, __pyx_L3_error)
CYTHON_FALLTHROUGH;
case 1:
values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 39, __pyx_L3_error)
CYTHON_FALLTHROUGH;
case 0: break;
default: goto __pyx_L5_argtuple_error;
}
const Py_ssize_t kwd_pos_args = __pyx_nargs;
if (__Pyx_ParseKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values, kwd_pos_args, __pyx_kwds_len, "compute_mdl_score_given_cover", 0) < 0) __PYX_ERR(0, 39, __pyx_L3_error)
for (Py_ssize_t i = __pyx_nargs; i < 3; i++) {
if (unlikely(!values[i])) { __Pyx_RaiseArgtupleInvalid("compute_mdl_score_given_cover", 0, 3, 4, i); __PYX_ERR(0, 39, __pyx_L3_error) }
}
} else {
switch (__pyx_nargs) {
case 4:
values[3] = __Pyx_ArgRef_FASTCALL(__pyx_args, 3);
if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[3])) __PYX_ERR(0, 39, __pyx_L3_error)
CYTHON_FALLTHROUGH;
case 3:
values[2] = __Pyx_ArgRef_FASTCALL(__pyx_args, 2);
if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[2])) __PYX_ERR(0, 39, __pyx_L3_error)
values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1);
if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 39, __pyx_L3_error)
values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 39, __pyx_L3_error)
break;
default: goto __pyx_L5_argtuple_error;
}
}
__pyx_v_cover = ((struct __pyx_obj_27prolothar_process_discovery_9discovery_7proseqo_5cover_Cover *)values[0]);
__pyx_v_log = values[1];
__pyx_v_dfg = ((struct __pyx_obj_27prolothar_process_discovery_9discovery_7proseqo_11pattern_dfg_PatternDfg *)values[2]);
if (values[3]) {
__pyx_v_verbose = __Pyx_PyObject_IsTrue(values[3]); if (unlikely((__pyx_v_verbose == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 39, __pyx_L3_error)
} else {
__pyx_v_verbose = ((int)0);
}
}
goto __pyx_L6_skip;
__pyx_L5_argtuple_error:;
__Pyx_RaiseArgtupleInvalid("compute_mdl_score_given_cover", 0, 3, 4, __pyx_nargs); __PYX_ERR(0, 39, __pyx_L3_error)
__pyx_L6_skip:;
goto __pyx_L4_argument_unpacking_done;
__pyx_L3_error:;
for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
Py_XDECREF(values[__pyx_temp]);
}
__Pyx_AddTraceback("prolothar_process_discovery.discovery.proseqo.mdl_score.compute_mdl_score_given_cover", __pyx_clineno, __pyx_lineno, __pyx_filename);
__Pyx_RefNannyFinishContext();
return NULL;
__pyx_L4_argument_unpacking_done:;
if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_cover), __pyx_mstate_global->__pyx_ptype_27prolothar_process_discovery_9discovery_7proseqo_5cover_Cover, 1, "cover", 0))) __PYX_ERR(0, 39, __pyx_L1_error)
if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_dfg), __pyx_mstate_global->__pyx_ptype_27prolothar_process_discovery_9discovery_7proseqo_11pattern_dfg_PatternDfg, 1, "dfg", 0))) __PYX_ERR(0, 39, __pyx_L1_error)
__pyx_r = __pyx_pf_27prolothar_process_discovery_9discovery_7proseqo_9mdl_score_2compute_mdl_score_given_cover(__pyx_self, __pyx_v_cover, __pyx_v_log, __pyx_v_dfg, __pyx_v_verbose);
/* function exit code */
goto __pyx_L0;
__pyx_L1_error:;
__pyx_r = NULL;
for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
Py_XDECREF(values[__pyx_temp]);
}
goto __pyx_L7_cleaned_up;
__pyx_L0:;
for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
Py_XDECREF(values[__pyx_temp]);
}
__pyx_L7_cleaned_up:;
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
static PyObject *__pyx_pf_27prolothar_process_discovery_9discovery_7proseqo_9mdl_score_2compute_mdl_score_given_cover(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_27prolothar_process_discovery_9discovery_7proseqo_5cover_Cover *__pyx_v_cover, PyObject *__pyx_v_log, struct __pyx_obj_27prolothar_process_discovery_9discovery_7proseqo_11pattern_dfg_PatternDfg *__pyx_v_dfg, int __pyx_v_verbose) {
PyObject *__pyx_r = NULL;
__Pyx_XDECREF(__pyx_r);
__pyx_t_2.__pyx_n = 1;
__pyx_t_2.verbose = __pyx_v_verbose;
__pyx_t_1 = __pyx_f_27prolothar_process_discovery_9discovery_7proseqo_9mdl_score_compute_mdl_score_given_cover(__pyx_v_cover, __pyx_v_log, __pyx_v_dfg, 1, &__pyx_t_2); if (unlikely(__pyx_t_1 == ((float)-1) && PyErr_Occurred())) __PYX_ERR(0, 39, __pyx_L1_error)
__pyx_t_3 = PyFloat_FromDouble(__pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 39, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_3);
__pyx_r = __pyx_t_3;
__pyx_t_3 = 0;
goto __pyx_L0;
/* function exit code */
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_3);
__Pyx_AddTraceback("prolothar_process_discovery.discovery.proseqo.mdl_score.compute_mdl_score_given_cover", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = NULL;
__pyx_L0:;
__Pyx_XGIVEREF(__pyx_r);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* … */
__pyx_t_3 = __Pyx_CyFunction_New(&__pyx_mdef_27prolothar_process_discovery_9discovery_7proseqo_9mdl_score_3compute_mdl_score_given_cover, 0, __pyx_mstate_global->__pyx_n_u_compute_mdl_score_given_cover, NULL, __pyx_mstate_global->__pyx_n_u_prolothar_process_discovery_disc_3, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[1])); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 39, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_3);
__Pyx_CyFunction_SetDefaultsTuple(__pyx_t_3, __pyx_mstate_global->__pyx_tuple[1]);
if (PyDict_SetItem(__pyx_mstate_global->__pyx_d, __pyx_mstate_global->__pyx_n_u_compute_mdl_score_given_cover, __pyx_t_3) < 0) __PYX_ERR(0, 39, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
/* … */
__pyx_mstate_global->__pyx_tuple[1] = PyTuple_Pack(1, Py_False); if (unlikely(!__pyx_mstate_global->__pyx_tuple[1])) __PYX_ERR(0, 39, __pyx_L1_error)
__Pyx_GOTREF(__pyx_mstate_global->__pyx_tuple[1]);
__Pyx_GIVEREF(__pyx_mstate_global->__pyx_tuple[1]);
040: """give same output as compute_mdl_score but with a precomputed cover"""
+041: cdef float mdl_score = compute_encoded_length_of_pattern_dfg(
__pyx_t_3.__pyx_n = 1; __pyx_t_3.verbose = __pyx_v_verbose; __pyx_t_2 = __pyx_f_27prolothar_process_discovery_9discovery_7proseqo_9mdl_score_compute_encoded_length_of_pattern_dfg(__pyx_v_dfg, ((PyObject*)__pyx_t_1), 0, &__pyx_t_3); if (unlikely(__pyx_t_2 == ((float)-1) && PyErr_Occurred())) __PYX_ERR(0, 41, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_mdl_score = __pyx_t_2;
+042: dfg, cover.get_activity_set(), verbose=verbose)
__pyx_t_1 = ((struct __pyx_vtabstruct_27prolothar_process_discovery_9discovery_7proseqo_5cover_Cover *)__pyx_v_cover->__pyx_vtab)->get_activity_set(__pyx_v_cover, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 42, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1);
+043: mdl_score += cover.get_encoded_length_of_cover(log, verbose=verbose)
__pyx_t_4.__pyx_n = 1;
__pyx_t_4.verbose = __pyx_v_verbose;
__pyx_t_2 = ((struct __pyx_vtabstruct_27prolothar_process_discovery_9discovery_7proseqo_5cover_Cover *)__pyx_v_cover->__pyx_vtab)->get_encoded_length_of_cover(__pyx_v_cover, __pyx_v_log, 0, &__pyx_t_4); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 43, __pyx_L1_error)
__pyx_v_mdl_score = (__pyx_v_mdl_score + __pyx_t_2);
+044: return mdl_score
__pyx_r = __pyx_v_mdl_score; goto __pyx_L0;
045:
+046: cpdef float compute_encoded_length_of_pattern_dfg(PatternDfg pattern_dfg, frozenset activity_set, bint verbose=False):
static PyObject *__pyx_pw_27prolothar_process_discovery_9discovery_7proseqo_9mdl_score_5compute_encoded_length_of_pattern_dfg(PyObject *__pyx_self,
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
); /*proto*/
static float __pyx_f_27prolothar_process_discovery_9discovery_7proseqo_9mdl_score_compute_encoded_length_of_pattern_dfg(struct __pyx_obj_27prolothar_process_discovery_9discovery_7proseqo_11pattern_dfg_PatternDfg *__pyx_v_pattern_dfg, PyObject *__pyx_v_activity_set, CYTHON_UNUSED int __pyx_skip_dispatch, struct __pyx_opt_args_27prolothar_process_discovery_9discovery_7proseqo_9mdl_score_compute_encoded_length_of_pattern_dfg *__pyx_optional_args) {
int __pyx_v_verbose = ((int)0);
PyObject *__pyx_v_model_activity_set = 0;
float __pyx_v_encoded_length;
PyObject *__pyx_v_node = NULL;
PyObject *__pyx_v_code_length_of_pattern = NULL;
CYTHON_UNUSED PyObject *__pyx_v_available_activities_for_encoding = NULL;
int __pyx_v_max_nr_of_edges;
float __pyx_r;
if (__pyx_optional_args) {
if (__pyx_optional_args->__pyx_n > 0) {
__pyx_v_verbose = __pyx_optional_args->verbose;
}
}
__Pyx_INCREF(__pyx_v_activity_set);
/* … */
/* function exit code */
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_1);
__Pyx_XDECREF(__pyx_t_7);
__Pyx_XDECREF(__pyx_t_11);
__Pyx_XDECREF(__pyx_t_12);
__Pyx_XDECREF(__pyx_t_14);
__Pyx_AddTraceback("prolothar_process_discovery.discovery.proseqo.mdl_score.compute_encoded_length_of_pattern_dfg", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = -1;
__pyx_L0:;
__Pyx_XDECREF(__pyx_v_model_activity_set);
__Pyx_XDECREF(__pyx_v_node);
__Pyx_XDECREF(__pyx_v_code_length_of_pattern);
__Pyx_XDECREF(__pyx_v_available_activities_for_encoding);
__Pyx_XDECREF(__pyx_v_activity_set);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* Python wrapper */
static PyObject *__pyx_pw_27prolothar_process_discovery_9discovery_7proseqo_9mdl_score_5compute_encoded_length_of_pattern_dfg(PyObject *__pyx_self,
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
); /*proto*/
PyDoc_STRVAR(__pyx_doc_27prolothar_process_discovery_9discovery_7proseqo_9mdl_score_4compute_encoded_length_of_pattern_dfg, "computes the model cost (cost of the pattern_dfg)");
static PyMethodDef __pyx_mdef_27prolothar_process_discovery_9discovery_7proseqo_9mdl_score_5compute_encoded_length_of_pattern_dfg = {"compute_encoded_length_of_pattern_dfg", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_27prolothar_process_discovery_9discovery_7proseqo_9mdl_score_5compute_encoded_length_of_pattern_dfg, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_27prolothar_process_discovery_9discovery_7proseqo_9mdl_score_4compute_encoded_length_of_pattern_dfg};
static PyObject *__pyx_pw_27prolothar_process_discovery_9discovery_7proseqo_9mdl_score_5compute_encoded_length_of_pattern_dfg(PyObject *__pyx_self,
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
) {
struct __pyx_obj_27prolothar_process_discovery_9discovery_7proseqo_11pattern_dfg_PatternDfg *__pyx_v_pattern_dfg = 0;
PyObject *__pyx_v_activity_set = 0;
int __pyx_v_verbose;
#if !CYTHON_METH_FASTCALL
CYTHON_UNUSED Py_ssize_t __pyx_nargs;
#endif
CYTHON_UNUSED PyObject *const *__pyx_kwvalues;
PyObject *__pyx_r = 0;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("compute_encoded_length_of_pattern_dfg (wrapper)", 0);
#if !CYTHON_METH_FASTCALL
#if CYTHON_ASSUME_SAFE_SIZE
__pyx_nargs = PyTuple_GET_SIZE(__pyx_args);
#else
__pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL;
#endif
#endif
__pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs);
{
PyObject ** const __pyx_pyargnames[] = {&__pyx_mstate_global->__pyx_n_u_pattern_dfg,&__pyx_mstate_global->__pyx_n_u_activity_set,&__pyx_mstate_global->__pyx_n_u_verbose,0};
PyObject* values[3] = {0,0,0};
const Py_ssize_t __pyx_kwds_len = (__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0;
if (unlikely(__pyx_kwds_len) < 0) __PYX_ERR(0, 46, __pyx_L3_error)
if (__pyx_kwds_len > 0) {
switch (__pyx_nargs) {
case 3:
values[2] = __Pyx_ArgRef_FASTCALL(__pyx_args, 2);
if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[2])) __PYX_ERR(0, 46, __pyx_L3_error)
CYTHON_FALLTHROUGH;
case 2:
values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1);
if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 46, __pyx_L3_error)
CYTHON_FALLTHROUGH;
case 1:
values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 46, __pyx_L3_error)
CYTHON_FALLTHROUGH;
case 0: break;
default: goto __pyx_L5_argtuple_error;
}
const Py_ssize_t kwd_pos_args = __pyx_nargs;
if (__Pyx_ParseKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values, kwd_pos_args, __pyx_kwds_len, "compute_encoded_length_of_pattern_dfg", 0) < 0) __PYX_ERR(0, 46, __pyx_L3_error)
for (Py_ssize_t i = __pyx_nargs; i < 2; i++) {
if (unlikely(!values[i])) { __Pyx_RaiseArgtupleInvalid("compute_encoded_length_of_pattern_dfg", 0, 2, 3, i); __PYX_ERR(0, 46, __pyx_L3_error) }
}
} else {
switch (__pyx_nargs) {
case 3:
values[2] = __Pyx_ArgRef_FASTCALL(__pyx_args, 2);
if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[2])) __PYX_ERR(0, 46, __pyx_L3_error)
CYTHON_FALLTHROUGH;
case 2:
values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1);
if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 46, __pyx_L3_error)
values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 46, __pyx_L3_error)
break;
default: goto __pyx_L5_argtuple_error;
}
}
__pyx_v_pattern_dfg = ((struct __pyx_obj_27prolothar_process_discovery_9discovery_7proseqo_11pattern_dfg_PatternDfg *)values[0]);
__pyx_v_activity_set = ((PyObject*)values[1]);
if (values[2]) {
__pyx_v_verbose = __Pyx_PyObject_IsTrue(values[2]); if (unlikely((__pyx_v_verbose == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 46, __pyx_L3_error)
} else {
__pyx_v_verbose = ((int)0);
}
}
goto __pyx_L6_skip;
__pyx_L5_argtuple_error:;
__Pyx_RaiseArgtupleInvalid("compute_encoded_length_of_pattern_dfg", 0, 2, 3, __pyx_nargs); __PYX_ERR(0, 46, __pyx_L3_error)
__pyx_L6_skip:;
goto __pyx_L4_argument_unpacking_done;
__pyx_L3_error:;
for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
Py_XDECREF(values[__pyx_temp]);
}
__Pyx_AddTraceback("prolothar_process_discovery.discovery.proseqo.mdl_score.compute_encoded_length_of_pattern_dfg", __pyx_clineno, __pyx_lineno, __pyx_filename);
__Pyx_RefNannyFinishContext();
return NULL;
__pyx_L4_argument_unpacking_done:;
if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_pattern_dfg), __pyx_mstate_global->__pyx_ptype_27prolothar_process_discovery_9discovery_7proseqo_11pattern_dfg_PatternDfg, 1, "pattern_dfg", 0))) __PYX_ERR(0, 46, __pyx_L1_error)
if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_activity_set), (&PyFrozenSet_Type), 1, "activity_set", 1))) __PYX_ERR(0, 46, __pyx_L1_error)
__pyx_r = __pyx_pf_27prolothar_process_discovery_9discovery_7proseqo_9mdl_score_4compute_encoded_length_of_pattern_dfg(__pyx_self, __pyx_v_pattern_dfg, __pyx_v_activity_set, __pyx_v_verbose);
/* function exit code */
goto __pyx_L0;
__pyx_L1_error:;
__pyx_r = NULL;
for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
Py_XDECREF(values[__pyx_temp]);
}
goto __pyx_L7_cleaned_up;
__pyx_L0:;
for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
Py_XDECREF(values[__pyx_temp]);
}
__pyx_L7_cleaned_up:;
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
static PyObject *__pyx_pf_27prolothar_process_discovery_9discovery_7proseqo_9mdl_score_4compute_encoded_length_of_pattern_dfg(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_27prolothar_process_discovery_9discovery_7proseqo_11pattern_dfg_PatternDfg *__pyx_v_pattern_dfg, PyObject *__pyx_v_activity_set, int __pyx_v_verbose) {
PyObject *__pyx_r = NULL;
__Pyx_XDECREF(__pyx_r);
__pyx_t_2.__pyx_n = 1;
__pyx_t_2.verbose = __pyx_v_verbose;
__pyx_t_1 = __pyx_f_27prolothar_process_discovery_9discovery_7proseqo_9mdl_score_compute_encoded_length_of_pattern_dfg(__pyx_v_pattern_dfg, __pyx_v_activity_set, 1, &__pyx_t_2); if (unlikely(__pyx_t_1 == ((float)-1) && PyErr_Occurred())) __PYX_ERR(0, 46, __pyx_L1_error)
__pyx_t_3 = PyFloat_FromDouble(__pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 46, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_3);
__pyx_r = __pyx_t_3;
__pyx_t_3 = 0;
goto __pyx_L0;
/* function exit code */
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_3);
__Pyx_AddTraceback("prolothar_process_discovery.discovery.proseqo.mdl_score.compute_encoded_length_of_pattern_dfg", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = NULL;
__pyx_L0:;
__Pyx_XGIVEREF(__pyx_r);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* … */
__pyx_t_3 = __Pyx_CyFunction_New(&__pyx_mdef_27prolothar_process_discovery_9discovery_7proseqo_9mdl_score_5compute_encoded_length_of_pattern_dfg, 0, __pyx_mstate_global->__pyx_n_u_compute_encoded_length_of_patter, NULL, __pyx_mstate_global->__pyx_n_u_prolothar_process_discovery_disc_3, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[2])); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 46, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_3);
__Pyx_CyFunction_SetDefaultsTuple(__pyx_t_3, __pyx_mstate_global->__pyx_tuple[2]);
if (PyDict_SetItem(__pyx_mstate_global->__pyx_d, __pyx_mstate_global->__pyx_n_u_compute_encoded_length_of_patter, __pyx_t_3) < 0) __PYX_ERR(0, 46, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
/* … */
__pyx_mstate_global->__pyx_tuple[2] = PyTuple_Pack(1, Py_False); if (unlikely(!__pyx_mstate_global->__pyx_tuple[2])) __PYX_ERR(0, 46, __pyx_L1_error)
__Pyx_GOTREF(__pyx_mstate_global->__pyx_tuple[2]);
__Pyx_GIVEREF(__pyx_mstate_global->__pyx_tuple[2]);
047: """computes the model cost (cost of the pattern_dfg)"""
+048: cdef set model_activity_set = pattern_dfg.compute_activity_set()
__pyx_t_1 = ((struct __pyx_vtabstruct_27prolothar_process_discovery_9discovery_7proseqo_11pattern_dfg_PatternDfg *)__pyx_v_pattern_dfg->__pyx_base.__pyx_vtab)->compute_activity_set(__pyx_v_pattern_dfg, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 48, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_model_activity_set = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0;
049: #this only happens in rare cases when the model is known and contains
050: #activities that are not present in the sample log
+051: if len(model_activity_set) > len(activity_set):
if (unlikely(__pyx_v_model_activity_set == Py_None)) {
PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
__PYX_ERR(0, 51, __pyx_L1_error)
}
__pyx_t_2 = __Pyx_PySet_GET_SIZE(__pyx_v_model_activity_set); if (unlikely(__pyx_t_2 == ((Py_ssize_t)-1))) __PYX_ERR(0, 51, __pyx_L1_error)
if (unlikely(__pyx_v_activity_set == Py_None)) {
PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
__PYX_ERR(0, 51, __pyx_L1_error)
}
__pyx_t_3 = __Pyx_PySet_GET_SIZE(__pyx_v_activity_set); if (unlikely(__pyx_t_3 == ((Py_ssize_t)-1))) __PYX_ERR(0, 51, __pyx_L1_error)
__pyx_t_4 = (__pyx_t_2 > __pyx_t_3);
if (__pyx_t_4) {
/* … */
}
+052: activity_set = model_activity_set
__pyx_t_1 = __pyx_v_model_activity_set;
__Pyx_INCREF(__pyx_t_1);
if (!(likely(PyFrozenSet_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None) || __Pyx_RaiseUnexpectedTypeError("frozenset", __pyx_t_1))) __PYX_ERR(0, 52, __pyx_L1_error)
__Pyx_DECREF_SET(__pyx_v_activity_set, ((PyObject*)__pyx_t_1));
__pyx_t_1 = 0;
053: #number of activities
+054: cdef float encoded_length = mdl_utils.L_N(len(activity_set))
if (unlikely(__pyx_v_activity_set == Py_None)) {
PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
__PYX_ERR(0, 54, __pyx_L1_error)
}
__pyx_t_3 = __Pyx_PySet_GET_SIZE(__pyx_v_activity_set); if (unlikely(__pyx_t_3 == ((Py_ssize_t)-1))) __PYX_ERR(0, 54, __pyx_L1_error)
__pyx_t_5 = __pyx_f_16prolothar_common_9mdl_utils_L_N(__pyx_t_3, 0); if (unlikely(__pyx_t_5 == ((double)0.0))) __PYX_ERR(0, 54, __pyx_L1_error)
__pyx_v_encoded_length = __pyx_t_5;
055:
056: #number of nodes => nr of activities is an upper bound, since we do not allow
057: #activities to occur in multiple patterns
+058: encoded_length += log2(<float>len(activity_set))
if (unlikely(__pyx_v_activity_set == Py_None)) {
PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
__PYX_ERR(0, 58, __pyx_L1_error)
}
__pyx_t_3 = __Pyx_PySet_GET_SIZE(__pyx_v_activity_set); if (unlikely(__pyx_t_3 == ((Py_ssize_t)-1))) __PYX_ERR(0, 58, __pyx_L1_error)
try {
__pyx_t_6 = std::log2(((float)__pyx_t_3));
} catch(...) {
__Pyx_CppExn2PyErr();
__PYX_ERR(0, 58, __pyx_L1_error)
}
__pyx_v_encoded_length = (__pyx_v_encoded_length + __pyx_t_6);
059: #encode the individual patterns
+060: for node in pattern_dfg.get_nodes():
__pyx_t_7 = ((PyObject *)__pyx_v_pattern_dfg); __Pyx_INCREF(__pyx_t_7); __pyx_t_8 = 0; { PyObject *__pyx_callargs[2] = {__pyx_t_7, NULL}; __pyx_t_1 = __Pyx_PyObject_FastCallMethod(__pyx_mstate_global->__pyx_n_u_get_nodes, __pyx_callargs+__pyx_t_8, (1-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET)); __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 60, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); } if (likely(PyList_CheckExact(__pyx_t_1)) || PyTuple_CheckExact(__pyx_t_1)) { __pyx_t_7 = __pyx_t_1; __Pyx_INCREF(__pyx_t_7); __pyx_t_3 = 0; __pyx_t_9 = NULL; } else { __pyx_t_3 = -1; __pyx_t_7 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 60, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_9 = (CYTHON_COMPILING_IN_LIMITED_API) ? PyIter_Next : __Pyx_PyObject_GetIterNextFunc(__pyx_t_7); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 60, __pyx_L1_error) } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; for (;;) { if (likely(!__pyx_t_9)) { if (likely(PyList_CheckExact(__pyx_t_7))) { { Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_7); #if !CYTHON_ASSUME_SAFE_SIZE if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 60, __pyx_L1_error) #endif if (__pyx_t_3 >= __pyx_temp) break; } __pyx_t_1 = __Pyx_PyList_GetItemRef(__pyx_t_7, __pyx_t_3); ++__pyx_t_3; } else { { Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_7); #if !CYTHON_ASSUME_SAFE_SIZE if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 60, __pyx_L1_error) #endif if (__pyx_t_3 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_1 = __Pyx_NewRef(PyTuple_GET_ITEM(__pyx_t_7, __pyx_t_3)); #else __pyx_t_1 = __Pyx_PySequence_ITEM(__pyx_t_7, __pyx_t_3); #endif ++__pyx_t_3; } if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 60, __pyx_L1_error) } else { __pyx_t_1 = __pyx_t_9(__pyx_t_7); if (unlikely(!__pyx_t_1)) { PyObject* exc_type = PyErr_Occurred(); if (exc_type) { if (unlikely(!__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) __PYX_ERR(0, 60, __pyx_L1_error) PyErr_Clear(); } break; } } __Pyx_GOTREF(__pyx_t_1); __Pyx_XDECREF_SET(__pyx_v_node, __pyx_t_1); __pyx_t_1 = 0; /* … */ } __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+061: encoded_length += log2(<float>NR_OF_PATTERN_TYPES_WITH_SINGLETON)
__Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_NR_OF_PATTERN_TYPES_WITH_SINGLET); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 61, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_6 = __Pyx_PyFloat_AsFloat(__pyx_t_1); if (unlikely((__pyx_t_6 == (float)-1) && PyErr_Occurred())) __PYX_ERR(0, 61, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; try { __pyx_t_10 = std::log2(((float)__pyx_t_6)); } catch(...) { __Pyx_CppExn2PyErr(); __PYX_ERR(0, 61, __pyx_L1_error) } __pyx_v_encoded_length = (__pyx_v_encoded_length + __pyx_t_10);
+062: code_length_of_pattern, available_activities_for_encoding = \
__Pyx_XDECREF_SET(__pyx_v_code_length_of_pattern, __pyx_t_11); __pyx_t_11 = 0; __Pyx_XDECREF_SET(__pyx_v_available_activities_for_encoding, __pyx_t_12); __pyx_t_12 = 0;
+063: (<Pattern>(<Node>node).pattern).get_encoded_length_in_code_table(activity_set)
__pyx_t_1 = ((struct __pyx_vtabstruct_27prolothar_process_discovery_9discovery_7proseqo_7pattern_7pattern_Pattern *)((struct __pyx_obj_27prolothar_process_discovery_9discovery_7proseqo_7pattern_7pattern_Pattern *)((struct __pyx_obj_16prolothar_common_6models_3dfg_4node_Node *)__pyx_v_node)->pattern)->__pyx_vtab)->get_encoded_length_in_code_table(((struct __pyx_obj_27prolothar_process_discovery_9discovery_7proseqo_7pattern_7pattern_Pattern *)((struct __pyx_obj_16prolothar_common_6models_3dfg_4node_Node *)__pyx_v_node)->pattern), __pyx_v_activity_set, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 63, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (likely(__pyx_t_1 != Py_None)) { PyObject* sequence = __pyx_t_1; Py_ssize_t size = __Pyx_PyTuple_GET_SIZE(sequence); if (unlikely(size != 2)) { if (size > 2) __Pyx_RaiseTooManyValuesError(2); else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); __PYX_ERR(0, 62, __pyx_L1_error) } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_11 = PyTuple_GET_ITEM(sequence, 0); __Pyx_INCREF(__pyx_t_11); __pyx_t_12 = PyTuple_GET_ITEM(sequence, 1); __Pyx_INCREF(__pyx_t_12); #else __pyx_t_11 = __Pyx_PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 62, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); __pyx_t_12 = __Pyx_PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 62, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_12); #endif __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } else { __Pyx_RaiseNoneNotIterableError(); __PYX_ERR(0, 62, __pyx_L1_error) }
+064: encoded_length += code_length_of_pattern
__pyx_t_1 = PyFloat_FromDouble(__pyx_v_encoded_length); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 64, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_12 = PyNumber_InPlaceAdd(__pyx_t_1, __pyx_v_code_length_of_pattern); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 64, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_12); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_10 = __Pyx_PyFloat_AsFloat(__pyx_t_12); if (unlikely((__pyx_t_10 == (float)-1) && PyErr_Occurred())) __PYX_ERR(0, 64, __pyx_L1_error) __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; __pyx_v_encoded_length = __pyx_t_10;
+065: if encoded_length < 0:
__pyx_t_4 = (__pyx_v_encoded_length < 0.0);
if (unlikely(__pyx_t_4)) {
/* … */
}
+066: raise ValueError()
__pyx_t_12 = NULL;
__Pyx_INCREF(__pyx_builtin_ValueError);
__pyx_t_1 = __pyx_builtin_ValueError;
__pyx_t_8 = 1;
{
PyObject *__pyx_callargs[2] = {__pyx_t_12, NULL};
__pyx_t_7 = __Pyx_PyObject_FastCall(__pyx_t_1, __pyx_callargs+__pyx_t_8, (1-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
__Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 66, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_7);
}
__Pyx_Raise(__pyx_t_7, 0, 0, 0);
__Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
__PYX_ERR(0, 66, __pyx_L1_error)
+067: cdef int max_nr_of_edges = pattern_dfg.get_nr_of_nodes() ** 2
__pyx_t_13 = ((struct __pyx_vtabstruct_27prolothar_process_discovery_9discovery_7proseqo_11pattern_dfg_PatternDfg *)__pyx_v_pattern_dfg->__pyx_base.__pyx_vtab)->__pyx_base.get_nr_of_nodes(((struct __pyx_obj_16prolothar_common_6models_22directly_follows_graph_DirectlyFollowsGraph *)__pyx_v_pattern_dfg), 0); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 67, __pyx_L1_error)
__pyx_v_max_nr_of_edges = __Pyx_pow_long(((long)__pyx_t_13), 2);
+068: encoded_length += log2(<float>(max_nr_of_edges + 1))
try {
__pyx_t_10 = std::log2(((float)(__pyx_v_max_nr_of_edges + 1)));
} catch(...) {
__Pyx_CppExn2PyErr();
__PYX_ERR(0, 68, __pyx_L1_error)
}
__pyx_v_encoded_length = (__pyx_v_encoded_length + __pyx_t_10);
069: #which edges are present or 0
+070: encoded_length += mdl_utils.log2binom(max_nr_of_edges,
__pyx_t_5 = __pyx_f_16prolothar_common_9mdl_utils_log2binom(__pyx_v_max_nr_of_edges, __pyx_t_13, 0); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 70, __pyx_L1_error)
__pyx_v_encoded_length = (__pyx_v_encoded_length + __pyx_t_5);
+071: pattern_dfg.get_nr_of_edges())
__pyx_t_13 = ((struct __pyx_vtabstruct_27prolothar_process_discovery_9discovery_7proseqo_11pattern_dfg_PatternDfg *)__pyx_v_pattern_dfg->__pyx_base.__pyx_vtab)->__pyx_base.get_nr_of_edges(((struct __pyx_obj_16prolothar_common_6models_22directly_follows_graph_DirectlyFollowsGraph *)__pyx_v_pattern_dfg), 0); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 71, __pyx_L1_error)
+072: if verbose:
if (__pyx_v_verbose) {
/* … */
}
+073: print('encoded length of pattern DFG: %.2f' % encoded_length)
__pyx_t_1 = NULL;
__Pyx_INCREF(__pyx_builtin_print);
__pyx_t_12 = __pyx_builtin_print;
__pyx_t_11 = PyFloat_FromDouble(__pyx_v_encoded_length); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 73, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_11);
__pyx_t_14 = PyUnicode_Format(__pyx_mstate_global->__pyx_kp_u_encoded_length_of_pattern_DFG_2f, __pyx_t_11); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 73, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_14);
__Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
__pyx_t_8 = 1;
{
PyObject *__pyx_callargs[2] = {__pyx_t_1, __pyx_t_14};
__pyx_t_7 = __Pyx_PyObject_FastCall(__pyx_t_12, __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
__Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
__Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
__Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 73, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_7);
}
__Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+074: return encoded_length
__pyx_r = __pyx_v_encoded_length; goto __pyx_L0;
075:
+076: cpdef float estimate_mdl_score(
static PyObject *__pyx_pw_27prolothar_process_discovery_9discovery_7proseqo_9mdl_score_7estimate_mdl_score(PyObject *__pyx_self,
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
); /*proto*/
static float __pyx_f_27prolothar_process_discovery_9discovery_7proseqo_9mdl_score_estimate_mdl_score(struct __pyx_obj_27prolothar_process_discovery_9discovery_7proseqo_11pattern_dfg_PatternDfg *__pyx_v_pattern_dfg_without_candidate, struct __pyx_obj_27prolothar_process_discovery_9discovery_7proseqo_5cover_Cover *__pyx_v_cover_without_candidate, PyObject *__pyx_v_candidate, PyObject *__pyx_v_log, struct __pyx_obj_16prolothar_common_6models_22directly_follows_graph_DirectlyFollowsGraph *__pyx_v_dfg, CYTHON_UNUSED int __pyx_skip_dispatch, struct __pyx_opt_args_27prolothar_process_discovery_9discovery_7proseqo_9mdl_score_estimate_mdl_score *__pyx_optional_args) {
/* … */
/* function exit code */
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_1);
__Pyx_XDECREF(__pyx_t_2);
__Pyx_XDECREF(__pyx_t_3);
__Pyx_AddTraceback("prolothar_process_discovery.discovery.proseqo.mdl_score.estimate_mdl_score", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = -1;
__pyx_L0:;
__Pyx_XDECREF((PyObject *)__pyx_v_cover);
__Pyx_XDECREF((PyObject *)__pyx_v_pattern_dfg);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* Python wrapper */
static PyObject *__pyx_pw_27prolothar_process_discovery_9discovery_7proseqo_9mdl_score_7estimate_mdl_score(PyObject *__pyx_self,
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
); /*proto*/
PyDoc_STRVAR(__pyx_doc_27prolothar_process_discovery_9discovery_7proseqo_9mdl_score_6estimate_mdl_score, "computes an estimate for the MDL of the PatternDfg that results from the\n application of the given candidate\n ");
static PyMethodDef __pyx_mdef_27prolothar_process_discovery_9discovery_7proseqo_9mdl_score_7estimate_mdl_score = {"estimate_mdl_score", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_27prolothar_process_discovery_9discovery_7proseqo_9mdl_score_7estimate_mdl_score, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_27prolothar_process_discovery_9discovery_7proseqo_9mdl_score_6estimate_mdl_score};
static PyObject *__pyx_pw_27prolothar_process_discovery_9discovery_7proseqo_9mdl_score_7estimate_mdl_score(PyObject *__pyx_self,
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
) {
struct __pyx_obj_27prolothar_process_discovery_9discovery_7proseqo_11pattern_dfg_PatternDfg *__pyx_v_pattern_dfg_without_candidate = 0;
struct __pyx_obj_27prolothar_process_discovery_9discovery_7proseqo_5cover_Cover *__pyx_v_cover_without_candidate = 0;
PyObject *__pyx_v_candidate = 0;
PyObject *__pyx_v_log = 0;
struct __pyx_obj_16prolothar_common_6models_22directly_follows_graph_DirectlyFollowsGraph *__pyx_v_dfg = 0;
int __pyx_v_verbose;
#if !CYTHON_METH_FASTCALL
CYTHON_UNUSED Py_ssize_t __pyx_nargs;
#endif
CYTHON_UNUSED PyObject *const *__pyx_kwvalues;
PyObject *__pyx_r = 0;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("estimate_mdl_score (wrapper)", 0);
#if !CYTHON_METH_FASTCALL
#if CYTHON_ASSUME_SAFE_SIZE
__pyx_nargs = PyTuple_GET_SIZE(__pyx_args);
#else
__pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL;
#endif
#endif
__pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs);
{
PyObject ** const __pyx_pyargnames[] = {&__pyx_mstate_global->__pyx_n_u_pattern_dfg_without_candidate,&__pyx_mstate_global->__pyx_n_u_cover_without_candidate,&__pyx_mstate_global->__pyx_n_u_candidate,&__pyx_mstate_global->__pyx_n_u_log,&__pyx_mstate_global->__pyx_n_u_dfg,&__pyx_mstate_global->__pyx_n_u_verbose,0};
PyObject* values[6] = {0,0,0,0,0,0};
const Py_ssize_t __pyx_kwds_len = (__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0;
if (unlikely(__pyx_kwds_len) < 0) __PYX_ERR(0, 76, __pyx_L3_error)
if (__pyx_kwds_len > 0) {
switch (__pyx_nargs) {
case 6:
values[5] = __Pyx_ArgRef_FASTCALL(__pyx_args, 5);
if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[5])) __PYX_ERR(0, 76, __pyx_L3_error)
CYTHON_FALLTHROUGH;
case 5:
values[4] = __Pyx_ArgRef_FASTCALL(__pyx_args, 4);
if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[4])) __PYX_ERR(0, 76, __pyx_L3_error)
CYTHON_FALLTHROUGH;
case 4:
values[3] = __Pyx_ArgRef_FASTCALL(__pyx_args, 3);
if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[3])) __PYX_ERR(0, 76, __pyx_L3_error)
CYTHON_FALLTHROUGH;
case 3:
values[2] = __Pyx_ArgRef_FASTCALL(__pyx_args, 2);
if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[2])) __PYX_ERR(0, 76, __pyx_L3_error)
CYTHON_FALLTHROUGH;
case 2:
values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1);
if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 76, __pyx_L3_error)
CYTHON_FALLTHROUGH;
case 1:
values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 76, __pyx_L3_error)
CYTHON_FALLTHROUGH;
case 0: break;
default: goto __pyx_L5_argtuple_error;
}
const Py_ssize_t kwd_pos_args = __pyx_nargs;
if (__Pyx_ParseKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values, kwd_pos_args, __pyx_kwds_len, "estimate_mdl_score", 0) < 0) __PYX_ERR(0, 76, __pyx_L3_error)
for (Py_ssize_t i = __pyx_nargs; i < 5; i++) {
if (unlikely(!values[i])) { __Pyx_RaiseArgtupleInvalid("estimate_mdl_score", 0, 5, 6, i); __PYX_ERR(0, 76, __pyx_L3_error) }
}
} else {
switch (__pyx_nargs) {
case 6:
values[5] = __Pyx_ArgRef_FASTCALL(__pyx_args, 5);
if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[5])) __PYX_ERR(0, 76, __pyx_L3_error)
CYTHON_FALLTHROUGH;
case 5:
values[4] = __Pyx_ArgRef_FASTCALL(__pyx_args, 4);
if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[4])) __PYX_ERR(0, 76, __pyx_L3_error)
values[3] = __Pyx_ArgRef_FASTCALL(__pyx_args, 3);
if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[3])) __PYX_ERR(0, 76, __pyx_L3_error)
values[2] = __Pyx_ArgRef_FASTCALL(__pyx_args, 2);
if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[2])) __PYX_ERR(0, 76, __pyx_L3_error)
values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1);
if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 76, __pyx_L3_error)
values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 76, __pyx_L3_error)
break;
default: goto __pyx_L5_argtuple_error;
}
}
__pyx_v_pattern_dfg_without_candidate = ((struct __pyx_obj_27prolothar_process_discovery_9discovery_7proseqo_11pattern_dfg_PatternDfg *)values[0]);
__pyx_v_cover_without_candidate = ((struct __pyx_obj_27prolothar_process_discovery_9discovery_7proseqo_5cover_Cover *)values[1]);
__pyx_v_candidate = values[2];
__pyx_v_log = values[3];
__pyx_v_dfg = ((struct __pyx_obj_16prolothar_common_6models_22directly_follows_graph_DirectlyFollowsGraph *)values[4]);
if (values[5]) {
__pyx_v_verbose = __Pyx_PyObject_IsTrue(values[5]); if (unlikely((__pyx_v_verbose == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 82, __pyx_L3_error)
} else {
/* … */
/* function exit code */
goto __pyx_L0;
__pyx_L1_error:;
__pyx_r = NULL;
for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
Py_XDECREF(values[__pyx_temp]);
}
goto __pyx_L7_cleaned_up;
__pyx_L0:;
for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
Py_XDECREF(values[__pyx_temp]);
}
__pyx_L7_cleaned_up:;
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
static PyObject *__pyx_pf_27prolothar_process_discovery_9discovery_7proseqo_9mdl_score_6estimate_mdl_score(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_27prolothar_process_discovery_9discovery_7proseqo_11pattern_dfg_PatternDfg *__pyx_v_pattern_dfg_without_candidate, struct __pyx_obj_27prolothar_process_discovery_9discovery_7proseqo_5cover_Cover *__pyx_v_cover_without_candidate, PyObject *__pyx_v_candidate, PyObject *__pyx_v_log, struct __pyx_obj_16prolothar_common_6models_22directly_follows_graph_DirectlyFollowsGraph *__pyx_v_dfg, int __pyx_v_verbose) {
PyObject *__pyx_r = NULL;
__Pyx_XDECREF(__pyx_r);
__pyx_t_2.__pyx_n = 1;
__pyx_t_2.verbose = __pyx_v_verbose;
__pyx_t_1 = __pyx_f_27prolothar_process_discovery_9discovery_7proseqo_9mdl_score_estimate_mdl_score(__pyx_v_pattern_dfg_without_candidate, __pyx_v_cover_without_candidate, __pyx_v_candidate, __pyx_v_log, __pyx_v_dfg, 1, &__pyx_t_2); if (unlikely(__pyx_t_1 == ((float)-1) && PyErr_Occurred())) __PYX_ERR(0, 76, __pyx_L1_error)
__pyx_t_3 = PyFloat_FromDouble(__pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 76, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_3);
__pyx_r = __pyx_t_3;
__pyx_t_3 = 0;
goto __pyx_L0;
/* function exit code */
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_3);
__Pyx_AddTraceback("prolothar_process_discovery.discovery.proseqo.mdl_score.estimate_mdl_score", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = NULL;
__pyx_L0:;
__Pyx_XGIVEREF(__pyx_r);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* … */
__pyx_t_3 = __Pyx_CyFunction_New(&__pyx_mdef_27prolothar_process_discovery_9discovery_7proseqo_9mdl_score_7estimate_mdl_score, 0, __pyx_mstate_global->__pyx_n_u_estimate_mdl_score, NULL, __pyx_mstate_global->__pyx_n_u_prolothar_process_discovery_disc_3, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[3])); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 76, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_3);
__Pyx_CyFunction_SetDefaultsTuple(__pyx_t_3, __pyx_mstate_global->__pyx_tuple[3]);
if (PyDict_SetItem(__pyx_mstate_global->__pyx_d, __pyx_mstate_global->__pyx_n_u_estimate_mdl_score, __pyx_t_3) < 0) __PYX_ERR(0, 76, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
/* … */
__pyx_mstate_global->__pyx_tuple[3] = PyTuple_Pack(1, Py_False); if (unlikely(!__pyx_mstate_global->__pyx_tuple[3])) __PYX_ERR(0, 76, __pyx_L1_error)
__Pyx_GOTREF(__pyx_mstate_global->__pyx_tuple[3]);
__Pyx_GIVEREF(__pyx_mstate_global->__pyx_tuple[3]);
077: PatternDfg pattern_dfg_without_candidate,
078: Cover cover_without_candidate,
079: object candidate,
080: object log,
081: DirectlyFollowsGraph dfg,
+082: bint verbose = False):
int __pyx_v_verbose = ((int)0);
struct __pyx_obj_27prolothar_process_discovery_9discovery_7proseqo_5cover_Cover *__pyx_v_cover = 0;
struct __pyx_obj_27prolothar_process_discovery_9discovery_7proseqo_11pattern_dfg_PatternDfg *__pyx_v_pattern_dfg = 0;
float __pyx_v_mdl_score;
float __pyx_r;
if (__pyx_optional_args) {
if (__pyx_optional_args->__pyx_n > 0) {
__pyx_v_verbose = __pyx_optional_args->verbose;
}
}
/* … */
__pyx_v_verbose = ((int)0);
}
}
goto __pyx_L6_skip;
__pyx_L5_argtuple_error:;
__Pyx_RaiseArgtupleInvalid("estimate_mdl_score", 0, 5, 6, __pyx_nargs); __PYX_ERR(0, 76, __pyx_L3_error)
__pyx_L6_skip:;
goto __pyx_L4_argument_unpacking_done;
__pyx_L3_error:;
for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
Py_XDECREF(values[__pyx_temp]);
}
__Pyx_AddTraceback("prolothar_process_discovery.discovery.proseqo.mdl_score.estimate_mdl_score", __pyx_clineno, __pyx_lineno, __pyx_filename);
__Pyx_RefNannyFinishContext();
return NULL;
__pyx_L4_argument_unpacking_done:;
if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_pattern_dfg_without_candidate), __pyx_mstate_global->__pyx_ptype_27prolothar_process_discovery_9discovery_7proseqo_11pattern_dfg_PatternDfg, 1, "pattern_dfg_without_candidate", 0))) __PYX_ERR(0, 77, __pyx_L1_error)
if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_cover_without_candidate), __pyx_mstate_global->__pyx_ptype_27prolothar_process_discovery_9discovery_7proseqo_5cover_Cover, 1, "cover_without_candidate", 0))) __PYX_ERR(0, 78, __pyx_L1_error)
if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_dfg), __pyx_mstate_global->__pyx_ptype_16prolothar_common_6models_22directly_follows_graph_DirectlyFollowsGraph, 1, "dfg", 0))) __PYX_ERR(0, 81, __pyx_L1_error)
__pyx_r = __pyx_pf_27prolothar_process_discovery_9discovery_7proseqo_9mdl_score_6estimate_mdl_score(__pyx_self, __pyx_v_pattern_dfg_without_candidate, __pyx_v_cover_without_candidate, __pyx_v_candidate, __pyx_v_log, __pyx_v_dfg, __pyx_v_verbose);
083: """computes an estimate for the MDL of the PatternDfg that results from the
084: application of the given candidate
085: """
+086: cdef Cover cover = cover_without_candidate.copy_counts_only()
__pyx_t_1 = ((PyObject *)((struct __pyx_vtabstruct_27prolothar_process_discovery_9discovery_7proseqo_5cover_Cover *)__pyx_v_cover_without_candidate->__pyx_vtab)->copy_counts_only(__pyx_v_cover_without_candidate, 0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 86, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_cover = ((struct __pyx_obj_27prolothar_process_discovery_9discovery_7proseqo_5cover_Cover *)__pyx_t_1); __pyx_t_1 = 0;
+087: cdef PatternDfg pattern_dfg = candidate.estimate_cover_change(
__pyx_t_2 = __pyx_v_candidate; __Pyx_INCREF(__pyx_t_2); /* … */ if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_mstate_global->__pyx_ptype_27prolothar_process_discovery_9discovery_7proseqo_11pattern_dfg_PatternDfg))))) __PYX_ERR(0, 87, __pyx_L1_error) __pyx_v_pattern_dfg = ((struct __pyx_obj_27prolothar_process_discovery_9discovery_7proseqo_11pattern_dfg_PatternDfg *)__pyx_t_1); __pyx_t_1 = 0;
+088: cover, pattern_dfg_without_candidate.copy(), dfg)
__pyx_t_3 = ((PyObject *)((struct __pyx_vtabstruct_27prolothar_process_discovery_9discovery_7proseqo_11pattern_dfg_PatternDfg *)__pyx_v_pattern_dfg_without_candidate->__pyx_base.__pyx_vtab)->copy(__pyx_v_pattern_dfg_without_candidate, 0)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 88, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = 0; { PyObject *__pyx_callargs[4] = {__pyx_t_2, ((PyObject *)__pyx_v_cover), __pyx_t_3, ((PyObject *)__pyx_v_dfg)}; __pyx_t_1 = __Pyx_PyObject_FastCallMethod(__pyx_mstate_global->__pyx_n_u_estimate_cover_change, __pyx_callargs+__pyx_t_4, (4-__pyx_t_4) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET)); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 87, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); }
089:
+090: cdef float mdl_score = compute_encoded_length_of_pattern_dfg(
__pyx_t_6.__pyx_n = 1; __pyx_t_6.verbose = __pyx_v_verbose; __pyx_t_5 = __pyx_f_27prolothar_process_discovery_9discovery_7proseqo_9mdl_score_compute_encoded_length_of_pattern_dfg(__pyx_v_pattern_dfg, ((PyObject*)__pyx_t_1), 0, &__pyx_t_6); if (unlikely(__pyx_t_5 == ((float)-1) && PyErr_Occurred())) __PYX_ERR(0, 90, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_mdl_score = __pyx_t_5;
+091: pattern_dfg, cover.get_activity_set(), verbose=verbose)
__pyx_t_1 = ((struct __pyx_vtabstruct_27prolothar_process_discovery_9discovery_7proseqo_5cover_Cover *)__pyx_v_cover->__pyx_vtab)->get_activity_set(__pyx_v_cover, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 91, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1);
+092: mdl_score += cover.get_encoded_length_of_cover(log, verbose=verbose)
__pyx_t_7.__pyx_n = 1;
__pyx_t_7.verbose = __pyx_v_verbose;
__pyx_t_5 = ((struct __pyx_vtabstruct_27prolothar_process_discovery_9discovery_7proseqo_5cover_Cover *)__pyx_v_cover->__pyx_vtab)->get_encoded_length_of_cover(__pyx_v_cover, __pyx_v_log, 0, &__pyx_t_7); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 92, __pyx_L1_error)
__pyx_v_mdl_score = (__pyx_v_mdl_score + __pyx_t_5);
+093: return mdl_score
__pyx_r = __pyx_v_mdl_score; goto __pyx_L0;
094:
+095: cpdef float estimate_lower_bound_mdl_score(
static PyObject *__pyx_pw_27prolothar_process_discovery_9discovery_7proseqo_9mdl_score_9estimate_lower_bound_mdl_score(PyObject *__pyx_self,
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
); /*proto*/
static float __pyx_f_27prolothar_process_discovery_9discovery_7proseqo_9mdl_score_estimate_lower_bound_mdl_score(struct __pyx_obj_27prolothar_process_discovery_9discovery_7proseqo_11pattern_dfg_PatternDfg *__pyx_v_pattern_dfg_without_candidate, struct __pyx_obj_27prolothar_process_discovery_9discovery_7proseqo_5cover_Cover *__pyx_v_cover_without_candidate, PyObject *__pyx_v_candidate, PyObject *__pyx_v_log, struct __pyx_obj_16prolothar_common_6models_22directly_follows_graph_DirectlyFollowsGraph *__pyx_v_dfg, CYTHON_UNUSED int __pyx_skip_dispatch, struct __pyx_opt_args_27prolothar_process_discovery_9discovery_7proseqo_9mdl_score_estimate_lower_bound_mdl_score *__pyx_optional_args) {
/* … */
/* function exit code */
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_1);
__Pyx_XDECREF(__pyx_t_2);
__Pyx_XDECREF(__pyx_t_3);
__Pyx_AddTraceback("prolothar_process_discovery.discovery.proseqo.mdl_score.estimate_lower_bound_mdl_score", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = -1;
__pyx_L0:;
__Pyx_XDECREF((PyObject *)__pyx_v_cover);
__Pyx_XDECREF((PyObject *)__pyx_v_pattern_dfg);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* Python wrapper */
static PyObject *__pyx_pw_27prolothar_process_discovery_9discovery_7proseqo_9mdl_score_9estimate_lower_bound_mdl_score(PyObject *__pyx_self,
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
); /*proto*/
PyDoc_STRVAR(__pyx_doc_27prolothar_process_discovery_9discovery_7proseqo_9mdl_score_8estimate_lower_bound_mdl_score, "computes an estimate in form of a lower bound for the MDL of the\n PatternDfg that results from the application of the given candidate\n ");
static PyMethodDef __pyx_mdef_27prolothar_process_discovery_9discovery_7proseqo_9mdl_score_9estimate_lower_bound_mdl_score = {"estimate_lower_bound_mdl_score", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_27prolothar_process_discovery_9discovery_7proseqo_9mdl_score_9estimate_lower_bound_mdl_score, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_27prolothar_process_discovery_9discovery_7proseqo_9mdl_score_8estimate_lower_bound_mdl_score};
static PyObject *__pyx_pw_27prolothar_process_discovery_9discovery_7proseqo_9mdl_score_9estimate_lower_bound_mdl_score(PyObject *__pyx_self,
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
) {
struct __pyx_obj_27prolothar_process_discovery_9discovery_7proseqo_11pattern_dfg_PatternDfg *__pyx_v_pattern_dfg_without_candidate = 0;
struct __pyx_obj_27prolothar_process_discovery_9discovery_7proseqo_5cover_Cover *__pyx_v_cover_without_candidate = 0;
PyObject *__pyx_v_candidate = 0;
PyObject *__pyx_v_log = 0;
struct __pyx_obj_16prolothar_common_6models_22directly_follows_graph_DirectlyFollowsGraph *__pyx_v_dfg = 0;
int __pyx_v_verbose;
#if !CYTHON_METH_FASTCALL
CYTHON_UNUSED Py_ssize_t __pyx_nargs;
#endif
CYTHON_UNUSED PyObject *const *__pyx_kwvalues;
PyObject *__pyx_r = 0;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("estimate_lower_bound_mdl_score (wrapper)", 0);
#if !CYTHON_METH_FASTCALL
#if CYTHON_ASSUME_SAFE_SIZE
__pyx_nargs = PyTuple_GET_SIZE(__pyx_args);
#else
__pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL;
#endif
#endif
__pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs);
{
PyObject ** const __pyx_pyargnames[] = {&__pyx_mstate_global->__pyx_n_u_pattern_dfg_without_candidate,&__pyx_mstate_global->__pyx_n_u_cover_without_candidate,&__pyx_mstate_global->__pyx_n_u_candidate,&__pyx_mstate_global->__pyx_n_u_log,&__pyx_mstate_global->__pyx_n_u_dfg,&__pyx_mstate_global->__pyx_n_u_verbose,0};
PyObject* values[6] = {0,0,0,0,0,0};
const Py_ssize_t __pyx_kwds_len = (__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0;
if (unlikely(__pyx_kwds_len) < 0) __PYX_ERR(0, 95, __pyx_L3_error)
if (__pyx_kwds_len > 0) {
switch (__pyx_nargs) {
case 6:
values[5] = __Pyx_ArgRef_FASTCALL(__pyx_args, 5);
if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[5])) __PYX_ERR(0, 95, __pyx_L3_error)
CYTHON_FALLTHROUGH;
case 5:
values[4] = __Pyx_ArgRef_FASTCALL(__pyx_args, 4);
if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[4])) __PYX_ERR(0, 95, __pyx_L3_error)
CYTHON_FALLTHROUGH;
case 4:
values[3] = __Pyx_ArgRef_FASTCALL(__pyx_args, 3);
if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[3])) __PYX_ERR(0, 95, __pyx_L3_error)
CYTHON_FALLTHROUGH;
case 3:
values[2] = __Pyx_ArgRef_FASTCALL(__pyx_args, 2);
if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[2])) __PYX_ERR(0, 95, __pyx_L3_error)
CYTHON_FALLTHROUGH;
case 2:
values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1);
if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 95, __pyx_L3_error)
CYTHON_FALLTHROUGH;
case 1:
values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 95, __pyx_L3_error)
CYTHON_FALLTHROUGH;
case 0: break;
default: goto __pyx_L5_argtuple_error;
}
const Py_ssize_t kwd_pos_args = __pyx_nargs;
if (__Pyx_ParseKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values, kwd_pos_args, __pyx_kwds_len, "estimate_lower_bound_mdl_score", 0) < 0) __PYX_ERR(0, 95, __pyx_L3_error)
for (Py_ssize_t i = __pyx_nargs; i < 5; i++) {
if (unlikely(!values[i])) { __Pyx_RaiseArgtupleInvalid("estimate_lower_bound_mdl_score", 0, 5, 6, i); __PYX_ERR(0, 95, __pyx_L3_error) }
}
} else {
switch (__pyx_nargs) {
case 6:
values[5] = __Pyx_ArgRef_FASTCALL(__pyx_args, 5);
if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[5])) __PYX_ERR(0, 95, __pyx_L3_error)
CYTHON_FALLTHROUGH;
case 5:
values[4] = __Pyx_ArgRef_FASTCALL(__pyx_args, 4);
if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[4])) __PYX_ERR(0, 95, __pyx_L3_error)
values[3] = __Pyx_ArgRef_FASTCALL(__pyx_args, 3);
if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[3])) __PYX_ERR(0, 95, __pyx_L3_error)
values[2] = __Pyx_ArgRef_FASTCALL(__pyx_args, 2);
if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[2])) __PYX_ERR(0, 95, __pyx_L3_error)
values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1);
if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 95, __pyx_L3_error)
values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 95, __pyx_L3_error)
break;
default: goto __pyx_L5_argtuple_error;
}
}
__pyx_v_pattern_dfg_without_candidate = ((struct __pyx_obj_27prolothar_process_discovery_9discovery_7proseqo_11pattern_dfg_PatternDfg *)values[0]);
__pyx_v_cover_without_candidate = ((struct __pyx_obj_27prolothar_process_discovery_9discovery_7proseqo_5cover_Cover *)values[1]);
__pyx_v_candidate = values[2];
__pyx_v_log = values[3];
__pyx_v_dfg = ((struct __pyx_obj_16prolothar_common_6models_22directly_follows_graph_DirectlyFollowsGraph *)values[4]);
if (values[5]) {
__pyx_v_verbose = __Pyx_PyObject_IsTrue(values[5]); if (unlikely((__pyx_v_verbose == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 101, __pyx_L3_error)
} else {
/* … */
/* function exit code */
goto __pyx_L0;
__pyx_L1_error:;
__pyx_r = NULL;
for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
Py_XDECREF(values[__pyx_temp]);
}
goto __pyx_L7_cleaned_up;
__pyx_L0:;
for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
Py_XDECREF(values[__pyx_temp]);
}
__pyx_L7_cleaned_up:;
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
static PyObject *__pyx_pf_27prolothar_process_discovery_9discovery_7proseqo_9mdl_score_8estimate_lower_bound_mdl_score(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_27prolothar_process_discovery_9discovery_7proseqo_11pattern_dfg_PatternDfg *__pyx_v_pattern_dfg_without_candidate, struct __pyx_obj_27prolothar_process_discovery_9discovery_7proseqo_5cover_Cover *__pyx_v_cover_without_candidate, PyObject *__pyx_v_candidate, PyObject *__pyx_v_log, struct __pyx_obj_16prolothar_common_6models_22directly_follows_graph_DirectlyFollowsGraph *__pyx_v_dfg, int __pyx_v_verbose) {
PyObject *__pyx_r = NULL;
__Pyx_XDECREF(__pyx_r);
__pyx_t_2.__pyx_n = 1;
__pyx_t_2.verbose = __pyx_v_verbose;
__pyx_t_1 = __pyx_f_27prolothar_process_discovery_9discovery_7proseqo_9mdl_score_estimate_lower_bound_mdl_score(__pyx_v_pattern_dfg_without_candidate, __pyx_v_cover_without_candidate, __pyx_v_candidate, __pyx_v_log, __pyx_v_dfg, 1, &__pyx_t_2); if (unlikely(__pyx_t_1 == ((float)-1) && PyErr_Occurred())) __PYX_ERR(0, 95, __pyx_L1_error)
__pyx_t_3 = PyFloat_FromDouble(__pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 95, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_3);
__pyx_r = __pyx_t_3;
__pyx_t_3 = 0;
goto __pyx_L0;
/* … */
__pyx_t_3 = __Pyx_CyFunction_New(&__pyx_mdef_27prolothar_process_discovery_9discovery_7proseqo_9mdl_score_9estimate_lower_bound_mdl_score, 0, __pyx_mstate_global->__pyx_n_u_estimate_lower_bound_mdl_score, NULL, __pyx_mstate_global->__pyx_n_u_prolothar_process_discovery_disc_3, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[4])); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 95, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_3);
__Pyx_CyFunction_SetDefaultsTuple(__pyx_t_3, __pyx_mstate_global->__pyx_tuple[4]);
if (PyDict_SetItem(__pyx_mstate_global->__pyx_d, __pyx_mstate_global->__pyx_n_u_estimate_lower_bound_mdl_score, __pyx_t_3) < 0) __PYX_ERR(0, 95, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
096: PatternDfg pattern_dfg_without_candidate,
097: Cover cover_without_candidate,
098: object candidate,
099: object log,
100: DirectlyFollowsGraph dfg,
+101: bint verbose = False):
int __pyx_v_verbose = ((int)0);
struct __pyx_obj_27prolothar_process_discovery_9discovery_7proseqo_5cover_Cover *__pyx_v_cover = 0;
struct __pyx_obj_27prolothar_process_discovery_9discovery_7proseqo_11pattern_dfg_PatternDfg *__pyx_v_pattern_dfg = 0;
float __pyx_v_mdl_score;
float __pyx_r;
if (__pyx_optional_args) {
if (__pyx_optional_args->__pyx_n > 0) {
__pyx_v_verbose = __pyx_optional_args->verbose;
}
}
/* … */
__pyx_v_verbose = ((int)0);
}
}
goto __pyx_L6_skip;
__pyx_L5_argtuple_error:;
__Pyx_RaiseArgtupleInvalid("estimate_lower_bound_mdl_score", 0, 5, 6, __pyx_nargs); __PYX_ERR(0, 95, __pyx_L3_error)
__pyx_L6_skip:;
goto __pyx_L4_argument_unpacking_done;
__pyx_L3_error:;
for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
Py_XDECREF(values[__pyx_temp]);
}
__Pyx_AddTraceback("prolothar_process_discovery.discovery.proseqo.mdl_score.estimate_lower_bound_mdl_score", __pyx_clineno, __pyx_lineno, __pyx_filename);
__Pyx_RefNannyFinishContext();
return NULL;
__pyx_L4_argument_unpacking_done:;
if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_pattern_dfg_without_candidate), __pyx_mstate_global->__pyx_ptype_27prolothar_process_discovery_9discovery_7proseqo_11pattern_dfg_PatternDfg, 1, "pattern_dfg_without_candidate", 0))) __PYX_ERR(0, 96, __pyx_L1_error)
if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_cover_without_candidate), __pyx_mstate_global->__pyx_ptype_27prolothar_process_discovery_9discovery_7proseqo_5cover_Cover, 1, "cover_without_candidate", 0))) __PYX_ERR(0, 97, __pyx_L1_error)
if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_dfg), __pyx_mstate_global->__pyx_ptype_16prolothar_common_6models_22directly_follows_graph_DirectlyFollowsGraph, 1, "dfg", 0))) __PYX_ERR(0, 100, __pyx_L1_error)
__pyx_r = __pyx_pf_27prolothar_process_discovery_9discovery_7proseqo_9mdl_score_8estimate_lower_bound_mdl_score(__pyx_self, __pyx_v_pattern_dfg_without_candidate, __pyx_v_cover_without_candidate, __pyx_v_candidate, __pyx_v_log, __pyx_v_dfg, __pyx_v_verbose);
102: """computes an estimate in form of a lower bound for the MDL of the
103: PatternDfg that results from the application of the given candidate
104: """
+105: cdef Cover cover = cover_without_candidate.copy_counts_only()
__pyx_t_1 = ((PyObject *)((struct __pyx_vtabstruct_27prolothar_process_discovery_9discovery_7proseqo_5cover_Cover *)__pyx_v_cover_without_candidate->__pyx_vtab)->copy_counts_only(__pyx_v_cover_without_candidate, 0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 105, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_cover = ((struct __pyx_obj_27prolothar_process_discovery_9discovery_7proseqo_5cover_Cover *)__pyx_t_1); __pyx_t_1 = 0;
106:
+107: cdef PatternDfg pattern_dfg = candidate.estimate_cover_change_for_lower_bound(
__pyx_t_2 = __pyx_v_candidate; __Pyx_INCREF(__pyx_t_2); /* … */ if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_mstate_global->__pyx_ptype_27prolothar_process_discovery_9discovery_7proseqo_11pattern_dfg_PatternDfg))))) __PYX_ERR(0, 107, __pyx_L1_error) __pyx_v_pattern_dfg = ((struct __pyx_obj_27prolothar_process_discovery_9discovery_7proseqo_11pattern_dfg_PatternDfg *)__pyx_t_1); __pyx_t_1 = 0;
+108: cover, pattern_dfg_without_candidate.copy(), dfg)
__pyx_t_3 = ((PyObject *)((struct __pyx_vtabstruct_27prolothar_process_discovery_9discovery_7proseqo_11pattern_dfg_PatternDfg *)__pyx_v_pattern_dfg_without_candidate->__pyx_base.__pyx_vtab)->copy(__pyx_v_pattern_dfg_without_candidate, 0)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 108, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = 0; { PyObject *__pyx_callargs[4] = {__pyx_t_2, ((PyObject *)__pyx_v_cover), __pyx_t_3, ((PyObject *)__pyx_v_dfg)}; __pyx_t_1 = __Pyx_PyObject_FastCallMethod(__pyx_mstate_global->__pyx_n_u_estimate_cover_change_for_lower, __pyx_callargs+__pyx_t_4, (4-__pyx_t_4) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET)); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 107, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); }
109:
+110: cdef float mdl_score = compute_encoded_length_of_pattern_dfg(
__pyx_t_6.__pyx_n = 1; __pyx_t_6.verbose = __pyx_v_verbose; __pyx_t_5 = __pyx_f_27prolothar_process_discovery_9discovery_7proseqo_9mdl_score_compute_encoded_length_of_pattern_dfg(__pyx_v_pattern_dfg, ((PyObject*)__pyx_t_1), 0, &__pyx_t_6); if (unlikely(__pyx_t_5 == ((float)-1) && PyErr_Occurred())) __PYX_ERR(0, 110, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_mdl_score = __pyx_t_5;
+111: pattern_dfg, cover.get_activity_set(), verbose=verbose)
__pyx_t_1 = ((struct __pyx_vtabstruct_27prolothar_process_discovery_9discovery_7proseqo_5cover_Cover *)__pyx_v_cover->__pyx_vtab)->get_activity_set(__pyx_v_cover, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 111, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1);
+112: mdl_score += cover.get_encoded_length_of_cover(log, verbose=verbose)
__pyx_t_7.__pyx_n = 1;
__pyx_t_7.verbose = __pyx_v_verbose;
__pyx_t_5 = ((struct __pyx_vtabstruct_27prolothar_process_discovery_9discovery_7proseqo_5cover_Cover *)__pyx_v_cover->__pyx_vtab)->get_encoded_length_of_cover(__pyx_v_cover, __pyx_v_log, 0, &__pyx_t_7); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 112, __pyx_L1_error)
__pyx_v_mdl_score = (__pyx_v_mdl_score + __pyx_t_5);
+113: return mdl_score
__pyx_r = __pyx_v_mdl_score; goto __pyx_L0;