Example #1
0
    def __createSATformula(self, pn, m0, mf, max_d, max_t, traces_xes,
                           nbTraces):
        '''
        This function creates and solve the SAT formula of the clustering problem.
        :param pn (Petrinet)
        :param m0 (Marking)
        :param mf (Marking)
        :param max_d (int)
        :param max_t (int)
        :param traces_xes (Log)
        '''
        # this object creates variable numbers of the SAT formula
        self.__vars = VariablesGenerator()
        # formula version of data event log
        log_to_PN_w_formula, self.__traces = log_to_Petri_with_w(
            traces_xes,
            self.__transitions,
            self.__vars,
            self.__size_of_run,
            self.__wait_transition_trace,
            self.__wait_transition_model,
            label_l=BOOLEAN_VAR_TRACES_ACTIONS,
            max_nbTraces=nbTraces)
        # creates the boolean variables for the next formulas
        self.__createBooleanVariables()
        # formula of centroids
        centroidsFormulasList = self.__createCentroids(m0, mf)
        # formula that describes maximal distance
        diffTracesCentroids = self.__getDiffTracesCentroids(
            self.__vars.getFunction(BOOLEAN_VAR_CHI_TRANSITIONS),
            self.__vars.getFunction(BOOLEAN_VAR_DIFF_l),
            self.__vars.getFunction(BOOLEAN_VAR_DIFF_m),
            self.__vars.getFunction(BOOLEAN_VAR_TRACES_ACTIONS))

        # formula that create BOOLEAN_VAR_COMMON_T variables
        listOfCommonTransitions = self.__commonTransitions(
            self.__vars.getFunction(BOOLEAN_VAR_COMMON_T),
            self.__vars.getFunction(BOOLEAN_VAR_K_CONTAINS_T))
        # formula that describes that a trace belongs to at most one cluster
        aClusterMax = self.__tracesInAClusterOnly(
            self.__vars.getFunction(BOOLEAN_VAR_J_CLUSTERISED),
            self.__vars.getFunction(BOOLEAN_VAR_J_IN_K))
        # concat the formula
        full_formula = And([], [], log_to_PN_w_formula +
                           centroidsFormulasList + diffTracesCentroids +
                           listOfCommonTransitions + aClusterMax)
        # formula to cnf
        cnf = full_formula.operatorToCnf(self.__vars.iterator)

        # CNF is completed with minimisation and solved
        self.__createWCNFWithMinimization(cnf)
Example #2
0
    def __createWncf(self, initialisationFormulas, distanceFormula,
                     artefactForMinimization):
        '''
        This method creates the wncf formulas with the weighted variables depending on the distance and artefact.
        :param initialisationFormulas: @see __artefactsInitialisation
        :param distanceFormula: @see __compute_distance
        :param artefactForMinimization: MULTI_ALIGNMENT or ANTI_ALIGNMENT or EXACT_ALIGNMENT
        :return:
        '''
        formulas = initialisationFormulas + distanceFormula + self.__sup_to_minimize(
            artefactForMinimization)
        full_formula = And([], [], formulas)
        cnf = full_formula.operatorToCnf(self.__vars.iterator)
        wcnf = WCNF()
        wcnf.extend(cnf)
        wcnf = self.__createWeights(wcnf, artefactForMinimization)

        self.__formula_time = time.time()
        return wcnf